Remember that sexy_migrations plugin that I chatted about back in March? Well, changeset 6667 has updated Rails to incorporate this migration style into the core.
I read through the updated code and it doesn't appear that the sexy migration style for foreign keys is supported. At this point, it looks like what has been incorporated is a shorthand notation for datatyping the column names (especially nice for the timestamp columns). Of course, I'm not a Ruby expert so maybe I'm wrong. I'll report back if I am.
Not sure how to use it? There are some decent comments by DHH checked in along with the change:
Instead of calling column directly, you can also work with the short-hand definitions for the default types. They use the type as the method name instead of as a parameter and allow for multiple columns to be defined in a single statement.
What can be written like this with the regular calls to column:
[ruby] create_table "products", :force => true do |t| t.column "shop_id", :integer t.column "creator_id", :integer t.column "name", :string, :default => "Untitled" t.column "value", :string, :default => "Untitled" t.column "created_at", :datetime t.column "updated_at", :datetime end [/ruby]Can also be written as follows using the short-hand:
[ruby] create_table :products do |t| t.integer :shop_id, :creator_id t.string :name, :value, :default => "Untitled" t.timestamps end [/ruby]There's a short-hand method for each of the type values declared at the top. And then there's TableDefinition#timestamps that'll add created_at and updated_at as datetimes.