From 7e670d2bd7cfd57564b71ddb7c36d88301a26190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarka=20Ko=C5=A1anov=C3=A1?= Date: Wed, 24 Sep 2025 14:17:04 +0200 Subject: [PATCH 1/2] Remove default for organization_id --- ...efault_from_abuse_report_assignees_organization_id.rb | 9 +++++++++ db/schema_migrations/20250924121403 | 1 + db/structure.sql | 5 +++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20250924121403_remove_default_from_abuse_report_assignees_organization_id.rb create mode 100644 db/schema_migrations/20250924121403 diff --git a/db/migrate/20250924121403_remove_default_from_abuse_report_assignees_organization_id.rb b/db/migrate/20250924121403_remove_default_from_abuse_report_assignees_organization_id.rb new file mode 100644 index 00000000000000..73a2c7b76ef57e --- /dev/null +++ b/db/migrate/20250924121403_remove_default_from_abuse_report_assignees_organization_id.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveDefaultFromAbuseReportAssigneesOrganizationId < Gitlab::Database::Migration[2.3] + milestone '18.5' + + def change + change_column_default(:abuse_report_assignees, :organization_id, from: 1, to: nil) + end +end diff --git a/db/schema_migrations/20250924121403 b/db/schema_migrations/20250924121403 new file mode 100644 index 00000000000000..5fad6b8706f6fb --- /dev/null +++ b/db/schema_migrations/20250924121403 @@ -0,0 +1 @@ +2a086dc954b59b5dc5b1ad0a4894882c52d726ac8a5bb1c446a7085dd080c7cd \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index c4c3875155a13d..9b7daaf36a87c3 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9309,7 +9309,7 @@ CREATE TABLE abuse_report_assignees ( abuse_report_id bigint NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, - organization_id bigint DEFAULT 1 NOT NULL + organization_id bigint NOT NULL ); CREATE SEQUENCE abuse_report_assignees_id_seq @@ -9505,7 +9505,8 @@ CREATE TABLE abuse_reports ( CONSTRAINT abuse_reports_links_to_spam_length_check CHECK ((cardinality(links_to_spam) <= 20)), CONSTRAINT check_4b0a5120e0 CHECK ((char_length(screenshot) <= 255)), CONSTRAINT check_ab1260fa6c CHECK ((char_length(reported_from_url) <= 512)), - CONSTRAINT check_f3c0947a2d CHECK ((char_length(mitigation_steps) <= 1000)) + CONSTRAINT check_f3c0947a2d CHECK ((char_length(mitigation_steps) <= 1000)), + CONSTRAINT check_fc643d4880 CHECK ((reporter_id IS NOT NULL)) ); CREATE SEQUENCE abuse_reports_id_seq -- GitLab From e2720e7e887ca716b76d3f53cf91e4b73ff07593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarka=20Ko=C5=A1anov=C3=A1?= Date: Wed, 24 Sep 2025 14:17:25 +0200 Subject: [PATCH 2/2] Set sharding key for abuse_report_assignees --- db/docs/abuse_report_assignees.yml | 5 +++-- db/structure.sql | 3 +-- spec/lib/gitlab/database/sharding_key_spec.rb | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/db/docs/abuse_report_assignees.yml b/db/docs/abuse_report_assignees.yml index 863609a0cae933..2b887ab05057fc 100644 --- a/db/docs/abuse_report_assignees.yml +++ b/db/docs/abuse_report_assignees.yml @@ -7,6 +7,7 @@ feature_categories: description: Stores information linking abuse reports and users (assignee) introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/134240 milestone: '16.7' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_org +sharding_key: + organization_id: organizations table_size: small -sharding_key_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/553428 diff --git a/db/structure.sql b/db/structure.sql index 9b7daaf36a87c3..4bc4977e4961e1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9505,8 +9505,7 @@ CREATE TABLE abuse_reports ( CONSTRAINT abuse_reports_links_to_spam_length_check CHECK ((cardinality(links_to_spam) <= 20)), CONSTRAINT check_4b0a5120e0 CHECK ((char_length(screenshot) <= 255)), CONSTRAINT check_ab1260fa6c CHECK ((char_length(reported_from_url) <= 512)), - CONSTRAINT check_f3c0947a2d CHECK ((char_length(mitigation_steps) <= 1000)), - CONSTRAINT check_fc643d4880 CHECK ((reporter_id IS NOT NULL)) + CONSTRAINT check_f3c0947a2d CHECK ((char_length(mitigation_steps) <= 1000)) ); CREATE SEQUENCE abuse_reports_id_seq diff --git a/spec/lib/gitlab/database/sharding_key_spec.rb b/spec/lib/gitlab/database/sharding_key_spec.rb index f3da05caf6af29..0230c702506218 100644 --- a/spec/lib/gitlab/database/sharding_key_spec.rb +++ b/spec/lib/gitlab/database/sharding_key_spec.rb @@ -318,7 +318,6 @@ "abuse_report_labels" => "https://gitlab.com/gitlab-org/gitlab/-/issues/553427", "abuse_report_events" => "https://gitlab.com/gitlab-org/gitlab/-/issues/553429", "abuse_events" => "https://gitlab.com/gitlab-org/gitlab/-/issues/553427", - "abuse_report_assignees" => "https://gitlab.com/gitlab-org/gitlab/-/issues/553428", "labels" => "https://gitlab.com/gitlab-org/gitlab/-/issues/563889", "notes" => "https://gitlab.com/gitlab-org/gitlab/-/issues/569521", "notes_archived" => "https://gitlab.com/gitlab-org/gitlab/-/issues/569521", -- GitLab