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
SchemaPlus
Search
Michał Łomnicki
November 21, 2012
Technology
1
43
SchemaPlus
Michał Łomnicki
November 21, 2012
Tweet
Share
More Decks by Michał Łomnicki
See All by Michał Łomnicki
DDD, Rails and persistence
mlomnicki
1
280
Forget Ruby. Forget CoffeeScript. Do SOA
mlomnicki
1
120
Having fun with legacy apps
mlomnicki
1
65
CAP Theorem
mlomnicki
2
130
[PL] Transakcje w bazach danych
mlomnicki
1
230
Ruby Tricks 2
mlomnicki
3
68
Other Decks in Technology
See All in Technology
2025-10-09_プロジェクトマネージャーAIチャンス
taukami
0
140
やる気のない自分との向き合い方/How to Deal with Your Unmotivated Self
sanogemaru
0
500
これがLambdaレス時代のChatOpsだ!実例で学ぶAmazon Q Developerカスタムアクション活用法
iwamot
PRO
6
1.1k
GoでもGUIアプリを作りたい!
kworkdev
PRO
0
140
OAuthからOIDCへ ― 認可の仕組みが認証に拡張されるまで
yamatai1212
0
120
ユーザーの声とAI検証で進める、プロダクトディスカバリー
sansantech
PRO
1
140
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
14k
Node.js 2025: What's new and what's next
ruyadorno
0
300
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
技育祭2025【秋】 企業ピッチ/登壇資料(高橋 悟生)
hacobu
PRO
0
100
業務効率化をさらに加速させる、ノーコードツールとStep Functionsのハイブリッド化
smt7174
2
140
Codexとも仲良く。CodeRabbit CLIの紹介
moongift
PRO
0
210
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
5.8k
Automating Front-end Workflow
addyosmani
1371
200k
Six Lessons from altMBA
skipperchong
29
4k
The Cost Of JavaScript in 2023
addyosmani
55
9k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
20
1.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
KATA
mclloyd
32
15k
Faster Mobile Websites
deanohume
310
31k
Raft: Consensus for Rubyists
vanstee
140
7.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Transcript
SchemaPlus enhanced capabilities for schema definition and querying Ronen Barzel
& Michał Łomnicki
History Simon Harris / harukizaemon redhillonrails_core (2006, 2009) foreign_key_migrations =>
automatic_foreign_key schema_plus (2011)
Goals solid base well-tested well-documented better name :)
Plain ActiveRecord create_table :comments do |t| t.text :body t.integer :post_id
t.integer :author_id end execute "ALTER TABLE comments ADD FOREIGN KEY (post_id) \ REFERENCES (posts)" execute "ALTER TABLE comments ADD FOREIGN KEY (author_id) \ REFERENCES (users)" add_index :comments, :post_id
With schema_plus create_table :comments do |t| t.text :body t.integer :post_id,
:index => true t.integer :author_id, :references => :users end
auto-index foreign keys # without auto_index t.integer :post_id, :index =>
true # with auto_index t.integer :post_id
index t.string :area_code t.string :local_number, :index => { :unique =>
true, :with => :area_code }
Other features global, per table and per statement config expressional
indexes views
SchemaAssociations # without schema_associations class Post < ActiveRecord::Base belongs_to :author
has_many :comments end
SchemaAssociations # without schema_associations class Post < ActiveRecord::Base # associations
auto-created from foreign keys end
SchemaValidations create_table :posts do |t| t.integer :author_id, :null => false,
:references => :users t.integer :likes_count t.string :content, :limit => 5_000 end
SchemaValidations # without schema_validations class Post < ActiveRecord::Base validates :author,
:presence => true validates :likes_count, :numericality => true validates :content, :length => { :maximum => 5_000 } end
SchemaValidations # with schema_validations class Post < ActiveRecord::Base end
Schema Family Scary? ...but that's next step for active record
pattern
Questions http://github.com/lomba