diff --git a/db/migrate/20220725090224_add_etablissement_infos_to_services.rb b/db/migrate/20220725090224_add_etablissement_infos_to_services.rb index 90c6b26a0..21534c008 100644 --- a/db/migrate/20220725090224_add_etablissement_infos_to_services.rb +++ b/db/migrate/20220725090224_add_etablissement_infos_to_services.rb @@ -1,7 +1,14 @@ class AddEtablissementInfosToServices < ActiveRecord::Migration[6.1] - def change - add_column :services, :etablissement_infos, :jsonb, default: {} + def up + add_column :services, :etablissement_infos, :jsonb add_column :services, :etablissement_lat, :decimal, precision: 10, scale: 6 add_column :services, :etablissement_lng, :decimal, precision: 10, scale: 6 + change_column_default :services, :etablissement_infos, {} + end + + def down + remove_column :services, :etablissement_infos + remove_column :services, :etablissement_lat + remove_column :services, :etablissement_lng end end diff --git a/db/migrate/20220725090225_backfill_add_etablissement_infos_to_services.rb b/db/migrate/20220725090225_backfill_add_etablissement_infos_to_services.rb new file mode 100644 index 000000000..f5f5a1eb2 --- /dev/null +++ b/db/migrate/20220725090225_backfill_add_etablissement_infos_to_services.rb @@ -0,0 +1,10 @@ +class BackfillAddEtablissementInfosToServices < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def up + Service.unscoped.in_batches do |relation| # rubocop:disable DS/Unscoped + relation.update_all etablissement_infos: {} + sleep(0.01) + end + end +end