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
430
Serverless Is Ruby Future
ssnickolay
0
520
Anything new Rails 6?
ssnickolay
1
890
Serverless for mere mortals
ssnickolay
1
600
Evolution of Rails application architecture: 14 years in production
ssnickolay
3
960
A Healthy Monolith
ssnickolay
0
900
Elixir. There and Back Again
ssnickolay
0
420
Other Decks in Programming
See All in Programming
Ruby GitHub Packages
bkuhlmann
0
630
新宿ダンジョンを可視化してみた
satoshi7190
2
240
Site Reliability Engineering for GMO
pyama86
7
1k
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
210
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
Snowflakeで眠ったデータを起こそう!
estie
0
110
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
280
Semantic search with Django and pgvector
pauloxnet
0
240
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.1k
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
Tailwind CSSを本気でカスタマイズする方法
fsubal
13
5.2k
ONE WEDGE_company_guide
1wedge_one
0
460
Featured
See All Featured
A better future with KSS
kneath
231
16k
Raft: Consensus for Rubyists
vanstee
132
6.3k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
40
4.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
274
13k
Into the Great Unknown - MozCon
thekraken
10
990
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
Optimizing for Happiness
mojombo
370
69k
Design by the Numbers
sachag
274
18k
The Art of Programming - Codeland 2020
erikaheidi
42
12k
Adopting Sorbet at Scale
ufuk
68
8.6k
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 • …