Sha256: 696e7fed3a0e1f36e82f9e24e95257a4c095176639c5efb1d4277531ad840ce2

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

class CreateOptionTypeTranslations < ActiveRecord::Migration[6.1]
  def change
    if ActiveRecord::Base.connection.table_exists? 'spree_option_type_translations'
      # manually check for index since Rails if_exists does not always work correctly
      if ActiveRecord::Migration.connection.index_exists?(:spree_option_type_translations, :spree_option_type_id)
        remove_index :spree_option_type_translations, name: "index_spree_option_type_translations_on_spree_option_type_id", if_exists: true
      end
    else
      create_table :spree_option_type_translations do |t|

        # Translated attribute(s)
        t.string :name
        t.string :presentation

        t.string  :locale, null: false
        t.references :spree_option_type, null: false, foreign_key: true, index: false

        t.timestamps
      end

      add_index :spree_option_type_translations, :locale, name: :index_spree_option_type_translations_on_locale
    end

    add_index :spree_option_type_translations, [:spree_option_type_id, :locale], name: :unique_option_type_id_per_locale, unique: true
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spree_core-4.7.3 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.6 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.5 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.7.2 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.7.1 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.4 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.7.0 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.3 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.2 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.1 db/migrate/20230103144439_create_option_type_translations.rb
spree_core-4.6.0 db/migrate/20230103144439_create_option_type_translations.rb