Sha256: 262dcf79a7e88204c42ad9156a1f658777670eae664e462b7a883b8aa92aed1f

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

class CreateSpreePromotionCodeBatch < ActiveRecord::Migration[5.0]
  def change
    unless table_exists?(:spree_promotion_code_batches)
      create_table :spree_promotion_code_batches do |t|
        t.references :promotion, null: false, index: true, type: :integer
        t.string :base_code, null: false
        t.integer :number_of_codes, null: false
        t.string :email
        t.string :error
        t.string :state, default: "pending"
        t.timestamps precision: 6
      end
    end

    unless foreign_key_exists?(:spree_promotion_code_batches, :spree_promotions)
      add_foreign_key(
        :spree_promotion_code_batches,
        :spree_promotions,
        column: :promotion_id
      )
    end

    unless column_exists?(:spree_promotion_codes, :promotion_code_batch_id)
      add_column(
        :spree_promotion_codes,
        :promotion_code_batch_id,
        :integer,
      )
    end

    unless foreign_key_exists?(:spree_promotion_codes, :spree_promotion_code_batches)
      add_foreign_key(
        :spree_promotion_codes,
        :spree_promotion_code_batches,
        column: :promotion_code_batch_id,
      )
    end

    unless index_exists?(:spree_promotion_codes, :promotion_code_batch_id)
      add_index(
        :spree_promotion_codes,
        :promotion_code_batch_id,
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_legacy_promotions-4.5.1 db/migrate/20161017102621_create_spree_promotion_code_batch.rb
solidus_legacy_promotions-4.5.0 db/migrate/20161017102621_create_spree_promotion_code_batch.rb
solidus_legacy_promotions-4.4.2 db/migrate/20161017102621_create_spree_promotion_code_batch.rb
solidus_legacy_promotions-4.4.1 db/migrate/20161017102621_create_spree_promotion_code_batch.rb
solidus_legacy_promotions-4.4.0 db/migrate/20161017102621_create_spree_promotion_code_batch.rb