Merge pull request #7133 from betagouv/US/fix-migration-add-reference

fix(migration): apply what strong migration recommends
This commit is contained in:
mfo 2022-04-07 10:33:52 +02:00 committed by GitHub
commit a545e01034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View file

@ -3,9 +3,8 @@ class AddProcedurePresentationAndStateToExports < ActiveRecord::Migration[6.1]
def change
add_reference :exports, :procedure_presentation, null: true, index: { algorithm: :concurrently }
StrongMigrations.disable_check(:add_column)
add_column :exports, :statut, :string, default: 'tous'
StrongMigrations.enable_check(:add_column)
add_column :exports, :statut, :string
change_column_default :exports, :statut, "tous"
remove_index :exports, [:format, :time_span_type, :key]
add_index :exports, [:format, :time_span_type, :statut, :key], unique: true, algorithm: :concurrently
end

View file

@ -0,0 +1,10 @@
class BackfillExportStatus < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
Export.in_batches do |relation|
relation.update_all statut: "tous"
sleep(0.01)
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_04_05_163206) do
ActiveRecord::Schema.define(version: 2022_04_07_081538) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"