Merge pull request #7480 from betagouv/US/fix-migration

fix(AddColumnClosedToGroupeInstructeurs): add column with change_column_default
This commit is contained in:
mfo 2022-06-21 18:50:09 +02:00 committed by GitHub
commit cec0aa2aa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View file

@ -1,5 +1,6 @@
class AddColumnClosedToGroupeInstructeurs < ActiveRecord::Migration[6.1] class AddColumnClosedToGroupeInstructeurs < ActiveRecord::Migration[6.1]
def change def change
add_column :groupe_instructeurs, :closed, :boolean, default: false add_column :groupe_instructeurs, :closed, :boolean
change_column_default :groupe_instructeurs, :closed, false
end end
end end

View file

@ -0,0 +1,8 @@
class BackfillAddColumnClosedToGroupeInstructeurs < ActiveRecord::Migration[6.1]
def up
GroupeInstructeur.in_batches do |relation|
relation.update_all closed: false
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. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_06_20_141238) do ActiveRecord::Schema.define(version: 2022_06_21_160241) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto" enable_extension "pgcrypto"