Sha256: 59bab7674f846756bf6efea85a8b59536bdee4343f7383dbe92fa71c7dfbe988

Contents?: true

Size: 1.77 KB

Versions: 3

Compression:

Stored size: 1.77 KB

Contents

# This migration comes from alchemy (originally 20180227224537)
class MigrateTagsToGutentag < ActiveRecord::Migration[5.0]
  def change
    remove_index :taggings, :taggable_id
    remove_column :taggings, :tagger_id, :integer
    remove_index :taggings, :taggable_type
    remove_column :taggings, :tagger_type, :string
    remove_index :taggings, column: [:taggable_id, :taggable_type, :context], name: 'index_taggings_on_taggable_id_and_taggable_type_and_context'
    remove_column :taggings, :context, :string, limit: 128
    if index_exists? :taggings, [:tag_id, :taggable_id, :taggable_type], unique: true, name: 'taggings_idx'
      rename_index :taggings, 'taggings_idx', 'unique_taggings'
    else
      add_index :taggings, [:taggable_type, :taggable_id, :tag_id], unique: true, name: 'unique_taggings'
    end
    if index_exists? :taggings, [:taggable_id, :taggable_type], name: 'taggings_idy'
      rename_index :taggings, 'taggings_idy', 'index_gutentag_taggings_on_taggable_id_and_taggable_type'
    else
      add_index :taggings, [:taggable_type, :taggable_id]
    end
    add_column :taggings, :updated_at, :datetime
    change_column_null :taggings, :tag_id, false
    change_column_null :taggings, :taggable_id, false
    change_column_null :taggings, :taggable_type, false
    change_column_null :taggings, :created_at, false, Time.current
    change_column_null :taggings, :updated_at, false, Time.current
    rename_table :taggings, :gutentag_taggings

    change_column_null :tags, :name, false
    add_index :tags, :taggings_count
    rename_table :tags, :gutentag_tags

    %i(alchemy_attachments alchemy_elements alchemy_pages alchemy_pictures).each do |table|
      if column_exists? table, :cached_tag_list
        remove_column table, :cached_tag_list
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alchemy-devise-4.2.0 spec/dummy/db/migrate/20180301103350_migrate_tags_to_gutentag.alchemy.rb
alchemy-devise-4.1.0 spec/dummy/db/migrate/20180301103350_migrate_tags_to_gutentag.alchemy.rb
alchemy-devise-4.1.0.beta spec/dummy/db/migrate/20180301103350_migrate_tags_to_gutentag.alchemy.rb