20210329114688_create_related_promotions.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # encoding:utf-8
  2. class CreateRelatedPromotions < ActiveRecord::Migration
  3. def up
  4. create_table :depart_records_promotions do |t|
  5. t.integer :promotion_id
  6. t.integer :depart_record_id
  7. end
  8. create_table :depart_records_shop_promotions do |t|
  9. t.integer :shop_promotion_id
  10. t.integer :depart_record_id
  11. end
  12. create_table :depart_records_balance_promotions do |t|
  13. t.integer :balance_promotion_id
  14. t.integer :depart_record_id
  15. end
  16. add_index :depart_records_promotions,
  17. [:promotion_id, :depart_record_id],
  18. :name => "idx_pomotion_d_r_id"
  19. add_index :depart_records_shop_promotions,
  20. [:shop_promotion_id, :depart_record_id],
  21. :name => "idx_shop_pomotion_d_r_id"
  22. add_index :depart_records_balance_promotions,
  23. [:balance_promotion_id, :depart_record_id],
  24. :name => "idx_balance_pomotion_d_r_id"
  25. end
  26. def down
  27. drop_table :depart_records_promotions
  28. drop_table :depart_records_shop_promotions
  29. drop_table :depart_records_balance_promotions
  30. end
  31. end