chore(schema): fixup failed migrations, ensure exports->instructeurs foreign key exists
This commit is contained in:
parent
dd3805b7cd
commit
b11495a7a6
5 changed files with 18 additions and 8 deletions
|
@ -2,6 +2,7 @@ class AddGroupeGestionnaireToAdministrateurs < ActiveRecord::Migration[7.0]
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_reference :administrateurs, :groupe_gestionnaire, index: { algorithm: :concurrently }, null: true
|
# Foreign key is added in a later migration
|
||||||
|
add_reference :administrateurs, :groupe_gestionnaire, index: { algorithm: :concurrently }, null: true, foreign_key: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class AddContextToExports < ActiveRecord::Migration[7.0]
|
class AddDossiersCountToExports < ActiveRecord::Migration[7.0]
|
||||||
disable_ddl_transaction!
|
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :exports, :dossiers_count, :integer, null: true, default: nil
|
add_column :exports, :dossiers_count, :integer, null: true, default: nil
|
||||||
end
|
end
|
|
@ -1,8 +1,8 @@
|
||||||
class AddReferenceToExportsInstructeur < ActiveRecord::Migration[7.0]
|
class AddReferenceToExportsInstructeur < ActiveRecord::Migration[7.0]
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def change
|
def change
|
||||||
safety_assured do
|
# Foreign key is added in a later migration
|
||||||
add_reference :exports, :instructeur, foreign_key: true, null: true, default: nil, index: { algorithm: :concurrently }
|
add_reference :exports, :instructeur, null: true, default: nil, index: { algorithm: :concurrently }, foreign_key: false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class AddInstructeurForeignKeyToExports < ActiveRecord::Migration[7.0]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
# Foreign keys were already added on developer machines, but timeouted in production.
|
||||||
|
if !foreign_key_exists?(:exports, :instructeurs)
|
||||||
|
add_foreign_key :exports, :instructeurs, validate: false
|
||||||
|
validate_foreign_key :exports, :instructeurs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -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[7.0].define(version: 2023_10_09_143331) do
|
ActiveRecord::Schema[7.0].define(version: 2023_10_10_083144) 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"
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
Loading…
Reference in a new issue