fix(migration): apply what strong migration recommends

This commit is contained in:
Martin 2022-04-07 10:18:12 +02:00
parent 59cddcbfe6
commit f84c7ac5e4
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"