Skip to content

Instantly share code, notes, and snippets.

@ramon
Created July 15, 2009 21:06
Show Gist options
  • Save ramon/147987 to your computer and use it in GitHub Desktop.
Save ramon/147987 to your computer and use it in GitHub Desktop.
class CreateAddresses < ActiveRecord::Migration
def self.up
create_table :addresses do |t|
t.belongs_to :addressable, :polymorphic => true
t.integer :kind, :limit => 2
t.belongs_to :city
t.belongs_to :zone
t.string :street, :complement
t.string :number, :limit => 10
t.string :zipcode, :limit => 15
t.text :reference
end
add_index :addresses, [:addressable_id, :addressable_type]
add_index :addresses, :kind
add_index :addresses, :city_id
add_index :addresses, :zone_id
add_index :addresses, :zipcode
end
def self.down
drop_table :addresses
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment