Archer
Archer

Reputation: 1124

Rails: rename globalize column

The rails globalize gem docs are great, but I can't find a solution, what I have to do, when I want to rename a column.

Last Year I did that, to add the translation fields.

  def up
    remove_column :news, :name
    News.add_translation_fields! name: :string
  end

  def down
    add_column :news, :name, :string, default: nil
    remove_column :news_translations, :name
  end

Now I want to rename the column "name" to "title", without loosing my data and translations. How do I have to write the migration file?

Upvotes: 2

Views: 421

Answers (1)

rebagliatte
rebagliatte

Reputation: 2146

Alter the column on the news translations table directly:

def change
  rename_column :news_translations, :name, :title
end

Upvotes: 2

Related Questions