diff options
Diffstat (limited to 'db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb')
-rw-r--r-- | db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb b/db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb new file mode 100644 index 00000000000..0d625a54656 --- /dev/null +++ b/db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddFkOnMlCandidatesToMlModelVersions < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key(:ml_candidates, :ml_model_versions, column: :model_version_id, on_delete: :cascade) + end + + def down + with_lock_retries do + remove_foreign_key_if_exists(:ml_model_versions, column: :model_version_id, on_delete: :cascade) + end + end +end |