From 37747b01732afb072a918d8cd9767e146455c19b Mon Sep 17 00:00:00 2001 From: Nasser Zahrani Date: Wed, 23 Jul 2025 20:22:15 -0400 Subject: [PATCH] Not Null constraint on namespace ID for design_management_repository_states table --- ...states_namespace_id_not_null_constraint.rb | 17 +++++++++++ db/schema_migrations/20250724001730 | 1 + db/structure.sql | 29 ++++++++++++------- 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 db/post_migrate/20250724001730_add_design_management_repository_states_namespace_id_not_null_constraint.rb create mode 100644 db/schema_migrations/20250724001730 diff --git a/db/post_migrate/20250724001730_add_design_management_repository_states_namespace_id_not_null_constraint.rb b/db/post_migrate/20250724001730_add_design_management_repository_states_namespace_id_not_null_constraint.rb new file mode 100644 index 00000000000000..446377817ec08e --- /dev/null +++ b/db/post_migrate/20250724001730_add_design_management_repository_states_namespace_id_not_null_constraint.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddDesignManagementRepositoryStatesNamespaceIdNotNullConstraint < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + milestone '18.3' + + def up + add_not_null_constraint :design_management_repository_states, :namespace_id + end + + def down + remove_not_null_constraint :design_management_repository_states, :namespace_id + end +end diff --git a/db/schema_migrations/20250724001730 b/db/schema_migrations/20250724001730 new file mode 100644 index 00000000000000..bdab6b64d96b2a --- /dev/null +++ b/db/schema_migrations/20250724001730 @@ -0,0 +1 @@ +1c759e781a1c22e87a40b33ea6b33fd78e48aa447c57b9880b750c1e1cd51ad4 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index a5489c76e50f51..4b437b9ff72c7e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -5108,7 +5108,7 @@ PARTITION BY LIST (partition_id); CREATE TABLE p_ci_finished_build_ch_sync_events ( build_id bigint NOT NULL, - partition bigint DEFAULT 1 NOT NULL, + partition bigint DEFAULT 2 NOT NULL, build_finished_at timestamp without time zone NOT NULL, processed boolean DEFAULT false NOT NULL, project_id bigint NOT NULL @@ -5118,7 +5118,7 @@ PARTITION BY LIST (partition); CREATE TABLE p_ci_finished_pipeline_ch_sync_events ( pipeline_id bigint NOT NULL, project_namespace_id bigint NOT NULL, - partition bigint DEFAULT 1 NOT NULL, + partition bigint DEFAULT 2 NOT NULL, pipeline_finished_at timestamp without time zone NOT NULL, processed boolean DEFAULT false NOT NULL ) @@ -9624,16 +9624,16 @@ CREATE TABLE application_settings ( database_reindexing jsonb DEFAULT '{}'::jsonb NOT NULL, duo_chat jsonb DEFAULT '{}'::jsonb NOT NULL, group_settings jsonb DEFAULT '{}'::jsonb NOT NULL, + web_based_commit_signing_enabled boolean DEFAULT false NOT NULL, + lock_web_based_commit_signing_enabled boolean DEFAULT false NOT NULL, model_prompt_cache_enabled boolean DEFAULT true NOT NULL, lock_model_prompt_cache_enabled boolean DEFAULT false NOT NULL, response_limits jsonb DEFAULT '{}'::jsonb NOT NULL, - web_based_commit_signing_enabled boolean DEFAULT false NOT NULL, - lock_web_based_commit_signing_enabled boolean DEFAULT false NOT NULL, tmp_asset_proxy_secret_key jsonb, editor_extensions jsonb DEFAULT '{}'::jsonb NOT NULL, security_and_compliance_settings jsonb DEFAULT '{}'::jsonb NOT NULL, - sdrs_url text, default_profile_preferences jsonb DEFAULT '{}'::jsonb NOT NULL, + sdrs_url text, sdrs_enabled boolean DEFAULT false NOT NULL, sdrs_jwt_signing_key jsonb, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), @@ -9666,6 +9666,7 @@ CREATE TABLE application_settings ( CONSTRAINT check_4f8b811780 CHECK ((char_length(sentry_dsn) <= 255)), CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)), CONSTRAINT check_5688c70478 CHECK ((char_length(error_tracking_access_token_encrypted) <= 255)), + CONSTRAINT check_56fb3d74a1 CHECK ((char_length(sdrs_url) <= 255)), CONSTRAINT check_57123c9593 CHECK ((char_length(help_page_documentation_base_url) <= 255)), CONSTRAINT check_5a84c3ffdc CHECK ((char_length(content_validation_endpoint_url) <= 255)), CONSTRAINT check_5bcba483c4 CHECK ((char_length(sentry_environment) <= 255)), @@ -9677,7 +9678,6 @@ CREATE TABLE application_settings ( CONSTRAINT check_85a39b68ff CHECK ((char_length(encrypted_ci_jwt_signing_key_iv) <= 255)), CONSTRAINT check_8dca35398a CHECK ((char_length(public_runner_releases_url) <= 255)), CONSTRAINT check_8e7df605a1 CHECK ((char_length(cube_api_base_url) <= 512)), - CONSTRAINT check_9a42a7cfdd CHECK ((char_length(sdrs_url) <= 255)), CONSTRAINT check_9a719834eb CHECK ((char_length(secret_detection_token_revocation_url) <= 255)), CONSTRAINT check_9c6c447a13 CHECK ((char_length(maintenance_mode_message) <= 255)), CONSTRAINT check_a5704163cc CHECK ((char_length(secret_detection_revocation_token_types_url) <= 255)), @@ -10889,7 +10889,7 @@ CREATE TABLE boards ( project_id bigint, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, - name character varying DEFAULT 'Development'::character varying NOT NULL, + name character varying(255) DEFAULT 'Development'::character varying NOT NULL, milestone_id bigint, group_id bigint, weight integer, @@ -18546,11 +18546,11 @@ CREATE TABLE namespace_settings ( job_token_policies_enabled boolean DEFAULT false NOT NULL, security_policies jsonb DEFAULT '{}'::jsonb NOT NULL, duo_nano_features_enabled boolean, + web_based_commit_signing_enabled boolean, + lock_web_based_commit_signing_enabled boolean DEFAULT false NOT NULL, model_prompt_cache_enabled boolean, lock_model_prompt_cache_enabled boolean DEFAULT false NOT NULL, disable_invite_members boolean DEFAULT false NOT NULL, - web_based_commit_signing_enabled boolean, - lock_web_based_commit_signing_enabled boolean DEFAULT false NOT NULL, allow_enterprise_bypass_placeholder_confirmation boolean DEFAULT false NOT NULL, enterprise_bypass_expires_at timestamp with time zone, CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)), @@ -30016,6 +30016,9 @@ ALTER TABLE ONLY chat_names ALTER TABLE ONLY chat_teams ADD CONSTRAINT chat_teams_pkey PRIMARY KEY (id); +ALTER TABLE epic_issues + ADD CONSTRAINT check_048dce81f3 CHECK ((work_item_parent_link_id IS NOT NULL)) NOT VALID; + ALTER TABLE workspaces ADD CONSTRAINT check_2a89035b04 CHECK ((personal_access_token_id IS NOT NULL)) NOT VALID; @@ -30040,6 +30043,9 @@ ALTER TABLE oauth_applications ALTER TABLE ONLY group_type_ci_runners ADD CONSTRAINT check_81b90172a6 UNIQUE (id); +ALTER TABLE related_epic_links + ADD CONSTRAINT check_a6d9d7c276 CHECK ((issue_link_id IS NOT NULL)) NOT VALID; + ALTER TABLE p_ci_job_artifacts ADD CONSTRAINT check_b8fac815e7 CHECK ((char_length(exposed_as) <= 100)) NOT VALID; @@ -30055,6 +30061,9 @@ ALTER TABLE packages_packages ALTER TABLE sprints ADD CONSTRAINT check_df3816aed7 CHECK ((due_date IS NOT NULL)) NOT VALID; +ALTER TABLE epics + ADD CONSTRAINT check_fe5092debd CHECK ((work_item_parent_link_id IS NOT NULL)) NOT VALID; + ALTER TABLE instance_type_ci_runners ADD CONSTRAINT check_organization_id_nullness CHECK ((organization_id IS NULL)) NOT VALID; @@ -43420,7 +43429,7 @@ ALTER TABLE ONLY operations_scopes ADD CONSTRAINT fk_4913f5d6a2 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ALTER TABLE ONLY merge_requests_compliance_violations - ADD CONSTRAINT fk_492a40969e FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE; + ADD CONSTRAINT fk_492a40969e FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE NOT VALID; ALTER TABLE ONLY workspace_variables ADD CONSTRAINT fk_494e093520 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -- GitLab