class AddDiscountTables < ActiveRecord::Migration[<%= rails_migration_version %>] def change create_table :discounts do |t| t.bigint :discount_id t.string :name t.string :code t.string :discount_type, default: 'amount' t.decimal :value, default: 0 t.integer :duration_intervals t.integer :max_usage t.boolean :enabled, default: true t.datetime :valid_from t.datetime :valid_to t.integer :priority, default: 0 t.boolean :multiple_uses, default: true t.boolean :multiple_apps, default: true t.integer :app_id, default: 0 t.timestamps t.datetime :deleted_at end create_table :discount_shops do |t| t.bigint :discount_id, index: true, foreign_key: true t.string :domain end create_table :discounts_usage_log do |t| t.bigint :discount_id, index: true, foreign_key: true t.bigint :app_id, index: true, foreign_key: true t.string :domain t.boolean :sync, default: true t.string :process_type t.timestamps end create_table :discount_link_plans do |t| t.bigint :discount_id, index: true, foreign_key: true t.bigint :plan_id, index: true, foreign_key: true end end def down drop_table :discounts drop_table :discount_shops drop_table :discounts_usage_log drop_table :discount_link_plans end end