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
42
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
67
Other Decks in Technology
See All in Technology
「Linux」という言葉が指すもの
sat
PRO
4
140
「全員プロダクトマネージャー」を実現する、Cursorによる仕様検討の自動運転
applism118
22
12k
エンジニアリングマネージャーの成長の道筋とキャリア / Developers Summit 2025 KANSAI
daiksy
1
390
Webブラウザ向け動画配信プレイヤーの 大規模リプレイスから得た知見と学び
yud0uhu
0
240
新アイテムをどう使っていくか?みんなであーだこーだ言ってみよう / 20250911-rpi-jam-tokyo
akkiesoft
0
310
複数サービスを支えるマルチテナント型Batch MLプラットフォーム
lycorptech_jp
PRO
1
780
人工衛星のファームウェアをRustで書く理由
koba789
15
8.1k
初めてAWSを使うときのセキュリティ覚書〜初心者支部編〜
cmusudakeisuke
1
270
EncryptedSharedPreferences が deprecated になっちゃった!どうしよう! / Oh no! EncryptedSharedPreferences has been deprecated! What should I do?
yanzm
0
460
DevIO2025_継続的なサービス開発のための技術的意思決定のポイント / how-to-tech-decision-makaing-devio2025
nologyance
1
450
【実演版】カンファレンス登壇者・スタッフにこそ知ってほしいマイクの使い方 / 大吉祥寺.pm 2025
arthur1
1
890
Rustから学ぶ 非同期処理の仕組み
skanehira
1
140
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Done Done
chrislema
185
16k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Become a Pro
speakerdeck
PRO
29
5.5k
Designing for Performance
lara
610
69k
Six Lessons from altMBA
skipperchong
28
4k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.8k
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