# encoding:utf-8
class CreateRelatedPromotions < ActiveRecord::Migration
  def up

    create_table :depart_records_promotions do |t|
      t.integer :promotion_id
      t.integer :depart_record_id
    end

    create_table :depart_records_shop_promotions do |t|
      t.integer :shop_promotion_id
      t.integer :depart_record_id
    end


    create_table :depart_records_balance_promotions do |t|
      t.integer :balance_promotion_id
      t.integer :depart_record_id
    end


    add_index :depart_records_promotions,
              [:promotion_id, :depart_record_id],
              :name => "idx_pomotion_d_r_id"

    add_index :depart_records_shop_promotions,
              [:shop_promotion_id, :depart_record_id],
              :name => "idx_shop_pomotion_d_r_id"


    add_index :depart_records_balance_promotions,
              [:balance_promotion_id, :depart_record_id],
              :name => "idx_balance_pomotion_d_r_id"

  end

  def down
    drop_table :depart_records_promotions
    drop_table :depart_records_shop_promotions
    drop_table :depart_records_balance_promotions
  end

end
