cirandas.net

ref: master

db/migrate/20150310132902_add_id_to_favorite_enterprises_people.rb


 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
26
class AddIdToFavoriteEnterprisesPeople < ActiveRecord::Migration
  def up
    rename_table :favorite_enteprises_people, :favorite_enterprise_people

    change_table :favorite_enterprise_people do |t|
      t.timestamps
    end
    add_column :favorite_enterprise_people, :id, :primary_key

    add_index :favorite_enterprise_people, [:person_id, :enterprise_id]
    add_index :favorite_enterprise_people, :person_id
    add_index :favorite_enterprise_people, :enterprise_id
  end

  def down
    rename_table :favorite_enterprise_people, :favorite_enteprises_people

    remove_column :favorite_enteprises_people, :id
    remove_column :favorite_enteprises_people, :created_at
    remove_column :favorite_enteprises_people, :updated_at

    remove_index :favorite_enteprises_people, [:person_id, :enterprise_id]
    remove_index :favorite_enteprises_people, :person_id
    remove_index :favorite_enteprises_people, :enterprise_id
  end
end