diff options
Diffstat (limited to 'db/post_migrate/20230608101503_add_ci_job_annotations_foreign_key.rb')
-rw-r--r-- | db/post_migrate/20230608101503_add_ci_job_annotations_foreign_key.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/db/post_migrate/20230608101503_add_ci_job_annotations_foreign_key.rb b/db/post_migrate/20230608101503_add_ci_job_annotations_foreign_key.rb new file mode 100644 index 00000000000..b4548ed8c28 --- /dev/null +++ b/db/post_migrate/20230608101503_add_ci_job_annotations_foreign_key.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddCiJobAnnotationsForeignKey < Gitlab::Database::Migration[2.1] + include Gitlab::Database::PartitioningMigrationHelpers + + disable_ddl_transaction! + + def up + add_concurrent_partitioned_foreign_key( + :p_ci_job_annotations, :p_ci_builds, + column: [:partition_id, :job_id], + target_column: [:partition_id, :id], + on_update: :cascade, + on_delete: :cascade, + reverse_lock_order: true + ) + end + + def down + remove_foreign_key_if_exists :p_ci_job_annotations, :p_ci_builds + end +end |