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
47
1
Share
SchemaPlus
Michał Łomnicki
November 21, 2012
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
130
Having fun with legacy apps
mlomnicki
1
69
CAP Theorem
mlomnicki
2
130
[PL] Transakcje w bazach danych
mlomnicki
1
280
Ruby Tricks 2
mlomnicki
3
73
Other Decks in Technology
See All in Technology
プロダクトを触って語って理解する、チーム横断バグバッシュのすすめ / 20260411 Naoki Takahashi
shift_evolve
PRO
1
250
3つのボトルネックを解消し、リリースエンジニアリングを再定義した話
nealle
0
340
ADOTで始めるサーバレスアーキテクチャのオブザーバビリティ
alchemy1115
2
270
I ran an automated simulation of fake news spread using OpenClaw.
zzzzico
1
1k
レガシーシステムをどう次世代に受け継ぐか
tachiiri
0
330
主催・運営として"場をつくる”というアウトプットのススメ
_mossann_t
0
130
2026年度新卒技術研修 サイバーエージェントのデータベース 活用事例とパフォーマンス調査入門
cyberagentdevelopers
PRO
6
7.1k
今年60歳のおっさんCBになる
kentapapa
1
350
Hooks, Filters & Now Context: Why MCPs Are the “Hooks” of the AI Era
miriamschwab
0
130
2026年春から始めるOpenTelemetry | sogaoh's LT @ PHP Conference ODAWARA 2026
sogaoh
PRO
0
100
AIを活用したアクセシビリティ改善フロー
degudegu2510
1
160
Hello UUID
mimifuwacc
0
130
Featured
See All Featured
Leo the Paperboy
mayatellez
7
1.6k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
330
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Mind Mapping
helmedeiros
PRO
1
150
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
430
Large-scale JavaScript Application Architecture
addyosmani
515
110k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Writing Fast Ruby
sferik
630
63k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
880
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
BBQ
matthewcrist
89
10k
Become a Pro
speakerdeck
PRO
31
5.9k
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