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
48
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
72
CAP Theorem
mlomnicki
2
140
[PL] Transakcje w bazach danych
mlomnicki
1
280
Ruby Tricks 2
mlomnicki
3
74
Other Decks in Technology
See All in Technology
VespaのParent Childを用いたフィードパフォーマンスの改善
taking
0
220
多角的な視点から見たAGI
terisuke
0
120
アクセシビリティはすべての人のもの
tomokusaba
0
240
Forget technical debt
ufried
0
160
AIの揺らぎに“コシ”を与える階層化品質設計
ickx
0
210
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
170
変化の激しい時代をゴキゲンに生き抜くために 〜ストレスマネジメントのススメ〜
kakehashi
PRO
4
830
UIライブラリに依存しすぎないReact Native設計を目指して
grandbig
0
190
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
2.3k
コミュニティ・勉強会を作るのは目的じゃない
ohmori_yusuke
0
280
20260423_ハドソンのエロゲを追え_レトロゲーム
poropinai1966
0
110
AI時代に越境し、 組織を変えるQAスキルの正体 / QA Skills for Transforming an Organization
mii3king
5
3.5k
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
230
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
The Cult of Friendly URLs
andyhume
79
6.9k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
680
Designing for Timeless Needs
cassininazir
0
210
Visualization
eitanlees
150
17k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
160
Navigating Team Friction
lara
192
16k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
110
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Discover your Explorer Soul
emna__ayadi
2
1.1k
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