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
49
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
76
CAP Theorem
mlomnicki
2
140
[PL] Transakcje w bazach danych
mlomnicki
1
280
Ruby Tricks 2
mlomnicki
3
79
Other Decks in Technology
See All in Technology
タクシーアプリ『GO』の実践的データ活用
mot_techtalk
2
150
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
Chart.js が簡単に使えるようになっていたので OGP 画像生成に使った話
kamekyame
0
160
JEP 522 Deep Dive - G1 GC同期コスト削減によるスループット向上を徹底検証&解説
tabatad
1
860
コードレビューを制するチームがソフトウェアデリバリーのフローを制す / Beyond Code Review: Distributing Its Responsibilities Across the SDLC
mtx2s
4
1.1k
地元にいないローカルオーガナイザーの立ち回り
uvb_76
1
470
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1.2k
Dario Amodi『Policy on the AI Exponential』を理解する
nagatsu
0
190
AI駆動開発が変える、大規模開発の前提 ーHuman in the Loop から Human on the Loop へ / AIE2026
visional_engineering_and_design
7
5.2k
[モダンアプリ勉強会]今更聞けないGit/GitHub入門
tsukuboshi
0
270
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
2.7k
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
18
10k
Featured
See All Featured
Mind Mapping
helmedeiros
PRO
1
230
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
220
Deep Space Network (abreviated)
tonyrice
0
160
Rails Girls Zürich Keynote
gr2m
96
14k
The Limits of Empathy - UXLibs8
cassininazir
1
350
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
Fireside Chat
paigeccino
42
3.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Test your architecture with Archunit
thirion
1
2.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
300
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