[Backport] Migrate globalize data #2986
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Background
We forgot to migrate existing data when we created the translations tables, and so when we edit translatable fields in the administration, they seem to be empty, increasing the risk of data loss.
Objectives
Migrate existing data to the translation tables (unless we've already translated those records!) so contents show up when administrators edit contents.
Notes
In order to migrate existing data, execute:
bin/rake globalize:migrate_data RAILS_ENV=production
Although we believe it's completely safe to run this task, we recommend backing up the database before executing any task which modifies its data.
This task will not migrate records which contain invalid data (for example, a banner with a blank title), which might happen if the database content has been edited manually by system administrators. You can check which records aren't migrated by checking the warnings generated by executing:
bin/rake globalize:simulate_migrate_data RAILS_ENV=production
Most of the time no records contain invalid data and the task will run without any warnings.
Globalize developers recommend removing the original columns after migrating the data, since having both original and translated columns is not supported. We might add another task dealing with this issue.