Sha256: d90485b34ed6fb43d77b2ffad0974229cbe51a1d2e659cb4e86f8f2aa52c16fa

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

class UpdateSpreeUniqueIndexesWithTenantScope < ActiveRecord::Migration[7.0]
  # If using a different tenant model, you will need to change the :tenant_id column name in the following indexes.
  def up
    remove_index :spree_preferences, name: :index_spree_preferences_on_key
    remove_index :spree_products, name: :index_spree_products_on_slug

    add_index :spree_preferences, %i[tenant_id key], unique: true, name: :index_spree_preferences_on_tenant_and_key
    add_index :spree_products, %i[tenant_id slug], unique: true, name: :index_spree_products_on_tenant_and_slug
  end

  def down
    remove_index :spree_preferences, name: :index_spree_preferences_on_tenant_and_key
    remove_index :spree_products, name: :index_spree_products_on_tenant_and_slug

    add_index :spree_preferences, :key, unique: true, name: :index_spree_preferences_on_key
    add_index :spree_products, :slug, unique: true, name: :index_spree_products_on_slug
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_act_as_tenant-0.0.3 db/migrate/20241204055845_update_spree_unique_indexes_with_tenant_scope.rb