add index in migrate file

This commit is contained in:
phyusin
2018-07-06 11:55:22 +06:30
parent 6e197fb37e
commit 8e28559fb0
20 changed files with 63 additions and 48 deletions

View File

@@ -3,10 +3,10 @@ class CreatePromotion < ActiveRecord::Migration[5.1]
create_table :promotions do |t|
t.string :promo_code, :limit => 16
t.date :promo_start_date, :null => false
t.date :promo_end_date, :null => false
t.time :promo_start_hour, :null => false
t.time :promo_end_hour, :null => false
t.date :promo_start_date, :null => false, :index => true
t.date :promo_end_date, :null => false, :index => true
t.time :promo_start_hour, :null => false, :index => true
t.time :promo_end_hour, :null => false, :index => true
t.string :promo_day, :null => false, :default => "[0,1,2,3,4,5,6]"
t.string :promo_type, :null => false, :default => "Quantity"
t.string :original_product
@@ -14,5 +14,6 @@ class CreatePromotion < ActiveRecord::Migration[5.1]
t.string :created_by, :null => false
t.timestamps
end
add_index :promotions, [:promo_start_date, :promo_end_date, :promo_start_hour, :promo_end_hour], name: 'index_promotions'
end
end