ramon (owner)

Revisions

gist: 147987 Download_button fork
public
Public Clone URL: git://gist.github.com/147987.git
Embed All Files: show embed
Text #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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