Sha256: f658dbc6d3c093ec0252b5012b38627742af140a4ebd5bd2bd2a11877bf89d7e

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

class CreateSpreeTaxonNameAndDescriptionTranslationsForMobilityTableBackend < ActiveRecord::Migration[6.1]
  def change
    # create translation table only if spree_globalize has not already created it
    if ActiveRecord::Base.connection.table_exists? 'spree_taxon_translations'
      # manually check for index since Rails if_exists does not always work correctly
      if ActiveRecord::Migration.connection.index_exists?(:spree_taxon_translations, :spree_taxon_id)
        # replacing this with index on spree_taxon_id and locale
        remove_index :spree_taxon_translations, name: "index_spree_taxon_translations_on_spree_taxon_id", if_exists: true
      end
    else
      create_table :spree_taxon_translations do |t|
        # Translated attribute(s)
        t.string :name
        t.text :description

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

        t.timestamps null: false
      end

      add_index :spree_taxon_translations, :locale, name: :index_spree_taxon_translations_on_locale
    end

    add_index :spree_taxon_translations, [:spree_taxon_id, :locale], name: :index_spree_taxon_translations_on_spree_taxon_id_and_locale, unique: true
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spree_core-4.10.1 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.10.0 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.9.0 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.8.3 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.8.2 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.7.3 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.6 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.5 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.7.2 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.7.1 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.4 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.7.0 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.3 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.2 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.1 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb
spree_core-4.6.0 db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb