Don't audit Globalize data migrations

There's a conflict between the data migrations Globalize uses and the
audited configuration. Since Globalize uses the model to run the
migrations, it might try to run code that wasn't available when the
migration was created.

In this case, when migrating data it tries to audit the translations
table for budget investments. However, the migration creating the table
for audits hasn't been run at this point, since it was added after the
migration to add translations to investments was.

On the other hand, this data migration isn't really a change in the
model attibutes, so it shouldn't be audited anyway.

So we're disabling auditing during the migration in order to avoid these
issues.
This commit is contained in:
Javi Martín
2020-01-18 13:59:02 +01:00
parent a5105b93f1
commit 3b2d4820cc

View File

@@ -1,5 +1,6 @@
class AddBudgetInvestmentTranslations < ActiveRecord::Migration[4.2]
def self.up
Budget::Investment::Translation.without_auditing do
Budget::Investment.create_translation_table!(
{
title: :string,
@@ -8,6 +9,7 @@ class AddBudgetInvestmentTranslations < ActiveRecord::Migration[4.2]
{ migrate_data: true }
)
end
end
def self.down
Budget::Investment.drop_translation_table!