Skip to content

Instantly share code, notes, and snippets.

@ugisozols
Last active December 19, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ugisozols/5998256 to your computer and use it in GitHub Desktop.
Save ugisozols/5998256 to your computer and use it in GitHub Desktop.
Refinery CMS long index name fix when upgrading from 2.0.x to 2.1.x
class RemoveMetaKeywordsFromSeoMeta < ActiveRecord::Migration
def up
with_index_name_fix do
remove_column :seo_meta, :meta_keywords
end
end
def down
add_column :seo_meta, :meta_keywords, :string
end
def with_index_name_fix
if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite" &&
ActiveRecord::Base.connection.indexes('seo_meta').collect(&:name).include?("index_seo_meta_on_seo_meta_id_and_seo_meta_type")
remove_index :seo_meta, :seo_meta_id_and_seo_meta_type
yield
add_index :seo_meta, [:seo_meta_id, :seo_meta_type], :name => :id_type_index_on_seo_meta
else
yield
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment