21.05.2014 Views

PostgreSQL as a secret weapon for high-performance ... - PGCon

PostgreSQL as a secret weapon for high-performance ... - PGCon

PostgreSQL as a secret weapon for high-performance ... - PGCon

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Rails <strong>as</strong> ORM > Migrations<br />

Use SQL DDL not Rails DSL<br />

(unless targeting multiple RDBMS)<br />

Schema in SQL vs Rails parlance<br />

Migration in SQL<br />

Migration in Rails parlance<br />

execute "<br />

create table Foo (<br />

id serial not null,<br />

name varchar(20),<br />

bar_id integer,<br />

"<br />

);<br />

primary key (id),<br />

<strong>for</strong>eign key (bar_id)<br />

references Bar (id)<br />

create_table :foo do |t|<br />

t.string :name, :limit => 20<br />

t.references :bar<br />

end<br />

execute "alter table foo add<br />

<strong>for</strong>eign key (bar_id)<br />

references Bar (id)"<br />

Gleb Arshinov & Alex Dymo ● <strong>PostgreSQL</strong> <strong>as</strong> a <strong>secret</strong> <strong>weapon</strong> <strong>for</strong> <strong>high</strong>-per<strong>for</strong>mance Ruby on Rails applications ● <strong>PGCon</strong> 2010 18 / 58

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!