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
40
SchemaPlus
Michał Łomnicki
November 21, 2012
Tweet
Share
More Decks by Michał Łomnicki
See All by Michał Łomnicki
DDD, Rails and persistence
mlomnicki
1
270
Forget Ruby. Forget CoffeeScript. Do SOA
mlomnicki
1
120
Having fun with legacy apps
mlomnicki
1
62
CAP Theorem
mlomnicki
2
120
[PL] Transakcje w bazach danych
mlomnicki
1
170
Ruby Tricks 2
mlomnicki
3
60
Other Decks in Technology
See All in Technology
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
700
速くて安いWebサイトを作る
nishiharatsubasa
10
12k
開発スピードは上がっている…品質はどうする? スピードと品質を両立させるためのプロダクト開発の進め方とは #DevSumi #DevSumiB / Agile And Quality
nihonbuson
2
2.8k
Datadogとともにオブザーバビリティを布教しよう
mego2221
0
140
組織貢献をするフリーランスエンジニアという生き方
n_takehata
1
1.3k
開発組織のための セキュアコーディング研修の始め方
flatt_security
3
2k
データの品質が低いと何が困るのか
kzykmyzw
6
1.1k
利用終了したドメイン名の最強終活〜観測環境を育てて、分析・供養している件〜 / The Ultimate End-of-Life Preparation for Discontinued Domain Names
nttcom
2
180
リアルタイム分析データベースで実現する SQLベースのオブザーバビリティ
mikimatsumoto
0
1.3k
リーダブルテストコード 〜メンテナンスしやすい テストコードを作成する方法を考える〜 #DevSumi #DevSumiB / Readable test code
nihonbuson
11
7.1k
データマネジメントのトレードオフに立ち向かう
ikkimiyazaki
6
840
スタートアップ1人目QAエンジニアが QAチームを立ち上げ、“個”からチーム、 そして“組織”に成長するまで / How to set up QA team at reiwatravel
mii3king
2
1.4k
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
How to train your dragon (web standard)
notwaldorf
91
5.8k
Code Reviewing Like a Champion
maltzj
521
39k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
A designer walks into a library…
pauljervisheath
205
24k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
Automating Front-end Workflow
addyosmani
1368
200k
A Modern Web Designer's Workflow
chriscoyier
693
190k
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