Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Migrate globalize data #2986

Merged
merged 7 commits into from
Oct 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Log failed data migrations
In theory, it should never happen, but that's why exceptions exist.
  • Loading branch information
javierm committed Oct 23, 2018
commit 3c48059f07c78dbdca69ef2ecea784210af6a17c
11 changes: 9 additions & 2 deletions lib/tasks/globalize.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace :globalize do
desc "Migrates existing data to translation tables"
task migrate_data: :environment do
logger = Logger.new(STDOUT)
logger.formatter = proc { |severity, _datetime, _progname, msg| "#{severity} #{msg}\n" }

[
AdminNotification,
Banner,
Expand All @@ -16,7 +19,7 @@ namespace :globalize do
SiteCustomization::Page,
Widget::Card
].each do |model_class|
Logger.new(STDOUT).info "Migrating #{model_class} data"
logger.info "Migrating #{model_class} data"

fields = model_class.translated_attribute_names

Expand All @@ -33,7 +36,11 @@ namespace :globalize do
end
end

record.save!
begin
record.save!
rescue ActiveRecord::RecordInvalid
logger.error "Failed to save #{model_class} with id #{record.id}"
end
end
end
end
Expand Down