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
37
SchemaPlus
Michał Łomnicki
November 21, 2012
Tweet
Share
More Decks by Michał Łomnicki
See All by Michał Łomnicki
DDD, Rails and persistence
mlomnicki
1
250
Forget Ruby. Forget CoffeeScript. Do SOA
mlomnicki
1
120
Having fun with legacy apps
mlomnicki
1
58
CAP Theorem
mlomnicki
2
110
[PL] Transakcje w bazach danych
mlomnicki
1
110
Ruby Tricks 2
mlomnicki
3
52
Other Decks in Technology
See All in Technology
GraphQL 成熟度モデルの紹介と、プロダクトに当てはめた事例 / GraphQL maturity model
mh4gf
7
1.3k
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
230
Gitlab本から学んだこと - そーだいなるプレイバック / gitlab-book
soudai
4
300
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
120
Azureの基本的な権限管理の勉強会
yhana
0
280
Cracking the KubeCon CfP
inductor
2
240
ここが嬉しいABAC ここが辛いよABAC #再解説+補足編
masahirokawahara
1
270
Compose Compiler Metricsを使った実践的なコードレビュー
tomorrowkey
1
220
Yahoo! 知恵袋フロントエンドをリアーキテクトしている話
lycorptech_jp
PRO
1
110
開発パフォーマンスを最大化するための開発体制
ham0215
2
360
サーバー間 GraphQL と webmock-graphql の話 / server-to-server graphql and webmock-graphql
qsona
2
180
DevOpsDays History and my DevOps story
kawaguti
PRO
9
2.5k
Featured
See All Featured
Web development in the modern age
philhawksworth
202
10k
How to Ace a Technical Interview
jacobian
272
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
125
32k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
357
22k
Building an army of robots
kneath
300
41k
Music & Morning Musume
bryan
41
5.6k
Art, The Web, and Tiny UX
lynnandtonic
289
19k
How GitHub (no longer) Works
holman
304
140k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
241
1.2M
Optimizing for Happiness
mojombo
370
69k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.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