Skip to content
Snippets Groups Projects
Unverified Commit 7b6dc073 authored by Keeyan Nejad's avatar Keeyan Nejad Committed by GitLab
Browse files

Create multi not null constraint for exports

Prevent group and project ID from both being null.

Required as part of the sharding work for cells.

Changelog: performance
parent 63c505c9
No related branches found
No related tags found
No related merge requests found
# frozen_string_literal: true
class AddMultiNotNullConstraintToBulkImportExports < Gitlab::Database::Migration[2.2]
milestone '17.6'
disable_ddl_transaction!
def up
add_multi_column_not_null_constraint(:bulk_import_exports, :group_id, :project_id)
end
def down
remove_multi_column_not_null_constraint(:bulk_import_exports, :group_id, :project_id)
end
end
6560d591cabfeda2a813ef521492af968e282c7d329b8cd9769ac9607fa32c4b
\ No newline at end of file
Loading
Loading
@@ -7983,7 +7983,8 @@ CREATE TABLE bulk_import_exports (
user_id bigint,
CONSTRAINT check_24cb010672 CHECK ((char_length(relation) <= 255)),
CONSTRAINT check_8f0f357334 CHECK ((char_length(error) <= 255)),
CONSTRAINT check_9ee6d14d33 CHECK ((char_length(jid) <= 255))
CONSTRAINT check_9ee6d14d33 CHECK ((char_length(jid) <= 255)),
CONSTRAINT check_e84b7c0730 CHECK ((num_nonnulls(group_id, project_id) = 1))
);
 
CREATE SEQUENCE bulk_import_exports_id_seq
Loading
Loading
@@ -2,7 +2,7 @@
 
FactoryBot.define do
factory :bulk_import_export, class: 'BulkImports::Export', traits: %i[started] do
group
group { association(:group) if project.nil? }
relation { 'labels' }
 
trait :started do
Loading
Loading
Loading
Loading
@@ -27,7 +27,6 @@
'analytics_devops_adoption_segments.namespace_id',
*['badges.project_id', 'badges.group_id'],
*['boards.project_id', 'boards.group_id'],
*['bulk_import_exports.project_id', 'bulk_import_exports.group_id'],
'ci_pipeline_schedules.project_id',
'ci_sources_pipelines.project_id',
'ci_triggers.project_id',
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment