a4108c7787
Recent migrations used ActiveRecord when removing invalid data. This may break if the ActiveRecord model later changes. To ensure these migrations will run correctly, even when the code will have changed, let's use an SQL-based helper instead of ActiveRecord.
16 lines
560 B
Ruby
16 lines
560 B
Ruby
class AddForeignKeysToAdministrateursInstructeurs < ActiveRecord::Migration[6.1]
|
|
include Database::MigrationHelpers
|
|
|
|
def up
|
|
delete_orphans :administrateurs_instructeurs, :administrateurs
|
|
add_foreign_key :administrateurs_instructeurs, :administrateurs
|
|
|
|
delete_orphans :administrateurs_instructeurs, :instructeurs
|
|
add_foreign_key :administrateurs_instructeurs, :instructeurs
|
|
end
|
|
|
|
def down
|
|
remove_foreign_key :administrateurs_instructeurs, :administrateurs
|
|
remove_foreign_key :administrateurs_instructeurs, :instructeurs
|
|
end
|
|
end
|