diff --git a/db/docs/draft_notes.yml b/db/docs/draft_notes.yml index d37a8192b8826b0e0cf8c2e534c1b1da6d3027b5..1fe47721d2d7d530d6ef3b6aa7cb951b50a25799 100644 --- a/db/docs/draft_notes.yml +++ b/db/docs/draft_notes.yml @@ -8,14 +8,6 @@ description: Notes created during the review of an MR that are not yet published introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/4213 milestone: '11.4' gitlab_schema: gitlab_main_cell -desired_sharding_key: - project_id: - references: projects - backfill_via: - parent: - foreign_key: merge_request_id - table: merge_requests - sharding_key: target_project_id - belongs_to: merge_request -desired_sharding_key_migration_job_name: BackfillDraftNotesProjectId table_size: small +sharding_key: + project_id: projects diff --git a/db/post_migrate/20250210065034_validate_draft_notes_project_id_not_null_constraint.rb b/db/post_migrate/20250210065034_validate_draft_notes_project_id_not_null_constraint.rb new file mode 100644 index 0000000000000000000000000000000000000000..5799aeecd3dfa5347aeabc12f1297314dd151ac7 --- /dev/null +++ b/db/post_migrate/20250210065034_validate_draft_notes_project_id_not_null_constraint.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ValidateDraftNotesProjectIdNotNullConstraint < Gitlab::Database::Migration[2.2] + milestone '17.10' + + def up + validate_not_null_constraint :draft_notes, :project_id + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20250210065034 b/db/schema_migrations/20250210065034 new file mode 100644 index 0000000000000000000000000000000000000000..301d194c152ad9a5618756d61b2fdbc0c1d01cd0 --- /dev/null +++ b/db/schema_migrations/20250210065034 @@ -0,0 +1 @@ +17898021bbd8b5bdef675c73e0aef30a77b0cbbeb6348b89e75f2b4837ec58b4 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 1f4e531e85bc1f04c53c259b93be943d68390857..5b6ce385a002759f62f4092d3c2305ac680a9323 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -13115,6 +13115,7 @@ CREATE TABLE draft_notes ( internal boolean DEFAULT false NOT NULL, note_type smallint, project_id bigint, + CONSTRAINT check_2a752d05fe CHECK ((project_id IS NOT NULL)), CONSTRAINT check_c497a94a0e CHECK ((char_length(line_code) <= 255)) ); @@ -27269,9 +27270,6 @@ ALTER TABLE ONLY chat_names ALTER TABLE ONLY chat_teams ADD CONSTRAINT chat_teams_pkey PRIMARY KEY (id); -ALTER TABLE draft_notes - ADD CONSTRAINT check_2a752d05fe CHECK ((project_id IS NOT NULL)) NOT VALID; - ALTER TABLE workspaces ADD CONSTRAINT check_2a89035b04 CHECK ((personal_access_token_id IS NOT NULL)) NOT VALID;