diff --git a/db/docs/duo_workflows_checkpoint_writes.yml b/db/docs/duo_workflows_checkpoint_writes.yml index 91ec65274ff..1b92f7823b5 100644 --- a/db/docs/duo_workflows_checkpoint_writes.yml +++ b/db/docs/duo_workflows_checkpoint_writes.yml @@ -10,4 +10,5 @@ milestone: '17.9' gitlab_schema: gitlab_main_cell sharding_key: project_id: projects + namespace_id: namespaces table_size: small diff --git a/db/docs/duo_workflows_checkpoints.yml b/db/docs/duo_workflows_checkpoints.yml index b060989fc2f..19e94354204 100644 --- a/db/docs/duo_workflows_checkpoints.yml +++ b/db/docs/duo_workflows_checkpoints.yml @@ -10,4 +10,5 @@ milestone: '17.2' gitlab_schema: gitlab_main_cell sharding_key: project_id: projects + namespace_id: namespaces table_size: medium diff --git a/db/docs/duo_workflows_events.yml b/db/docs/duo_workflows_events.yml index a12fcb39e7b..0afc43755ab 100644 --- a/db/docs/duo_workflows_events.yml +++ b/db/docs/duo_workflows_events.yml @@ -10,4 +10,5 @@ milestone: '17.5' gitlab_schema: gitlab_main_cell sharding_key: project_id: projects + namespace_id: namespaces table_size: small diff --git a/db/docs/duo_workflows_workflows.yml b/db/docs/duo_workflows_workflows.yml index 70640bcd137..72087e4f23a 100644 --- a/db/docs/duo_workflows_workflows.yml +++ b/db/docs/duo_workflows_workflows.yml @@ -10,4 +10,5 @@ milestone: '17.2' gitlab_schema: gitlab_main_cell sharding_key: project_id: projects + namespace_id: namespaces table_size: small diff --git a/db/migrate/20250618010101_add_project_or_namespace_constraint_to_duo_workflows_workflows.rb b/db/migrate/20250618010101_add_project_or_namespace_constraint_to_duo_workflows_workflows.rb new file mode 100644 index 00000000000..40fb0707bf6 --- /dev/null +++ b/db/migrate/20250618010101_add_project_or_namespace_constraint_to_duo_workflows_workflows.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddProjectOrNamespaceConstraintToDuoWorkflowsWorkflows < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + add_multi_column_not_null_constraint(:duo_workflows_workflows, :project_id, :namespace_id) + end + + def down + remove_multi_column_not_null_constraint(:duo_workflows_workflows, :project_id, :namespace_id) + end +end diff --git a/db/migrate/20250618010102_remove_not_null_constraint_from_duo_workflows_workflows_project_id.rb b/db/migrate/20250618010102_remove_not_null_constraint_from_duo_workflows_workflows_project_id.rb new file mode 100644 index 00000000000..58e867c5133 --- /dev/null +++ b/db/migrate/20250618010102_remove_not_null_constraint_from_duo_workflows_workflows_project_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveNotNullConstraintFromDuoWorkflowsWorkflowsProjectId < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + change_column_null :duo_workflows_workflows, :project_id, true + end + + def down + change_column_null :duo_workflows_workflows, :project_id, false + end +end diff --git a/db/migrate/20250618010103_cleanup_records_with_null_project_ids_from_duo_workflows_workflows.rb b/db/migrate/20250618010103_cleanup_records_with_null_project_ids_from_duo_workflows_workflows.rb new file mode 100644 index 00000000000..49819b24d35 --- /dev/null +++ b/db/migrate/20250618010103_cleanup_records_with_null_project_ids_from_duo_workflows_workflows.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class CleanupRecordsWithNullProjectIdsFromDuoWorkflowsWorkflows < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '18.2' + + BATCH_SIZE = 1000 + + class Workflow < MigrationRecord + include EachBatch + + self.table_name = 'duo_workflows_workflows' + end + + def up + # no-op - this migration is required to allow a rollback of + # `RemoveNotNullConstraintFromDuoWorkflowsWorkflowsProjectId` + end + + def down + Workflow.each_batch(of: BATCH_SIZE) do |relation| + relation + .where(project_id: nil) + .delete_all + end + end +end diff --git a/db/migrate/20250618010201_add_project_or_namespace_constraint_to_duo_workflows_checkpoints.rb b/db/migrate/20250618010201_add_project_or_namespace_constraint_to_duo_workflows_checkpoints.rb new file mode 100644 index 00000000000..5755ad61faf --- /dev/null +++ b/db/migrate/20250618010201_add_project_or_namespace_constraint_to_duo_workflows_checkpoints.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddProjectOrNamespaceConstraintToDuoWorkflowsCheckpoints < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + add_multi_column_not_null_constraint(:duo_workflows_checkpoints, :project_id, :namespace_id) + end + + def down + remove_multi_column_not_null_constraint(:duo_workflows_checkpoints, :project_id, :namespace_id) + end +end diff --git a/db/migrate/20250618010202_remove_not_null_constraint_from_duo_workflows_checkpoints_project_id.rb b/db/migrate/20250618010202_remove_not_null_constraint_from_duo_workflows_checkpoints_project_id.rb new file mode 100644 index 00000000000..5e7145caba5 --- /dev/null +++ b/db/migrate/20250618010202_remove_not_null_constraint_from_duo_workflows_checkpoints_project_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveNotNullConstraintFromDuoWorkflowsCheckpointsProjectId < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + change_column_null :duo_workflows_checkpoints, :project_id, true + end + + def down + change_column_null :duo_workflows_checkpoints, :project_id, false + end +end diff --git a/db/migrate/20250618010203_cleanup_records_with_null_project_ids_from_duo_workflows_checkpoints.rb b/db/migrate/20250618010203_cleanup_records_with_null_project_ids_from_duo_workflows_checkpoints.rb new file mode 100644 index 00000000000..68456c1e185 --- /dev/null +++ b/db/migrate/20250618010203_cleanup_records_with_null_project_ids_from_duo_workflows_checkpoints.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class CleanupRecordsWithNullProjectIdsFromDuoWorkflowsCheckpoints < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '18.2' + + BATCH_SIZE = 1000 + + class WorkflowCheckpoint < MigrationRecord + include EachBatch + + self.table_name = 'duo_workflows_checkpoints' + end + + def up + # no-op - this migration is required to allow a rollback of + # `AddProjectOrNamespaceConstraintToDuoWorkflowsCheckpoints` + end + + def down + WorkflowCheckpoint.each_batch(of: BATCH_SIZE) do |relation| + relation + .where(project_id: nil) + .delete_all + end + end +end diff --git a/db/migrate/20250618010301_add_project_or_namespace_constraint_to_duo_workflows_events.rb b/db/migrate/20250618010301_add_project_or_namespace_constraint_to_duo_workflows_events.rb new file mode 100644 index 00000000000..5fcddf8906f --- /dev/null +++ b/db/migrate/20250618010301_add_project_or_namespace_constraint_to_duo_workflows_events.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddProjectOrNamespaceConstraintToDuoWorkflowsEvents < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + add_multi_column_not_null_constraint(:duo_workflows_events, :project_id, :namespace_id) + end + + def down + remove_multi_column_not_null_constraint(:duo_workflows_events, :project_id, :namespace_id) + end +end diff --git a/db/migrate/20250618010302_remove_not_null_constraint_from_duo_workflows_events_project_id.rb b/db/migrate/20250618010302_remove_not_null_constraint_from_duo_workflows_events_project_id.rb new file mode 100644 index 00000000000..59047ccfd1e --- /dev/null +++ b/db/migrate/20250618010302_remove_not_null_constraint_from_duo_workflows_events_project_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveNotNullConstraintFromDuoWorkflowsEventsProjectId < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + change_column_null :duo_workflows_events, :project_id, true + end + + def down + change_column_null :duo_workflows_events, :project_id, false + end +end diff --git a/db/migrate/20250618010303_cleanup_records_with_null_project_ids_from_duo_workflows_events.rb b/db/migrate/20250618010303_cleanup_records_with_null_project_ids_from_duo_workflows_events.rb new file mode 100644 index 00000000000..2a37aece7a1 --- /dev/null +++ b/db/migrate/20250618010303_cleanup_records_with_null_project_ids_from_duo_workflows_events.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CleanupRecordsWithNullProjectIdsFromDuoWorkflowsEvents < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '18.2' + + BATCH_SIZE = 1000 + + class WorkflowEvent < MigrationRecord + include EachBatch + + self.table_name = 'duo_workflows_events' + end + + def up + # no-op - this migration is required to allow a rollback of `RemoveNotNullConstraintFromDuoWorkflowsEventsProjectId` + end + + def down + WorkflowEvent.each_batch(of: BATCH_SIZE) do |relation| + relation + .where(project_id: nil) + .delete_all + end + end +end diff --git a/db/migrate/20250618010401_add_project_or_namespace_constraint_to_duo_workflows_checkpoint_writes.rb b/db/migrate/20250618010401_add_project_or_namespace_constraint_to_duo_workflows_checkpoint_writes.rb new file mode 100644 index 00000000000..2bbb656c231 --- /dev/null +++ b/db/migrate/20250618010401_add_project_or_namespace_constraint_to_duo_workflows_checkpoint_writes.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddProjectOrNamespaceConstraintToDuoWorkflowsCheckpointWrites < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + add_multi_column_not_null_constraint(:duo_workflows_checkpoint_writes, :project_id, :namespace_id) + end + + def down + remove_multi_column_not_null_constraint(:duo_workflows_checkpoint_writes, :project_id, :namespace_id) + end +end diff --git a/db/migrate/20250618010402_remove_not_null_constraint_from_duo_workflows_checkpoint_writes_project_id.rb b/db/migrate/20250618010402_remove_not_null_constraint_from_duo_workflows_checkpoint_writes_project_id.rb new file mode 100644 index 00000000000..e75129c6a14 --- /dev/null +++ b/db/migrate/20250618010402_remove_not_null_constraint_from_duo_workflows_checkpoint_writes_project_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveNotNullConstraintFromDuoWorkflowsCheckpointWritesProjectId < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + milestone '18.2' + + def up + change_column_null :duo_workflows_checkpoint_writes, :project_id, true + end + + def down + change_column_null :duo_workflows_checkpoint_writes, :project_id, false + end +end diff --git a/db/migrate/20250618010403_cleanup_records_with_null_project_ids_from_duo_workflows_checkpoint_writes.rb b/db/migrate/20250618010403_cleanup_records_with_null_project_ids_from_duo_workflows_checkpoint_writes.rb new file mode 100644 index 00000000000..6227e99dee2 --- /dev/null +++ b/db/migrate/20250618010403_cleanup_records_with_null_project_ids_from_duo_workflows_checkpoint_writes.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class CleanupRecordsWithNullProjectIdsFromDuoWorkflowsCheckpointWrites < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '18.2' + + BATCH_SIZE = 1000 + + class WorkflowCheckPointWrite < MigrationRecord + include EachBatch + + self.table_name = 'duo_workflows_checkpoint_writes' + end + + def up + # no-op - this migration is required to allow a rollback of + # `RemoveNotNullConstraintFromDuoWorkflowsCheckpointWritesProjectId` + end + + def down + WorkflowCheckPointWrite.each_batch(of: BATCH_SIZE) do |relation| + relation + .where(project_id: nil) + .delete_all + end + end +end diff --git a/db/schema_migrations/20250618010101 b/db/schema_migrations/20250618010101 new file mode 100644 index 00000000000..bf5fa96c3a1 --- /dev/null +++ b/db/schema_migrations/20250618010101 @@ -0,0 +1 @@ +142099780029cd6becea865ffee8920a9ca03fa65090af567a530e37b8fa2d86 \ No newline at end of file diff --git a/db/schema_migrations/20250618010102 b/db/schema_migrations/20250618010102 new file mode 100644 index 00000000000..b014bc44140 --- /dev/null +++ b/db/schema_migrations/20250618010102 @@ -0,0 +1 @@ +4cc366bdfa4bb881cd5cb3ed1093e2022ffb8dc18d72428c31aec067a4b1e9d2 \ No newline at end of file diff --git a/db/schema_migrations/20250618010103 b/db/schema_migrations/20250618010103 new file mode 100644 index 00000000000..395fd977e40 --- /dev/null +++ b/db/schema_migrations/20250618010103 @@ -0,0 +1 @@ +b48fa652ec41ed3540e858275e6447863c17ccbb9c8caab2ff3ac138ef1819b0 \ No newline at end of file diff --git a/db/schema_migrations/20250618010201 b/db/schema_migrations/20250618010201 new file mode 100644 index 00000000000..226b3c51010 --- /dev/null +++ b/db/schema_migrations/20250618010201 @@ -0,0 +1 @@ +c064b787cf4ad31326c11817069ec54a7bdfbbb702521894a1274a82d65f009c \ No newline at end of file diff --git a/db/schema_migrations/20250618010202 b/db/schema_migrations/20250618010202 new file mode 100644 index 00000000000..a84b402b644 --- /dev/null +++ b/db/schema_migrations/20250618010202 @@ -0,0 +1 @@ +e3011cb75f7b533c3a1b09046857cb0ce81c37be396849cd74692a8e09547da9 \ No newline at end of file diff --git a/db/schema_migrations/20250618010203 b/db/schema_migrations/20250618010203 new file mode 100644 index 00000000000..ba605ffb407 --- /dev/null +++ b/db/schema_migrations/20250618010203 @@ -0,0 +1 @@ +f524b4d60b0bf69ccdb66104cb1a1cc57d1f22555d530b7c11e3f80cc410962b \ No newline at end of file diff --git a/db/schema_migrations/20250618010301 b/db/schema_migrations/20250618010301 new file mode 100644 index 00000000000..a0b56135336 --- /dev/null +++ b/db/schema_migrations/20250618010301 @@ -0,0 +1 @@ +03b23d923e3a43afd8c1f9fb2add645be48c16c9da76d5f7d6806e176d95637b \ No newline at end of file diff --git a/db/schema_migrations/20250618010302 b/db/schema_migrations/20250618010302 new file mode 100644 index 00000000000..fe03a9cf348 --- /dev/null +++ b/db/schema_migrations/20250618010302 @@ -0,0 +1 @@ +1ac2e8f3c3c3ccf33e6d66622ebca638f778d5b0dff2370106141d923889d410 \ No newline at end of file diff --git a/db/schema_migrations/20250618010303 b/db/schema_migrations/20250618010303 new file mode 100644 index 00000000000..df4c57a99b8 --- /dev/null +++ b/db/schema_migrations/20250618010303 @@ -0,0 +1 @@ +19fa463a438e6fb77d85577b24f1575f75aca16541655e9816437316076664aa \ No newline at end of file diff --git a/db/schema_migrations/20250618010401 b/db/schema_migrations/20250618010401 new file mode 100644 index 00000000000..5aec9e9bc05 --- /dev/null +++ b/db/schema_migrations/20250618010401 @@ -0,0 +1 @@ +bb3dfee2da2d7575f13a1929666eeb4784c0ebe1d7a37161576a1b10505fe5d2 \ No newline at end of file diff --git a/db/schema_migrations/20250618010402 b/db/schema_migrations/20250618010402 new file mode 100644 index 00000000000..ecad1eeeca0 --- /dev/null +++ b/db/schema_migrations/20250618010402 @@ -0,0 +1 @@ +c825a4b5ebf4b8a48d9b886ceb25e684b7240fdb2db339713e50c42df2636dc3 \ No newline at end of file diff --git a/db/schema_migrations/20250618010403 b/db/schema_migrations/20250618010403 new file mode 100644 index 00000000000..753035d24da --- /dev/null +++ b/db/schema_migrations/20250618010403 @@ -0,0 +1 @@ +06341854dd545f8a3fa161961e778c9d435e8c51c33a7afc2e19ac9a13021298 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 2d59cc88524..39396ebd584 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -14295,7 +14295,7 @@ ALTER SEQUENCE draft_notes_id_seq OWNED BY draft_notes.id; CREATE TABLE duo_workflows_checkpoint_writes ( id bigint NOT NULL, workflow_id bigint NOT NULL, - project_id bigint NOT NULL, + project_id bigint, idx integer NOT NULL, thread_ts text NOT NULL, task text NOT NULL, @@ -14304,6 +14304,7 @@ CREATE TABLE duo_workflows_checkpoint_writes ( data text NOT NULL, namespace_id bigint, CONSTRAINT check_38dc205bb2 CHECK ((char_length(data) <= 10000)), + CONSTRAINT check_3d119c06ee CHECK ((num_nonnulls(namespace_id, project_id) = 1)), CONSTRAINT check_c64af76670 CHECK ((char_length(write_type) <= 255)), CONSTRAINT check_d66d09c813 CHECK ((char_length(task) <= 255)), CONSTRAINT check_ddb83bc2d5 CHECK ((char_length(channel) <= 255)), @@ -14322,7 +14323,7 @@ ALTER SEQUENCE duo_workflows_checkpoint_writes_id_seq OWNED BY duo_workflows_che CREATE TABLE duo_workflows_checkpoints ( id bigint NOT NULL, workflow_id bigint NOT NULL, - project_id bigint NOT NULL, + project_id bigint, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, thread_ts text NOT NULL, @@ -14331,6 +14332,7 @@ CREATE TABLE duo_workflows_checkpoints ( metadata jsonb NOT NULL, namespace_id bigint, CONSTRAINT check_3dcc551d16 CHECK ((char_length(parent_ts) <= 255)), + CONSTRAINT check_4b59da71b6 CHECK ((num_nonnulls(namespace_id, project_id) = 1)), CONSTRAINT check_5d3139b983 CHECK ((char_length(thread_ts) <= 255)) ); @@ -14346,7 +14348,7 @@ ALTER SEQUENCE duo_workflows_checkpoints_id_seq OWNED BY duo_workflows_checkpoin CREATE TABLE duo_workflows_events ( id bigint NOT NULL, workflow_id bigint NOT NULL, - project_id bigint NOT NULL, + project_id bigint, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, event_type smallint NOT NULL, @@ -14355,7 +14357,8 @@ CREATE TABLE duo_workflows_events ( correlation_id_value text, namespace_id bigint, CONSTRAINT check_125840165c CHECK ((char_length(message) <= 16384)), - CONSTRAINT check_5e35596b00 CHECK ((char_length(correlation_id_value) <= 128)) + CONSTRAINT check_5e35596b00 CHECK ((char_length(correlation_id_value) <= 128)), + CONSTRAINT check_9014d33202 CHECK ((num_nonnulls(namespace_id, project_id) = 1)) ); CREATE SEQUENCE duo_workflows_events_id_seq @@ -14370,7 +14373,7 @@ ALTER SEQUENCE duo_workflows_events_id_seq OWNED BY duo_workflows_events.id; CREATE TABLE duo_workflows_workflows ( id bigint NOT NULL, user_id bigint NOT NULL, - project_id bigint NOT NULL, + project_id bigint, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, status smallint DEFAULT 0 NOT NULL, @@ -14384,6 +14387,7 @@ CREATE TABLE duo_workflows_workflows ( namespace_id bigint, CONSTRAINT check_30ca07a4ef CHECK ((char_length(goal) <= 16384)), CONSTRAINT check_3a9162f1ae CHECK ((char_length(image) <= 2048)), + CONSTRAINT check_73884a5839 CHECK ((num_nonnulls(namespace_id, project_id) = 1)), CONSTRAINT check_ec723e2a1a CHECK ((char_length(workflow_definition) <= 255)) ); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 9d9c60ca294..82272ad4199 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -56059,6 +56059,9 @@ msgstr "" msgid "SecurityOrchestration|All projects in this group except:" msgstr "" +msgid "SecurityOrchestration|All projects in this instance except:" +msgstr "" + msgid "SecurityOrchestration|All projects linked to security policy project." msgstr ""