Sha256: b437812560c2c13d40faaad3ad059b4208ee31efd321dc0865b26af369d02fe0

Contents?: true

Size: 1.28 KB

Versions: 22

Compression:

Stored size: 1.28 KB

Contents

class AddTypeAndMetaToSpreeZone < ActiveRecord::Migration
  def up
    add_column :spree_zones, :klass, :text unless column_exists?(:spree_zones, :klass)
    add_column :spree_zones, :status, :text unless column_exists?(:spree_zones, :status)
    add_column :spree_zones, :meta, :jsonb, default: '{}' unless column_exists?(:spree_zones, :meta)

    add_index :spree_zones, :meta, using: :gin unless index_exists?(:spree_zones, :meta)
    add_index :spree_zones, %i[id klass] unless index_exists?(:spree_zones, %i[id klass])
    add_index :spree_zones, %i[klass name], unique: true unless index_exists?(:spree_zones, %i[klass name])
    add_index :spree_zones, :status unless index_exists?(:spree_zones, :status)
  end

  def down
    remove_index :spree_zones, :status if index_exists?(:spree_zones, :status)
    remove_index :spree_zones, %i[klass name] if index_exists?(:spree_zones, %i[klass name])
    remove_index :spree_zones, %i[id klass] if index_exists?(:spree_zones, %i[id klass])
    remove_index :spree_zones, :meta if index_exists?(:spree_zones, :meta)

    remove_column :spree_zones, :meta if column_exists?(:spree_zones, :meta)
    remove_column :spree_zones, :status if column_exists?(:spree_zones, :status)
    remove_column :spree_zones, :klass if column_exists?(:spree_zones, :klass)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
flowcommerce_spree-0.0.22 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.21 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.20 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.19 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.18 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.17 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.16 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.15 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.14 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.13 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.12 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.11 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.10 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.9 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.8 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.7 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.6 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.5 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.4 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
flowcommerce_spree-0.0.3 db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb