svenfuchs/globalize3 — Issue #85: migrate data with table name different from the model
Author: ck3g
Created: 2011-12-04 17:01:10+00:00
State: open

Greetings. I've got some legacy code. Now I try to migrate existed data from model to translations table.
I have following model:

class NewsItem < ActiveRecord::Base
translates :title, :content
set_table_name "news"
end

How I write migration:

NewsItem.create_translation_table!({}, { :migrate_data => true })

Then I running migration I've get following error:

== CreateGlobalize3Tables: migrating ====================================
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Unknown column 'news_item_translations.news_item_id' in 'where clause': SELECT `news_item_translations`.* FROM `news_item_translations` WHERE (`news_item_translations`.news_item_id = 2)

The table was created with name `news_item_translations`

mysql> describe news_item_translations;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| news_id | int(11) | YES | | NULL | |
| locale | varchar(255) | YES | | NULL | |

with field **news_id**