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
43
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
68
Other Decks in Technology
See All in Technology
Dylib Hijacking on macOS: Dead or Alive?
patrickwardle
0
430
サイバーエージェント流クラウドコスト削減施策「みんなで金塊堀太郎」
kurochan
4
2.2k
HR Force における DWH の併用事例 ~ サービス基盤としての BigQuery / 分析基盤としての Snowflake ~@Cross Data Platforms Meetup #2「BigQueryと愉快な仲間たち」
ryo_suzuki
0
250
旅で応援する✈️ NEWTが目指すコミュニティ支援とあたらしい旅行 / New Travel: Supporting by NEWT on Your Journey
mii3king
0
120
「魔法少女まどか☆マギカ Magia Exedra」のIPのキャラクターを描くための3Dルック開発
gree_tech
PRO
0
130
生成AI時代のセキュアコーディングとDevSecOps
yuriemori
0
150
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
AIフル活用で挑む!空間アプリ開発のリアル
taat
0
130
AIとともに歩んでいくデザイナーの役割の変化
lycorptech_jp
PRO
0
770
生成AIを安心して活用するために──「情報セキュリティガイドライン」策定とポイント
gree_tech
PRO
0
140
もう外には出ない。より快適なフルリモート環境を目指して
mottyzzz
10
5.7k
[VPoE Global Summit] サービスレベル目標による信頼性への投資最適化
satos
0
200
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.5k
Building an army of robots
kneath
306
46k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Faster Mobile Websites
deanohume
310
31k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
920
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Rails Girls Zürich Keynote
gr2m
95
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
10
880
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How to train your dragon (web standard)
notwaldorf
97
6.3k
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