Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails 6: ActiveRecord
Search
Nikolay Sverchkov
November 30, 2019
Programming
0
29
Rails 6: ActiveRecord
Nikolay Sverchkov
November 30, 2019
Tweet
Share
More Decks by Nikolay Sverchkov
See All by Nikolay Sverchkov
Authorization in the GraphQL era
ssnickolay
0
570
Serverless Is Ruby Future
ssnickolay
0
580
Anything new Rails 6?
ssnickolay
1
1k
Serverless for mere mortals
ssnickolay
1
660
Evolution of Rails application architecture: 14 years in production
ssnickolay
3
1k
A Healthy Monolith
ssnickolay
0
1k
Elixir. There and Back Again
ssnickolay
0
490
Other Decks in Programming
See All in Programming
Why I Choose NetBeans for Jakarta EE
ivargrimstad
0
350
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
120
Cloud Adoption Frameworkにみる組織とクラウド導入戦略(縮小版)
tomokusaba
1
230
Competitionsだけじゃない! Kaggle Notebooks Grandmasterのすすめ
corochann
2
720
Kubernetes上でOracle_Databaseの運用を楽にするOraOperatorの紹介
nnaka2992
0
160
個人開発で使ってるやつを紹介する回
yohfee
1
710
NEWTにおけるiOS18対応の進め方
ryu1sazae
0
250
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
0
190
データフレームライブラリ徹底比較
daikikatsuragawa
2
110
4年間変わらなかった YOUTRUSTのアーキテクチャ
daiki1003
1
650
Modern Angular with Lightweight Stores: New Rules and Options
manfredsteyer
PRO
0
110
PHPを書く理由、PHPを書いていて良い理由 / Reasons to write PHP and why it is good to write PHP
seike460
PRO
5
480
Featured
See All Featured
Atom: Resistance is Futile
akmur
261
25k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
4
120
Faster Mobile Websites
deanohume
304
30k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Debugging Ruby Performance
tmm1
73
12k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Designing for humans not robots
tammielis
249
25k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Testing 201, or: Great Expectations
jmmastey
38
7k
Happy Clients
brianwarren
97
6.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Transcript
NIKOLAY SVERCHKOV @ssnickolay ACTIVE RECORD 6+
#saintprubyconf @ssnickolay
@ssnickolay RAILS 6.0 MULTIPLE DATABASE SUPPORT
@ssnickolay gem ‘octopus’
@ssnickolay gem ‘octopus’ FOCUSED ON
@ssnickolay RAILS 6.0: MULTI DB MULTI DB = DB SHARDING
= + + + VERTICAL OR HORIZONTAL PARTITIONING / REPLICATION
@ssnickolay RAILS 6.0: MULTI DB RAILS DID NOT HAVE ADEQUATE*
MULTI DB SUPPORT *https://github.com/ankane/multiverse
@ssnickolay RAILS 6.0: MULTI DB MULTI DB !!= DATABASE SHARDING
@ssnickolay AT LEAST 12 HUGE PRS FROM @EILEENCODES RAILS 6.0:
MULTI DB
WHEN YOU RELEASE THE NEW FEATURE
@ssnickolay RAILS 6.0: MULTI DB MULTI DB !!= DATABASE SHARDING
?
@ssnickolay RAILS 6.0: MULTI DB MULTI DB !!= DATABASE SHARDING
@ssnickolay RAILS 6.0: BULK INSERTS # Insert multiple records, performing
an upsert # when records have duplicate ISBNs Book.upsert_all([ { title: 'Rework', author: 'David', isbn: '1' }, { title: 'Eloquent Ruby', author: 'Russ', isbn: '1' } ], unique_by: { columns: %w[ isbn ] }) *gem ‘activerecord-import`
@ssnickolay RAILS 6.0: update Rails 4.0.2 update_attributes(column: value) update(column: value)
Rails 6+ update(column: value) Deprecate `update_attributes`
@ssnickolay RAILS 6.0: update Rails 4.0.2 update_attributes(column: value) update(column: value)
Rails 6+ update(column: value) Deprecate `update_attributes`
@ssnickolay RAILS 6.0: create_or_find_by find_or_create_by vs create_or_find_by
@ssnickolay find_or_create_by def find_or_create_by!(attributes, &block) find_by(attributes) !|| create!(attributes, &block) end
@ssnickolay find_or_create_by def find_or_create_by!(attributes, &block) find_by(attributes) !|| <Вот-Тут-> create!(attributes, &block)
end
@ssnickolay RAILS 6.0: create_or_find_by def create_or_find_by(attributes, &block) transaction(requires_new: true) {
create(attributes, &block) } rescue ActiveRecord!::RecordNotUnique find_by!(attributes) end
@ssnickolay RAILS 6.0: create_or_find_by def create_or_find_by(attributes, &block) transaction(requires_new: true) {
create(attributes, &block) } rescue ActiveRecord!::RecordNotUnique <Вот-Тут-> find_by!(attributes) end
@ssnickolay RAILS 6.0: Other • Make t.timestamps with precision by
default • Add support for UNLOGGED Postgresql tables • Add support for annotating queries generated by ActiveRecord::Relation with SQL comments • Make it possible to override the implicit order column • …