Last active
December 19, 2015 18:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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