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
33
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
670
Serverless Is Ruby Future
ssnickolay
0
630
Anything new Rails 6?
ssnickolay
1
1.2k
Serverless for mere mortals
ssnickolay
1
720
Evolution of Rails application architecture: 14 years in production
ssnickolay
3
1.1k
A Healthy Monolith
ssnickolay
0
1.1k
Elixir. There and Back Again
ssnickolay
0
560
Other Decks in Programming
See All in Programming
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
230
はじめての Go * WASM * OCR
sgash708
1
120
CloudNativePGを布教したい
nnaka2992
0
120
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
320
SwiftUI移行のためのインプレッショントラッキング基盤の構築
kokihirokawa
0
170
ソフトウェアエンジニアの成長
masuda220
PRO
12
2.2k
sappoRo.R #12 初心者セッション
kosugitti
0
280
苦しいTiDBへの移行を乗り越えて快適な運用を目指す
leveragestech
0
1.2k
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.3k
15分で学ぶDuckDBの可愛い使い方 DuckDBの最近の更新
notrogue
3
830
Google Cloudとo11yで実現するアプリケーション開発者主体のDB改善
nnaka2992
1
110
もう少しテストを書きたいんじゃ〜 #phpstudy
o0h
PRO
21
4.3k
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Code Reviewing Like a Champion
maltzj
521
39k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1.1k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Six Lessons from altMBA
skipperchong
27
3.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.4k
Faster Mobile Websites
deanohume
306
31k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Practical Orchestrator
shlominoach
186
10k
Gamification - CAS2011
davidbonilla
80
5.2k
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 • …