Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20230529182720_recreate_billable_index.rb2
-rw-r--r--db/migrate/20230529184716_recreated_activity_index.rb2
-rw-r--r--db/migrate/20230605043258_add_unconfirmed_created_at_index_to_users.rb2
-rw-r--r--db/migrate/20230926092914_add_approval_group_rules.rb34
-rw-r--r--db/migrate/20230926092944_add_approval_group_rules_groups.rb18
-rw-r--r--db/migrate/20230926093004_add_approval_group_rules_users.rb18
-rw-r--r--db/migrate/20230926093025_add_approval_group_rules_protected_branches.rb21
-rw-r--r--db/migrate/20230926093101_add_fk_to_approval_rule_on_approval_group_rules_users.rb18
-rw-r--r--db/migrate/20230926093144_add_fk_to_user_on_approval_group_rules_users.rb15
-rw-r--r--db/migrate/20230926093211_add_fk_to_approval_rule_on_approval_group_rules_groups.rb16
-rw-r--r--db/migrate/20230926093251_add_fk_to_group_on_approval_group_rules_groups.rb15
-rw-r--r--db/migrate/20230926105440_add_fk_to_approval_rule_on_approval_group_rules_protected_branches.rb18
-rw-r--r--db/migrate/20230926105931_add_fk_to_protected_branch_on_approval_group_rules_protected_branches.rb16
-rw-r--r--db/migrate/20230927124202_add_mastodon_to_user_details.rb21
-rw-r--r--db/migrate/20230928145555_add_fk_to_security_orchestration_policy_configuration_on_approval_group_rules.rb17
-rw-r--r--db/migrate/20230928145637_add_fk_to_scan_result_policy_on_approval_group_rules.rb16
-rw-r--r--db/migrate/20230929155123_migrate_disable_merge_trains_value.rb55
-rw-r--r--db/migrate/20231002162941_add_enable_artifact_external_redirect_warning_page_to_application_settings.rb10
-rw-r--r--db/migrate/20231005151816_add_created_at_to_status_check_responses.rb7
-rw-r--r--db/migrate/20231009115713_remove_duplicate_index_rule_type_four.rb16
-rw-r--r--db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb15
-rw-r--r--db/migrate/20231017095738_create_activity_pub_releases_subscriptions.rb25
-rw-r--r--db/migrate/20231017114131_add_auto_canceled_by_partition_id_to_p_ci_builds.rb14
-rw-r--r--db/migrate/20231017134349_create_ml_model_metadata.rb19
-rw-r--r--db/migrate/20231017135207_add_fields_to_ml_model.rb23
-rw-r--r--db/migrate/20231017154804_add_index_to_status_check_responses_on_id_and_status.rb14
-rw-r--r--db/migrate/20231017181403_add_generated_to_diff_files.rb9
-rw-r--r--db/migrate/20231018140154_remove_hashed_storage_migration_workers_job_instances.rb21
-rw-r--r--db/migrate/20231018152419_add_text_limit_to_ml_models.rb13
-rw-r--r--db/migrate/20231019104211_add_file_sha256_to_packages_nuget_symbols.rb13
-rw-r--r--db/migrate/20231019122855_add_semver_index_ci_runner_machines.rb24
-rw-r--r--db/migrate/20231019145202_add_status_to_packages_npm_metadata_caches.rb7
-rw-r--r--db/migrate/20231019180421_add_name_description_to_catalog_resources.rb28
-rw-r--r--db/migrate/20231020020732_add_user_phone_number_validation_telesign_reference_xid_index.rb15
-rw-r--r--db/migrate/20231020074227_add_auto_canceled_by_partition_id_to_p_ci_builds_self_managed.rb13
-rw-r--r--db/migrate/20231020095624_create_audit_events_streaming_http_group_namespace_filters.rb22
-rw-r--r--db/migrate/20231020112541_add_column_model_version_id_to_ml_candidates.rb7
-rw-r--r--db/migrate/20231020181652_add_index_packages_npm_metadata_caches_on_id_and_project_id_and_status.rb18
-rw-r--r--db/migrate/20231023073841_add_indexes_to_project_compliance_standards_adherence.rb21
-rw-r--r--db/migrate/20231023114006_add_index_on_model_version_id_to_ml_candidates.rb15
-rw-r--r--db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb15
-rw-r--r--db/migrate/20231023121955_add_description_to_ml_model_versions.rb9
-rw-r--r--db/migrate/20231023122508_add_text_limit_to_descriptions_on_ml_model_versions.rb13
-rw-r--r--db/migrate/20231024123444_add_archive_project_to_member_roles.rb9
-rw-r--r--db/migrate/20231024133234_add_source_package_name_to_sbom_component.rb28
-rw-r--r--db/migrate/20231024142236_add_fields_to_bulk_import_failures.rb12
-rw-r--r--db/migrate/20231024143457_add_text_limit_to_bulk_import_failures.rb16
-rw-r--r--db/migrate/20231024151916_add_index_unique_setting_type_on_vs_code_settings.rb18
-rw-r--r--db/migrate/20231024173744_add_path_to_catalog_resource_components.rb20
-rw-r--r--db/migrate/20231024212214_add_pipeline_cancel_role_restriction_enum.rb12
-rw-r--r--db/migrate/20231025123238_create_compliance_framework_security_policies.rb21
-rw-r--r--db/migrate/20231026050554_add_functions_for_primary_key_lookup.rb26
-rw-r--r--db/migrate/20231027052949_initialize_conversion_of_system_note_metadata_to_bigint.rb18
-rw-r--r--db/migrate/20231027064352_add_service_access_tokens_expiration_application_setting.rb11
-rw-r--r--db/migrate/20231027065205_add_service_access_tokens_expiration_namespace_setting.rb11
-rw-r--r--db/migrate/20231027084327_change_personal_access_tokens_remove_not_null_expires_at.rb17
-rw-r--r--db/migrate/20231030051837_add_project_id_to_packages_tags.rb10
-rw-r--r--db/migrate/20231030051838_add_index_to_packages_tags_project_id.rb15
-rw-r--r--db/migrate/20231030051839_add_foreign_key_to_packages_tags_project_id.rb16
-rw-r--r--db/migrate/20231030205639_update_default_package_metadata_purl_types.rb15
-rw-r--r--db/migrate/20231030205756_index_user_details_on_enterprise_group_id_and_user_id.rb22
-rw-r--r--db/migrate/20231031141439_add_smtp_authentication_to_service_desk_custom_email_credentials.rb10
-rw-r--r--db/migrate/20231031200433_add_framework_fk_to_compliance_framework_security_policies.rb19
-rw-r--r--db/migrate/20231031200645_add_policy_configuration_fk_to_compliance_framework_security_policies.rb19
-rw-r--r--db/migrate/20231102142553_add_zoekt_nodes.rb19
-rw-r--r--db/migrate/20231102142554_migrate_zoekt_shards_to_zoekt_nodes.rb34
-rw-r--r--db/migrate/20231102142555_add_zoekt_node_id_to_indexed_namespaces.rb13
-rw-r--r--db/migrate/20231102142565_add_zoekt_node_foreign_key_to_indexed_namespaces.rb17
-rw-r--r--db/migrate/20231103162825_add_wolfi_purl_type_to_package_metadata_purl_types.rb31
-rw-r--r--db/migrate/20231103195309_remove_deprecated_package_metadata_sync_worker.rb16
-rw-r--r--db/migrate/20231103223224_backfill_zoekt_node_id_on_indexed_namespaces.rb19
-rw-r--r--db/migrate/20231106145853_add_product_analytics_enabled_to_namespace_settings.rb9
-rw-r--r--db/migrate/20231106212340_add_visibility_level_to_catalog_resources.rb13
-rw-r--r--db/migrate/20231107062104_add_network_policy_egress_to_agent.rb22
-rw-r--r--db/migrate/20231107071201_add_project_authorizations_recalculated_at_to_user_details.rb11
-rw-r--r--db/migrate/20231107205734_add_update_namespace_name_to_application_settings.rb9
-rw-r--r--db/migrate/20231108072342_add_display_time_format_preference.rb10
-rw-r--r--db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb9
-rw-r--r--db/migrate/20231109133153_drop_idx_namespaces_on_ldap_sync_last_successful_update_at_for_gitlab.rb28
79 files changed, 1308 insertions, 7 deletions
diff --git a/db/migrate/20230529182720_recreate_billable_index.rb b/db/migrate/20230529182720_recreate_billable_index.rb
index 5e56dd7005a..a983dc5f295 100644
--- a/db/migrate/20230529182720_recreate_billable_index.rb
+++ b/db/migrate/20230529182720_recreate_billable_index.rb
@@ -8,8 +8,10 @@ class RecreateBillableIndex < Gitlab::Database::Migration[2.1]
def up
remove_concurrent_index_by_name :users, INDEX_NAME
+ # rubocop:disable Migration/PreventIndexCreation
add_concurrent_index :users, :id, name: INDEX_NAME,
where: "state = 'active' AND (user_type IN (0, 6, 4, 13)) AND (user_type IN (0, 4, 5))"
+ # rubocop:enable Migration/PreventIndexCreation
end
def down
diff --git a/db/migrate/20230529184716_recreated_activity_index.rb b/db/migrate/20230529184716_recreated_activity_index.rb
index 2b949d39de1..c5c76b8ec14 100644
--- a/db/migrate/20230529184716_recreated_activity_index.rb
+++ b/db/migrate/20230529184716_recreated_activity_index.rb
@@ -8,9 +8,11 @@ class RecreatedActivityIndex < Gitlab::Database::Migration[2.1]
def up
remove_concurrent_index_by_name :users, INDEX_NAME
+ # rubocop:disable Migration/PreventIndexCreation
add_concurrent_index :users, [:id, :last_activity_on],
name: INDEX_NAME,
where: "state = 'active' AND user_type IN (0, 4)"
+ # rubocop:enable Migration/PreventIndexCreation
end
def down
diff --git a/db/migrate/20230605043258_add_unconfirmed_created_at_index_to_users.rb b/db/migrate/20230605043258_add_unconfirmed_created_at_index_to_users.rb
index 65bd7a1266b..bd3a7006972 100644
--- a/db/migrate/20230605043258_add_unconfirmed_created_at_index_to_users.rb
+++ b/db/migrate/20230605043258_add_unconfirmed_created_at_index_to_users.rb
@@ -6,9 +6,11 @@ class AddUnconfirmedCreatedAtIndexToUsers < Gitlab::Database::Migration[2.1]
INDEX_NAME = 'index_users_on_unconfirmed_and_created_at_for_active_humans'
def up
+ # rubocop:disable Migration/PreventIndexCreation
add_concurrent_index :users, [:created_at, :id],
name: INDEX_NAME,
where: "confirmed_at IS NULL AND state = 'active' AND user_type IN (0)"
+ # rubocop:enable Migration/PreventIndexCreation
end
def down
diff --git a/db/migrate/20230926092914_add_approval_group_rules.rb b/db/migrate/20230926092914_add_approval_group_rules.rb
new file mode 100644
index 00000000000..c5f4a356df1
--- /dev/null
+++ b/db/migrate/20230926092914_add_approval_group_rules.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class AddApprovalGroupRules < Gitlab::Database::Migration[2.1]
+ INDEX_GROUP_ID_TYPE_NAME = 'idx_on_approval_group_rules_group_id_type_name'
+ INDEX_ANY_APPROVER_TYPE = 'idx_on_approval_group_rules_any_approver_type'
+ INDEX_SECURITY_ORCHESTRATION_POLICY_CONFURATION = 'idx_on_approval_group_rules_security_orch_policy'
+ disable_ddl_transaction!
+
+ def up
+ create_table :approval_group_rules do |t|
+ t.references :group, references: :namespaces, null: false,
+ foreign_key: { to_table: :namespaces, on_delete: :cascade }, index: false
+ t.timestamps_with_timezone
+ t.integer :approvals_required, limit: 2, null: false, default: 0
+ t.integer :report_type, limit: 2, null: true, default: nil
+ t.integer :rule_type, limit: 2, null: false, default: 1
+ t.integer :security_orchestration_policy_configuration_id, limit: 5
+ t.integer :scan_result_policy_id, limit: 5, index: true
+ t.text :name, null: false, limit: 255
+
+ t.index [:group_id, :rule_type, :name], unique: true, name: INDEX_GROUP_ID_TYPE_NAME
+ t.index [:group_id, :rule_type], where: 'rule_type = 4', unique: true, name: INDEX_ANY_APPROVER_TYPE
+ t.index :security_orchestration_policy_configuration_id, name: INDEX_SECURITY_ORCHESTRATION_POLICY_CONFURATION
+ end
+
+ add_text_limit :approval_group_rules, :name, 255
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :approval_group_rules
+ end
+ end
+end
diff --git a/db/migrate/20230926092944_add_approval_group_rules_groups.rb b/db/migrate/20230926092944_add_approval_group_rules_groups.rb
new file mode 100644
index 00000000000..52ac86737e6
--- /dev/null
+++ b/db/migrate/20230926092944_add_approval_group_rules_groups.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddApprovalGroupRulesGroups < Gitlab::Database::Migration[2.1]
+ INDEX_RULE_GROUP = 'idx_on_approval_group_rules_groups_rule_group'
+
+ def up
+ create_table :approval_group_rules_groups do |t|
+ t.bigint :approval_group_rule_id, null: false
+ t.bigint :group_id, null: false, index: true
+
+ t.index [:approval_group_rule_id, :group_id], unique: true, name: INDEX_RULE_GROUP
+ end
+ end
+
+ def down
+ drop_table :approval_group_rules_groups
+ end
+end
diff --git a/db/migrate/20230926093004_add_approval_group_rules_users.rb b/db/migrate/20230926093004_add_approval_group_rules_users.rb
new file mode 100644
index 00000000000..8c6d14ce9ac
--- /dev/null
+++ b/db/migrate/20230926093004_add_approval_group_rules_users.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddApprovalGroupRulesUsers < Gitlab::Database::Migration[2.1]
+ INDEX_RULE_USER = 'idx_on_approval_group_rules_users_rule_user'
+
+ def up
+ create_table :approval_group_rules_users do |t|
+ t.bigint :approval_group_rule_id, null: false
+ t.bigint :user_id, null: false, index: true
+
+ t.index [:approval_group_rule_id, :user_id], unique: true, name: INDEX_RULE_USER
+ end
+ end
+
+ def down
+ drop_table :approval_group_rules_users
+ end
+end
diff --git a/db/migrate/20230926093025_add_approval_group_rules_protected_branches.rb b/db/migrate/20230926093025_add_approval_group_rules_protected_branches.rb
new file mode 100644
index 00000000000..5f623ec9edb
--- /dev/null
+++ b/db/migrate/20230926093025_add_approval_group_rules_protected_branches.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddApprovalGroupRulesProtectedBranches < Gitlab::Database::Migration[2.1]
+ INDEX_RULE_PROTECTED_BRANCH = 'idx_on_approval_group_rules_protected_branch'
+ INDEX_APPROVAL_GROUP_RULE = 'idx_on_approval_group_rules'
+ INDEX_PROTECTED_BRANCH = 'idx_on_protected_branch'
+
+ def up
+ create_table :approval_group_rules_protected_branches do |t|
+ t.bigint :approval_group_rule_id, null: false
+ t.bigint :protected_branch_id, null: false
+
+ t.index :protected_branch_id, name: INDEX_PROTECTED_BRANCH
+ t.index [:approval_group_rule_id, :protected_branch_id], unique: true, name: INDEX_RULE_PROTECTED_BRANCH
+ end
+ end
+
+ def down
+ drop_table :approval_group_rules_protected_branches
+ end
+end
diff --git a/db/migrate/20230926093101_add_fk_to_approval_rule_on_approval_group_rules_users.rb b/db/migrate/20230926093101_add_fk_to_approval_rule_on_approval_group_rules_users.rb
new file mode 100644
index 00000000000..4c11542e9e6
--- /dev/null
+++ b/db/migrate/20230926093101_add_fk_to_approval_rule_on_approval_group_rules_users.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddFkToApprovalRuleOnApprovalGroupRulesUsers < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules_users,
+ :approval_group_rules,
+ column: :approval_group_rule_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules_users, column: :approval_group_rule_id
+ end
+ end
+end
diff --git a/db/migrate/20230926093144_add_fk_to_user_on_approval_group_rules_users.rb b/db/migrate/20230926093144_add_fk_to_user_on_approval_group_rules_users.rb
new file mode 100644
index 00000000000..30c08c8966d
--- /dev/null
+++ b/db/migrate/20230926093144_add_fk_to_user_on_approval_group_rules_users.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddFkToUserOnApprovalGroupRulesUsers < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules_users, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules_users, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230926093211_add_fk_to_approval_rule_on_approval_group_rules_groups.rb b/db/migrate/20230926093211_add_fk_to_approval_rule_on_approval_group_rules_groups.rb
new file mode 100644
index 00000000000..44526150266
--- /dev/null
+++ b/db/migrate/20230926093211_add_fk_to_approval_rule_on_approval_group_rules_groups.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddFkToApprovalRuleOnApprovalGroupRulesGroups < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules_groups, :approval_group_rules, column: :approval_group_rule_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules_groups, column: :approval_group_rule_id
+ end
+ end
+end
diff --git a/db/migrate/20230926093251_add_fk_to_group_on_approval_group_rules_groups.rb b/db/migrate/20230926093251_add_fk_to_group_on_approval_group_rules_groups.rb
new file mode 100644
index 00000000000..2052993af05
--- /dev/null
+++ b/db/migrate/20230926093251_add_fk_to_group_on_approval_group_rules_groups.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddFkToGroupOnApprovalGroupRulesGroups < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules_groups, :namespaces, column: :group_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules_groups, column: :group_id
+ end
+ end
+end
diff --git a/db/migrate/20230926105440_add_fk_to_approval_rule_on_approval_group_rules_protected_branches.rb b/db/migrate/20230926105440_add_fk_to_approval_rule_on_approval_group_rules_protected_branches.rb
new file mode 100644
index 00000000000..cd799656ac9
--- /dev/null
+++ b/db/migrate/20230926105440_add_fk_to_approval_rule_on_approval_group_rules_protected_branches.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddFkToApprovalRuleOnApprovalGroupRulesProtectedBranches < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules_protected_branches,
+ :approval_group_rules,
+ column: :approval_group_rule_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules_protected_branches, column: :approval_group_rule_id
+ end
+ end
+end
diff --git a/db/migrate/20230926105931_add_fk_to_protected_branch_on_approval_group_rules_protected_branches.rb b/db/migrate/20230926105931_add_fk_to_protected_branch_on_approval_group_rules_protected_branches.rb
new file mode 100644
index 00000000000..5804a8da4d8
--- /dev/null
+++ b/db/migrate/20230926105931_add_fk_to_protected_branch_on_approval_group_rules_protected_branches.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddFkToProtectedBranchOnApprovalGroupRulesProtectedBranches < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules_protected_branches, :protected_branches,
+ column: :protected_branch_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules_protected_branches, column: :protected_branch_id
+ end
+ end
+end
diff --git a/db/migrate/20230927124202_add_mastodon_to_user_details.rb b/db/migrate/20230927124202_add_mastodon_to_user_details.rb
new file mode 100644
index 00000000000..a1aa099087b
--- /dev/null
+++ b/db/migrate/20230927124202_add_mastodon_to_user_details.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddMastodonToUserDetails < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ USER_DETAILS_FIELD_LIMIT = 500
+
+ def up
+ with_lock_retries do
+ add_column :user_details, :mastodon, :text, default: '', null: false, if_not_exists: true
+ end
+
+ add_text_limit :user_details, :mastodon, USER_DETAILS_FIELD_LIMIT
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :user_details, :mastodon
+ end
+ end
+end
diff --git a/db/migrate/20230928145555_add_fk_to_security_orchestration_policy_configuration_on_approval_group_rules.rb b/db/migrate/20230928145555_add_fk_to_security_orchestration_policy_configuration_on_approval_group_rules.rb
new file mode 100644
index 00000000000..2630adcf81f
--- /dev/null
+++ b/db/migrate/20230928145555_add_fk_to_security_orchestration_policy_configuration_on_approval_group_rules.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddFkToSecurityOrchestrationPolicyConfigurationOnApprovalGroupRules < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules, :security_orchestration_policy_configurations,
+ column: :security_orchestration_policy_configuration_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules,
+ column: :security_orchestration_policy_configuration_id
+ end
+ end
+end
diff --git a/db/migrate/20230928145637_add_fk_to_scan_result_policy_on_approval_group_rules.rb b/db/migrate/20230928145637_add_fk_to_scan_result_policy_on_approval_group_rules.rb
new file mode 100644
index 00000000000..f30d03e0f62
--- /dev/null
+++ b/db/migrate/20230928145637_add_fk_to_scan_result_policy_on_approval_group_rules.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddFkToScanResultPolicyOnApprovalGroupRules < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :approval_group_rules, :scan_result_policies,
+ column: :scan_result_policy_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :approval_group_rules, column: :scan_result_policy_id
+ end
+ end
+end
diff --git a/db/migrate/20230929155123_migrate_disable_merge_trains_value.rb b/db/migrate/20230929155123_migrate_disable_merge_trains_value.rb
new file mode 100644
index 00000000000..59eadd07733
--- /dev/null
+++ b/db/migrate/20230929155123_migrate_disable_merge_trains_value.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+class MigrateDisableMergeTrainsValue < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class Gate < MigrationRecord
+ self.table_name = 'feature_gates'
+ end
+
+ UPDATE_QUERY = <<-SQL
+ UPDATE project_ci_cd_settings SET merge_trains_enabled = :merge_trains_enabled
+ WHERE project_id IN (:project_ids)
+ SQL
+
+ def update_merge_trains_enabled(project_ids, merge_trains_enabled)
+ ApplicationRecord.connection.execute(
+ ApplicationRecord.sanitize_sql([
+ UPDATE_QUERY,
+ {
+ project_ids: project_ids,
+ merge_trains_enabled: merge_trains_enabled.to_s.upcase
+ }
+ ])
+ )
+ end
+
+ def get_project_ids
+ project_ids = Gate.where(feature_key: :disable_merge_trains, key: 'actors').pluck('value')
+
+ project_ids.filter_map do |project_id|
+ # ensure actor is a project formatted correctly
+ match = project_id.match(/Project:[0-9]+/)[0]
+ # Extract the project id if there is an actor
+ match ? project_id.gsub('Project:', '').to_i : nil
+ end
+ end
+
+ def up
+ project_ids = get_project_ids
+
+ return unless project_ids
+
+ update_merge_trains_enabled(project_ids, false)
+ end
+
+ def down
+ project_ids = get_project_ids
+
+ return unless project_ids
+
+ update_merge_trains_enabled(project_ids, true)
+ end
+end
diff --git a/db/migrate/20231002162941_add_enable_artifact_external_redirect_warning_page_to_application_settings.rb b/db/migrate/20231002162941_add_enable_artifact_external_redirect_warning_page_to_application_settings.rb
new file mode 100644
index 00000000000..06fc4b6b313
--- /dev/null
+++ b/db/migrate/20231002162941_add_enable_artifact_external_redirect_warning_page_to_application_settings.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddEnableArtifactExternalRedirectWarningPageToApplicationSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column(:application_settings, :enable_artifact_external_redirect_warning_page, :boolean, default: true,
+ null: false)
+ end
+end
diff --git a/db/migrate/20231005151816_add_created_at_to_status_check_responses.rb b/db/migrate/20231005151816_add_created_at_to_status_check_responses.rb
new file mode 100644
index 00000000000..118586f61a8
--- /dev/null
+++ b/db/migrate/20231005151816_add_created_at_to_status_check_responses.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddCreatedAtToStatusCheckResponses < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :status_check_responses, :created_at, :datetime_with_timezone, null: false, default: -> { 'NOW()' }
+ end
+end
diff --git a/db/migrate/20231009115713_remove_duplicate_index_rule_type_four.rb b/db/migrate/20231009115713_remove_duplicate_index_rule_type_four.rb
new file mode 100644
index 00000000000..7fe69c30a81
--- /dev/null
+++ b/db/migrate/20231009115713_remove_duplicate_index_rule_type_four.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveDuplicateIndexRuleTypeFour < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'any_approver_merge_request_rule_type_unique_index'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :approval_merge_request_rules, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :approval_merge_request_rules, [:merge_request_id, :rule_type], where: 'rule_type = 4',
+ name: INDEX_NAME, unique: true
+ end
+end
diff --git a/db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb b/db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb
new file mode 100644
index 00000000000..d5e8ecfe370
--- /dev/null
+++ b/db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveTasksToBeDoneWorker < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ DEPRECATED_JOB_CLASSES = %w[TasksToBeDone::CreateWorker]
+
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+end
diff --git a/db/migrate/20231017095738_create_activity_pub_releases_subscriptions.rb b/db/migrate/20231017095738_create_activity_pub_releases_subscriptions.rb
new file mode 100644
index 00000000000..19693c29a33
--- /dev/null
+++ b/db/migrate/20231017095738_create_activity_pub_releases_subscriptions.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class CreateActivityPubReleasesSubscriptions < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ create_table :activity_pub_releases_subscriptions do |t|
+ t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :status, null: false, limit: 2, default: 1
+ t.text :shared_inbox_url, limit: 1024
+ t.text :subscriber_inbox_url, limit: 1024
+ t.text :subscriber_url, limit: 1024, null: false
+ t.jsonb :payload, null: true
+ t.index 'project_id, LOWER(subscriber_url)', name: :index_activity_pub_releases_sub_on_project_id_sub_url,
+ unique: true
+ t.index 'project_id, LOWER(subscriber_inbox_url)',
+ name: :index_activity_pub_releases_sub_on_project_id_inbox_url, unique: true
+ end
+ end
+
+ def down
+ drop_table :activity_pub_releases_subscriptions
+ end
+end
diff --git a/db/migrate/20231017114131_add_auto_canceled_by_partition_id_to_p_ci_builds.rb b/db/migrate/20231017114131_add_auto_canceled_by_partition_id_to_p_ci_builds.rb
index ecc606ca1a8..afd3b60a244 100644
--- a/db/migrate/20231017114131_add_auto_canceled_by_partition_id_to_p_ci_builds.rb
+++ b/db/migrate/20231017114131_add_auto_canceled_by_partition_id_to_p_ci_builds.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
class AddAutoCanceledByPartitionIdToPCiBuilds < Gitlab::Database::Migration[2.1]
- include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
-
- enable_lock_retries!
-
- def change
- return unless can_execute_on?(:ci_builds)
+ def up
+ # no-op
+ # moved to db/migrate/20231020074227_add_auto_canceled_by_partition_id_to_p_ci_builds_self_managed.rb
+ end
- add_column :p_ci_builds, :auto_canceled_by_partition_id, :bigint, default: 100, null: false, if_not_exists: true
+ def down
+ # no-op
+ # moved to db/migrate/20231020074227_add_auto_canceled_by_partition_id_to_p_ci_builds_self_managed.rb
end
end
diff --git a/db/migrate/20231017134349_create_ml_model_metadata.rb b/db/migrate/20231017134349_create_ml_model_metadata.rb
new file mode 100644
index 00000000000..f34ba729677
--- /dev/null
+++ b/db/migrate/20231017134349_create_ml_model_metadata.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateMlModelMetadata < Gitlab::Database::Migration[2.1]
+ ML_MODEL_METADATA_NAME_INDEX_NAME = "unique_index_ml_model_metadata_name"
+
+ def change
+ create_table :ml_model_metadata do |t|
+ t.timestamps_with_timezone null: false
+ t.references :model,
+ foreign_key: { to_table: :ml_models, on_delete: :cascade },
+ index: false,
+ null: false
+ t.text :name, limit: 255, null: false
+ t.text :value, limit: 5000, null: false
+
+ t.index [:model_id, :name], unique: true, name: ML_MODEL_METADATA_NAME_INDEX_NAME
+ end
+ end
+end
diff --git a/db/migrate/20231017135207_add_fields_to_ml_model.rb b/db/migrate/20231017135207_add_fields_to_ml_model.rb
new file mode 100644
index 00000000000..cb937e49491
--- /dev/null
+++ b/db/migrate/20231017135207_add_fields_to_ml_model.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddFieldsToMlModel < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20231018152419_add_text_limit_to_ml_models.rb
+ add_column :ml_models, :description, :text
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ add_column :ml_models, :user_id, :integer, null: true
+ add_concurrent_foreign_key :ml_models, :users, column: :user_id, on_delete: :nullify
+
+ add_concurrent_index :ml_models, :user_id
+ end
+
+ def down
+ remove_column :ml_models, :description
+ remove_column :ml_models, :user_id
+ remove_foreign_key_if_exists :ml_models, column: :user_id
+ end
+end
diff --git a/db/migrate/20231017154804_add_index_to_status_check_responses_on_id_and_status.rb b/db/migrate/20231017154804_add_index_to_status_check_responses_on_id_and_status.rb
new file mode 100644
index 00000000000..77aa1a1bb0f
--- /dev/null
+++ b/db/migrate/20231017154804_add_index_to_status_check_responses_on_id_and_status.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddIndexToStatusCheckResponsesOnIdAndStatus < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'idx_status_check_responses_on_id_and_status'
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :status_check_responses, [:id, :status], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :status_check_responses, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20231017181403_add_generated_to_diff_files.rb b/db/migrate/20231017181403_add_generated_to_diff_files.rb
new file mode 100644
index 00000000000..f93669381ef
--- /dev/null
+++ b/db/migrate/20231017181403_add_generated_to_diff_files.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddGeneratedToDiffFiles < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :merge_request_diff_files, :generated, :boolean
+ end
+end
diff --git a/db/migrate/20231018140154_remove_hashed_storage_migration_workers_job_instances.rb b/db/migrate/20231018140154_remove_hashed_storage_migration_workers_job_instances.rb
new file mode 100644
index 00000000000..73105a76249
--- /dev/null
+++ b/db/migrate/20231018140154_remove_hashed_storage_migration_workers_job_instances.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveHashedStorageMigrationWorkersJobInstances < Gitlab::Database::Migration[2.1]
+ DEPRECATED_JOB_CLASSES = %w[
+ HashedStorage::MigratorWorker
+ HashedStorage::ProjectMigrateWorker
+ HashedStorage::ProjectRollbackWorker
+ HashedStorage::RollbackerWorker
+ HashedStorage::BaseWorker
+ ]
+
+ disable_ddl_transaction!
+
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+end
diff --git a/db/migrate/20231018152419_add_text_limit_to_ml_models.rb b/db/migrate/20231018152419_add_text_limit_to_ml_models.rb
new file mode 100644
index 00000000000..179d6f20b53
--- /dev/null
+++ b/db/migrate/20231018152419_add_text_limit_to_ml_models.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToMlModels < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :ml_models, :description, 5000
+ end
+
+ def down
+ remove_text_limit :ml_models, :description
+ end
+end
diff --git a/db/migrate/20231019104211_add_file_sha256_to_packages_nuget_symbols.rb b/db/migrate/20231019104211_add_file_sha256_to_packages_nuget_symbols.rb
new file mode 100644
index 00000000000..374fa91000d
--- /dev/null
+++ b/db/migrate/20231019104211_add_file_sha256_to_packages_nuget_symbols.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddFileSha256ToPackagesNugetSymbols < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column :packages_nuget_symbols, :file_sha256, :binary
+ end
+
+ def down
+ remove_column :packages_nuget_symbols, :file_sha256
+ end
+end
diff --git a/db/migrate/20231019122855_add_semver_index_ci_runner_machines.rb b/db/migrate/20231019122855_add_semver_index_ci_runner_machines.rb
new file mode 100644
index 00000000000..b09f3cda60e
--- /dev/null
+++ b/db/migrate/20231019122855_add_semver_index_ci_runner_machines.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddSemverIndexCiRunnerMachines < Gitlab::Database::Migration[2.1]
+ MAJOR_INDEX_NAME = 'index_ci_runner_machines_on_major_version_trigram'
+ MINOR_INDEX_NAME = 'index_ci_runner_machines_on_minor_version_trigram'
+ PATCH_INDEX_NAME = 'index_ci_runner_machines_on_patch_version_trigram'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_runner_machines, %q[((substring(version from '^\d+\.'))), version, runner_id],
+ name: MAJOR_INDEX_NAME
+ add_concurrent_index :ci_runner_machines, %q[((substring(version from '^\d+\.\d+\.'))), version, runner_id],
+ name: MINOR_INDEX_NAME
+ add_concurrent_index :ci_runner_machines, %q[((substring(version from '^\d+\.\d+\.\d+'))), version, runner_id],
+ name: PATCH_INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_runner_machines, MAJOR_INDEX_NAME
+ remove_concurrent_index_by_name :ci_runner_machines, MINOR_INDEX_NAME
+ remove_concurrent_index_by_name :ci_runner_machines, PATCH_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20231019145202_add_status_to_packages_npm_metadata_caches.rb b/db/migrate/20231019145202_add_status_to_packages_npm_metadata_caches.rb
new file mode 100644
index 00000000000..f3d910e9350
--- /dev/null
+++ b/db/migrate/20231019145202_add_status_to_packages_npm_metadata_caches.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddStatusToPackagesNpmMetadataCaches < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :packages_npm_metadata_caches, :status, :integer, default: 0, null: false, limit: 2
+ end
+end
diff --git a/db/migrate/20231019180421_add_name_description_to_catalog_resources.rb b/db/migrate/20231019180421_add_name_description_to_catalog_resources.rb
new file mode 100644
index 00000000000..391d56342be
--- /dev/null
+++ b/db/migrate/20231019180421_add_name_description_to_catalog_resources.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class AddNameDescriptionToCatalogResources < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ NAME_INDEX = 'index_catalog_resources_on_name_trigram'
+ DESCRIPTION_INDEX = 'index_catalog_resources_on_description_trigram'
+
+ def up
+ # These columns must match the settings for the corresponding columns in the `projects` table
+ add_column :catalog_resources, :name, :varchar, null: true
+ add_column :catalog_resources, :description, :text, null: true # rubocop: disable Migration/AddLimitToTextColumns
+
+ add_concurrent_index :catalog_resources, :name, name: NAME_INDEX,
+ using: :gin, opclass: { name: :gin_trgm_ops }
+
+ add_concurrent_index :catalog_resources, :description, name: DESCRIPTION_INDEX,
+ using: :gin, opclass: { description: :gin_trgm_ops }
+ end
+
+ def down
+ remove_column :catalog_resources, :name
+ remove_column :catalog_resources, :description
+
+ remove_concurrent_index_by_name :catalog_resources, NAME_INDEX
+ remove_concurrent_index_by_name :catalog_resources, DESCRIPTION_INDEX
+ end
+end
diff --git a/db/migrate/20231020020732_add_user_phone_number_validation_telesign_reference_xid_index.rb b/db/migrate/20231020020732_add_user_phone_number_validation_telesign_reference_xid_index.rb
new file mode 100644
index 00000000000..4a0343f5809
--- /dev/null
+++ b/db/migrate/20231020020732_add_user_phone_number_validation_telesign_reference_xid_index.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUserPhoneNumberValidationTelesignReferenceXidIndex < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_user_phone_number_validations_on_telesign_reference_xid'
+
+ def up
+ add_concurrent_index(:user_phone_number_validations, :telesign_reference_xid, name: INDEX_NAME)
+ end
+
+ def down
+ remove_concurrent_index_by_name(:user_phone_number_validations, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20231020074227_add_auto_canceled_by_partition_id_to_p_ci_builds_self_managed.rb b/db/migrate/20231020074227_add_auto_canceled_by_partition_id_to_p_ci_builds_self_managed.rb
new file mode 100644
index 00000000000..5aa5d6c42ae
--- /dev/null
+++ b/db/migrate/20231020074227_add_auto_canceled_by_partition_id_to_p_ci_builds_self_managed.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddAutoCanceledByPartitionIdToPCiBuildsSelfManaged < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column :p_ci_builds, :auto_canceled_by_partition_id, :bigint, default: 100, null: false, if_not_exists: true
+ end
+
+ def down
+ remove_column :p_ci_builds, :auto_canceled_by_partition_id, if_exists: true
+ end
+end
diff --git a/db/migrate/20231020095624_create_audit_events_streaming_http_group_namespace_filters.rb b/db/migrate/20231020095624_create_audit_events_streaming_http_group_namespace_filters.rb
new file mode 100644
index 00000000000..07a580a12b2
--- /dev/null
+++ b/db/migrate/20231020095624_create_audit_events_streaming_http_group_namespace_filters.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateAuditEventsStreamingHttpGroupNamespaceFilters < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ UNIQ_DESTINATION_INDEX_NAME = 'unique_audit_events_group_namespace_filters_destination_id'
+ UNIQ_NAMESPACE_INDEX_NAME = 'unique_audit_events_group_namespace_filters_namespace_id'
+
+ def change
+ create_table :audit_events_streaming_http_group_namespace_filters do |t|
+ t.timestamps_with_timezone null: false
+ t.references :external_audit_event_destination,
+ null: false,
+ index: { unique: true, name: UNIQ_DESTINATION_INDEX_NAME },
+ foreign_key: { to_table: 'audit_events_external_audit_event_destinations', on_delete: :cascade }
+ t.references :namespace,
+ null: false,
+ index: { unique: true, name: UNIQ_NAMESPACE_INDEX_NAME },
+ foreign_key: { on_delete: :cascade }
+ end
+ end
+end
diff --git a/db/migrate/20231020112541_add_column_model_version_id_to_ml_candidates.rb b/db/migrate/20231020112541_add_column_model_version_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..7bfe78c4ebd
--- /dev/null
+++ b/db/migrate/20231020112541_add_column_model_version_id_to_ml_candidates.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddColumnModelVersionIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :ml_candidates, :model_version_id, :bigint, null: true
+ end
+end
diff --git a/db/migrate/20231020181652_add_index_packages_npm_metadata_caches_on_id_and_project_id_and_status.rb b/db/migrate/20231020181652_add_index_packages_npm_metadata_caches_on_id_and_project_id_and_status.rb
new file mode 100644
index 00000000000..6350ad935ca
--- /dev/null
+++ b/db/migrate/20231020181652_add_index_packages_npm_metadata_caches_on_id_and_project_id_and_status.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexPackagesNpmMetadataCachesOnIdAndProjectIdAndStatus < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_pkgs_npm_metadata_caches_on_id_and_project_id_and_status'
+ NPM_METADATA_CACHES_STATUS_DEFAULT = 0
+
+ def up
+ where = "project_id IS NULL AND status = #{NPM_METADATA_CACHES_STATUS_DEFAULT}"
+
+ add_concurrent_index :packages_npm_metadata_caches, :id, name: INDEX_NAME, where: where
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_npm_metadata_caches, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20231023073841_add_indexes_to_project_compliance_standards_adherence.rb b/db/migrate/20231023073841_add_indexes_to_project_compliance_standards_adherence.rb
new file mode 100644
index 00000000000..0a593547ddb
--- /dev/null
+++ b/db/migrate/20231023073841_add_indexes_to_project_compliance_standards_adherence.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddIndexesToProjectComplianceStandardsAdherence < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAMESPACE_ID = 'index_project_compliance_standards_adherence_on_namespace_id'
+ INDEX_NAMESPACE_AND_PROJECT_ID_DESC = 'i_compliance_standards_adherence_on_namespace_id_and_proj_id'
+
+ def up
+ add_concurrent_index :project_compliance_standards_adherence, [:namespace_id, :project_id, :id],
+ order: { project_id: :desc, id: :desc }, using: :btree, name: INDEX_NAMESPACE_AND_PROJECT_ID_DESC
+
+ remove_concurrent_index_by_name :project_compliance_standards_adherence, INDEX_NAMESPACE_ID
+ end
+
+ def down
+ add_concurrent_index :project_compliance_standards_adherence, :namespace_id, name: INDEX_NAMESPACE_ID
+
+ remove_concurrent_index_by_name :project_compliance_standards_adherence, INDEX_NAMESPACE_AND_PROJECT_ID_DESC
+ end
+end
diff --git a/db/migrate/20231023114006_add_index_on_model_version_id_to_ml_candidates.rb b/db/migrate/20231023114006_add_index_on_model_version_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..598600b8539
--- /dev/null
+++ b/db/migrate/20231023114006_add_index_on_model_version_id_to_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnModelVersionIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ml_candidates_on_model_version_id'
+
+ def up
+ add_concurrent_index :ml_candidates, :model_version_id, name: INDEX_NAME, unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :ml_candidates, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb b/db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb
new file mode 100644
index 00000000000..0d625a54656
--- /dev/null
+++ b/db/migrate/20231023114551_add_fk_on_ml_candidates_to_ml_model_versions.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddFkOnMlCandidatesToMlModelVersions < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(:ml_candidates, :ml_model_versions, column: :model_version_id, on_delete: :cascade)
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(:ml_model_versions, column: :model_version_id, on_delete: :cascade)
+ end
+ end
+end
diff --git a/db/migrate/20231023121955_add_description_to_ml_model_versions.rb b/db/migrate/20231023121955_add_description_to_ml_model_versions.rb
new file mode 100644
index 00000000000..4361477160a
--- /dev/null
+++ b/db/migrate/20231023121955_add_description_to_ml_model_versions.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDescriptionToMlModelVersions < Gitlab::Database::Migration[2.1]
+ def change
+ # rubocop:disable Migration/AddLimitToTextColumns -- limit being added on 20231023122508
+ add_column :ml_model_versions, :description, :text
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+end
diff --git a/db/migrate/20231023122508_add_text_limit_to_descriptions_on_ml_model_versions.rb b/db/migrate/20231023122508_add_text_limit_to_descriptions_on_ml_model_versions.rb
new file mode 100644
index 00000000000..9df61e4c2ef
--- /dev/null
+++ b/db/migrate/20231023122508_add_text_limit_to_descriptions_on_ml_model_versions.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToDescriptionsOnMlModelVersions < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :ml_model_versions, :description, 500
+ end
+
+ def down
+ remove_text_limit :ml_model_versions, :description
+ end
+end
diff --git a/db/migrate/20231024123444_add_archive_project_to_member_roles.rb b/db/migrate/20231024123444_add_archive_project_to_member_roles.rb
new file mode 100644
index 00000000000..27ff86450e8
--- /dev/null
+++ b/db/migrate/20231024123444_add_archive_project_to_member_roles.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddArchiveProjectToMemberRoles < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :member_roles, :archive_project, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20231024133234_add_source_package_name_to_sbom_component.rb b/db/migrate/20231024133234_add_source_package_name_to_sbom_component.rb
new file mode 100644
index 00000000000..41970429ca9
--- /dev/null
+++ b/db/migrate/20231024133234_add_source_package_name_to_sbom_component.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class AddSourcePackageNameToSbomComponent < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ INDEX = 'index_source_package_names_on_component_and_purl'
+
+ def up
+ with_lock_retries do
+ add_column :sbom_components, :source_package_name, :text, if_not_exists: true
+ end
+
+ add_text_limit :sbom_components, :source_package_name, 255
+ add_concurrent_index :sbom_components,
+ [:component_type, :source_package_name, :purl_type],
+ name: INDEX,
+ unique: true
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :sbom_components, :source_package_name, if_exists: true
+ end
+
+ remove_concurrent_index_by_name :sbom_components, name: INDEX
+ end
+end
diff --git a/db/migrate/20231024142236_add_fields_to_bulk_import_failures.rb b/db/migrate/20231024142236_add_fields_to_bulk_import_failures.rb
new file mode 100644
index 00000000000..670e42ba627
--- /dev/null
+++ b/db/migrate/20231024142236_add_fields_to_bulk_import_failures.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddFieldsToBulkImportFailures < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ def change
+ add_column :bulk_import_failures, :source_url, :text
+ add_column :bulk_import_failures, :source_title, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20231024143457_add_text_limit_to_bulk_import_failures.rb b/db/migrate/20231024143457_add_text_limit_to_bulk_import_failures.rb
new file mode 100644
index 00000000000..eeca88f22c9
--- /dev/null
+++ b/db/migrate/20231024143457_add_text_limit_to_bulk_import_failures.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToBulkImportFailures < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :bulk_import_failures, :source_url, 255
+ add_text_limit :bulk_import_failures, :source_title, 255
+ end
+
+ def down
+ remove_text_limit :bulk_import_failures, :source_url
+ remove_text_limit :bulk_import_failures, :source_title
+ end
+end
diff --git a/db/migrate/20231024151916_add_index_unique_setting_type_on_vs_code_settings.rb b/db/migrate/20231024151916_add_index_unique_setting_type_on_vs_code_settings.rb
new file mode 100644
index 00000000000..6eb34086299
--- /dev/null
+++ b/db/migrate/20231024151916_add_index_unique_setting_type_on_vs_code_settings.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexUniqueSettingTypeOnVsCodeSettings < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'unique_user_id_and_setting_type'
+ PREVIOUS_INDEX_NAME = 'index_vs_code_settings_on_user_id'
+
+ def up
+ remove_concurrent_index_by_name :vs_code_settings, name: PREVIOUS_INDEX_NAME
+ add_concurrent_index :vs_code_settings, [:user_id, :setting_type], name: INDEX_NAME, unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :vs_code_settings, name: INDEX_NAME
+ add_concurrent_index :vs_code_settings, [:user_id], name: PREVIOUS_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20231024173744_add_path_to_catalog_resource_components.rb b/db/migrate/20231024173744_add_path_to_catalog_resource_components.rb
new file mode 100644
index 00000000000..2473856faf1
--- /dev/null
+++ b/db/migrate/20231024173744_add_path_to_catalog_resource_components.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddPathToCatalogResourceComponents < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :catalog_resource_components, :path, :text, if_not_exists: true
+ end
+
+ add_text_limit :catalog_resource_components, :path, 255
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :catalog_resource_components, :path, :text, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20231024212214_add_pipeline_cancel_role_restriction_enum.rb b/db/migrate/20231024212214_add_pipeline_cancel_role_restriction_enum.rb
new file mode 100644
index 00000000000..ab26a1d783b
--- /dev/null
+++ b/db/migrate/20231024212214_add_pipeline_cancel_role_restriction_enum.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddPipelineCancelRoleRestrictionEnum < Gitlab::Database::Migration[2.1]
+ def up
+ add_column :project_ci_cd_settings, :restrict_pipeline_cancellation_role,
+ :integer, limit: 2, default: 0, null: false
+ end
+
+ def down
+ remove_column :project_ci_cd_settings, :restrict_pipeline_cancellation_role
+ end
+end
diff --git a/db/migrate/20231025123238_create_compliance_framework_security_policies.rb b/db/migrate/20231025123238_create_compliance_framework_security_policies.rb
new file mode 100644
index 00000000000..1cf970e0d6c
--- /dev/null
+++ b/db/migrate/20231025123238_create_compliance_framework_security_policies.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreateComplianceFrameworkSecurityPolicies < Gitlab::Database::Migration[2.2]
+ UNIQUE_INDEX_NAME = 'unique_compliance_framework_security_policies_framework_id'
+ POLICY_CONFIGURATION_INDEX_NAME = 'idx_compliance_security_policies_on_policy_configuration_id'
+
+ milestone '16.6'
+ enable_lock_retries!
+
+ def change
+ create_table :compliance_framework_security_policies do |t|
+ t.bigint :framework_id, null: false
+ t.bigint :policy_configuration_id, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :policy_index, limit: 2, null: false
+
+ t.index :policy_configuration_id, name: POLICY_CONFIGURATION_INDEX_NAME
+ t.index [:framework_id, :policy_configuration_id, :policy_index], unique: true, name: UNIQUE_INDEX_NAME
+ end
+ end
+end
diff --git a/db/migrate/20231026050554_add_functions_for_primary_key_lookup.rb b/db/migrate/20231026050554_add_functions_for_primary_key_lookup.rb
new file mode 100644
index 00000000000..ecf32f74e4b
--- /dev/null
+++ b/db/migrate/20231026050554_add_functions_for_primary_key_lookup.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class AddFunctionsForPrimaryKeyLookup < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ TABLES = %i[users namespaces projects].freeze
+
+ def up
+ TABLES.each do |table|
+ execute <<~SQL
+ CREATE OR REPLACE FUNCTION find_#{table}_by_id(#{table}_id bigint)
+ RETURNS #{table} AS $$
+ BEGIN
+ return (SELECT #{table} FROM #{table} WHERE id = #{table}_id LIMIT 1);
+ END;
+ $$ LANGUAGE plpgsql STABLE PARALLEL SAFE COST 1;
+ SQL
+ end
+ end
+
+ def down
+ TABLES.each do |table|
+ execute "DROP FUNCTION IF EXISTS find_#{table}_by_id"
+ end
+ end
+end
diff --git a/db/migrate/20231027052949_initialize_conversion_of_system_note_metadata_to_bigint.rb b/db/migrate/20231027052949_initialize_conversion_of_system_note_metadata_to_bigint.rb
new file mode 100644
index 00000000000..6dc840e8790
--- /dev/null
+++ b/db/migrate/20231027052949_initialize_conversion_of_system_note_metadata_to_bigint.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfSystemNoteMetadataToBigint < Gitlab::Database::Migration[2.2]
+ disable_ddl_transaction!
+
+ TABLE = :system_note_metadata
+ COLUMNS = %i[id]
+
+ milestone '16.6'
+
+ def up
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/migrate/20231027064352_add_service_access_tokens_expiration_application_setting.rb b/db/migrate/20231027064352_add_service_access_tokens_expiration_application_setting.rb
new file mode 100644
index 00000000000..6ef85a353fb
--- /dev/null
+++ b/db/migrate/20231027064352_add_service_access_tokens_expiration_application_setting.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddServiceAccessTokensExpirationApplicationSetting < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ enable_lock_retries!
+
+ def change
+ add_column :application_settings, :service_access_tokens_expiration_enforced, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20231027065205_add_service_access_tokens_expiration_namespace_setting.rb b/db/migrate/20231027065205_add_service_access_tokens_expiration_namespace_setting.rb
new file mode 100644
index 00000000000..86df338c416
--- /dev/null
+++ b/db/migrate/20231027065205_add_service_access_tokens_expiration_namespace_setting.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddServiceAccessTokensExpirationNamespaceSetting < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :service_access_tokens_expiration_enforced, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20231027084327_change_personal_access_tokens_remove_not_null_expires_at.rb b/db/migrate/20231027084327_change_personal_access_tokens_remove_not_null_expires_at.rb
new file mode 100644
index 00000000000..0f7e3d53707
--- /dev/null
+++ b/db/migrate/20231027084327_change_personal_access_tokens_remove_not_null_expires_at.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ChangePersonalAccessTokensRemoveNotNullExpiresAt < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'check_b8d60815eb'
+
+ def up
+ remove_not_null_constraint :personal_access_tokens, :expires_at
+ end
+
+ def down
+ add_not_null_constraint :personal_access_tokens, :expires_at, validate: false, constraint_name: CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20231030051837_add_project_id_to_packages_tags.rb b/db/migrate/20231030051837_add_project_id_to_packages_tags.rb
new file mode 100644
index 00000000000..b27e15cb648
--- /dev/null
+++ b/db/migrate/20231030051837_add_project_id_to_packages_tags.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddProjectIdToPackagesTags < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ enable_lock_retries!
+
+ def change
+ add_column :packages_tags, :project_id, :bigint
+ end
+end
diff --git a/db/migrate/20231030051838_add_index_to_packages_tags_project_id.rb b/db/migrate/20231030051838_add_index_to_packages_tags_project_id.rb
new file mode 100644
index 00000000000..17512137fff
--- /dev/null
+++ b/db/migrate/20231030051838_add_index_to_packages_tags_project_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToPackagesTagsProjectId < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+ INDEX_NAME = :index_packages_tags_on_project_id
+
+ def up
+ add_concurrent_index :packages_tags, :project_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name(:packages_tags, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20231030051839_add_foreign_key_to_packages_tags_project_id.rb b/db/migrate/20231030051839_add_foreign_key_to_packages_tags_project_id.rb
new file mode 100644
index 00000000000..6e3d6161582
--- /dev/null
+++ b/db/migrate/20231030051839_add_foreign_key_to_packages_tags_project_id.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToPackagesTagsProjectId < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :packages_tags, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :packages_tags, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20231030205639_update_default_package_metadata_purl_types.rb b/db/migrate/20231030205639_update_default_package_metadata_purl_types.rb
new file mode 100644
index 00000000000..1e2f1ccb578
--- /dev/null
+++ b/db/migrate/20231030205639_update_default_package_metadata_purl_types.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class UpdateDefaultPackageMetadataPurlTypes < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ disable_ddl_transaction!
+
+ PARTIALLY_ENABLED_SYNC = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].freeze
+ FULLY_ENABLED_SYNC = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13].freeze
+
+ def change
+ change_column_default :application_settings, :package_metadata_purl_types,
+ from: PARTIALLY_ENABLED_SYNC, to: FULLY_ENABLED_SYNC
+ end
+end
diff --git a/db/migrate/20231030205756_index_user_details_on_enterprise_group_id_and_user_id.rb b/db/migrate/20231030205756_index_user_details_on_enterprise_group_id_and_user_id.rb
new file mode 100644
index 00000000000..a993944e152
--- /dev/null
+++ b/db/migrate/20231030205756_index_user_details_on_enterprise_group_id_and_user_id.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class IndexUserDetailsOnEnterpriseGroupIdAndUserId < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_user_details_on_enterprise_group_id_and_user_id'
+ INDEX_NAME_TO_REMOVE = 'index_user_details_on_enterprise_group_id'
+
+ def up
+ add_concurrent_index(:user_details, [:enterprise_group_id, :user_id], name: INDEX_NAME)
+
+ remove_concurrent_index_by_name :user_details, INDEX_NAME_TO_REMOVE
+ end
+
+ def down
+ remove_concurrent_index_by_name :user_details, INDEX_NAME
+
+ add_concurrent_index :user_details, :enterprise_group_id, name: INDEX_NAME_TO_REMOVE
+ end
+end
diff --git a/db/migrate/20231031141439_add_smtp_authentication_to_service_desk_custom_email_credentials.rb b/db/migrate/20231031141439_add_smtp_authentication_to_service_desk_custom_email_credentials.rb
new file mode 100644
index 00000000000..e15e500af90
--- /dev/null
+++ b/db/migrate/20231031141439_add_smtp_authentication_to_service_desk_custom_email_credentials.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddSmtpAuthenticationToServiceDeskCustomEmailCredentials < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ def change
+ add_column :service_desk_custom_email_credentials, :smtp_authentication, :integer,
+ limit: 2, null: true, default: nil
+ end
+end
diff --git a/db/migrate/20231031200433_add_framework_fk_to_compliance_framework_security_policies.rb b/db/migrate/20231031200433_add_framework_fk_to_compliance_framework_security_policies.rb
new file mode 100644
index 00000000000..bb7fa924d15
--- /dev/null
+++ b/db/migrate/20231031200433_add_framework_fk_to_compliance_framework_security_policies.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddFrameworkFkToComplianceFrameworkSecurityPolicies < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :compliance_framework_security_policies,
+ :compliance_management_frameworks,
+ column: :framework_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :compliance_framework_security_policies, column: :framework_id
+ end
+ end
+end
diff --git a/db/migrate/20231031200645_add_policy_configuration_fk_to_compliance_framework_security_policies.rb b/db/migrate/20231031200645_add_policy_configuration_fk_to_compliance_framework_security_policies.rb
new file mode 100644
index 00000000000..cf6419c5128
--- /dev/null
+++ b/db/migrate/20231031200645_add_policy_configuration_fk_to_compliance_framework_security_policies.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddPolicyConfigurationFkToComplianceFrameworkSecurityPolicies < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :compliance_framework_security_policies,
+ :security_orchestration_policy_configurations,
+ column: :policy_configuration_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :compliance_framework_security_policies, column: :policy_configuration_id
+ end
+ end
+end
diff --git a/db/migrate/20231102142553_add_zoekt_nodes.rb b/db/migrate/20231102142553_add_zoekt_nodes.rb
new file mode 100644
index 00000000000..69a937ea4b0
--- /dev/null
+++ b/db/migrate/20231102142553_add_zoekt_nodes.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddZoektNodes < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ enable_lock_retries!
+
+ def change
+ create_table :zoekt_nodes do |t|
+ t.uuid :uuid, index: { unique: true }, null: false
+ t.bigint :used_bytes, null: false, default: 0
+ t.bigint :total_bytes, null: false, default: 0
+ t.datetime_with_timezone :last_seen_at, index: true, null: false, default: '1970-01-01'
+ t.timestamps_with_timezone
+ t.text :index_base_url, limit: 1024, index: { unique: true }, null: false
+ t.text :search_base_url, limit: 1024, index: { unique: true }, null: false
+ t.jsonb :metadata, default: {}, null: false
+ end
+ end
+end
diff --git a/db/migrate/20231102142554_migrate_zoekt_shards_to_zoekt_nodes.rb b/db/migrate/20231102142554_migrate_zoekt_shards_to_zoekt_nodes.rb
new file mode 100644
index 00000000000..23ae1231ae0
--- /dev/null
+++ b/db/migrate/20231102142554_migrate_zoekt_shards_to_zoekt_nodes.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class MigrateZoektShardsToZoektNodes < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ SELECTED_COLUMNS = %w[
+ index_base_url
+ search_base_url
+ uuid
+ used_bytes
+ total_bytes
+ metadata
+ last_seen_at
+ created_at
+ updated_at
+ ].join(',')
+
+ def up
+ connection.execute(<<~SQL)
+ INSERT INTO zoekt_nodes (#{SELECTED_COLUMNS})
+ SELECT #{SELECTED_COLUMNS}
+ FROM zoekt_shards
+ SQL
+ end
+
+ def down
+ connection.execute(<<~SQL)
+ DELETE FROM zoekt_nodes
+ SQL
+ end
+end
diff --git a/db/migrate/20231102142555_add_zoekt_node_id_to_indexed_namespaces.rb b/db/migrate/20231102142555_add_zoekt_node_id_to_indexed_namespaces.rb
new file mode 100644
index 00000000000..0b706cb0051
--- /dev/null
+++ b/db/migrate/20231102142555_add_zoekt_node_id_to_indexed_namespaces.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddZoektNodeIdToIndexedNamespaces < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ def up
+ add_column :zoekt_indexed_namespaces, :zoekt_node_id, :bigint
+ end
+
+ def down
+ remove_column :zoekt_indexed_namespaces, :zoekt_node_id
+ end
+end
diff --git a/db/migrate/20231102142565_add_zoekt_node_foreign_key_to_indexed_namespaces.rb b/db/migrate/20231102142565_add_zoekt_node_foreign_key_to_indexed_namespaces.rb
new file mode 100644
index 00000000000..957a2e751fa
--- /dev/null
+++ b/db/migrate/20231102142565_add_zoekt_node_foreign_key_to_indexed_namespaces.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddZoektNodeForeignKeyToIndexedNamespaces < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_zoekt_node_and_namespace'
+
+ def up
+ add_concurrent_foreign_key :zoekt_indexed_namespaces, :zoekt_nodes, column: :zoekt_node_id, on_delete: :cascade
+ add_concurrent_index :zoekt_indexed_namespaces, [:zoekt_node_id, :namespace_id], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :zoekt_indexed_namespaces, [:zoekt_node_id, :namespace_id], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20231103162825_add_wolfi_purl_type_to_package_metadata_purl_types.rb b/db/migrate/20231103162825_add_wolfi_purl_type_to_package_metadata_purl_types.rb
new file mode 100644
index 00000000000..bdbe8aa3a63
--- /dev/null
+++ b/db/migrate/20231103162825_add_wolfi_purl_type_to_package_metadata_purl_types.rb
@@ -0,0 +1,31 @@
+# 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 AddWolfiPurlTypeToPackageMetadataPurlTypes < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class ApplicationSetting < MigrationRecord
+ end
+
+ WOLFI_PURL_TYPE = 13
+
+ def up
+ application_setting = ApplicationSetting.last
+ return unless application_setting
+
+ application_setting.package_metadata_purl_types |= [WOLFI_PURL_TYPE]
+ application_setting.save
+ end
+
+ def down
+ application_setting = ApplicationSetting.last
+ return unless application_setting
+
+ application_setting.package_metadata_purl_types.delete(WOLFI_PURL_TYPE)
+ application_setting.save
+ end
+end
diff --git a/db/migrate/20231103195309_remove_deprecated_package_metadata_sync_worker.rb b/db/migrate/20231103195309_remove_deprecated_package_metadata_sync_worker.rb
new file mode 100644
index 00000000000..ae461d21799
--- /dev/null
+++ b/db/migrate/20231103195309_remove_deprecated_package_metadata_sync_worker.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveDeprecatedPackageMetadataSyncWorker < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ DEPRECATED_JOB_CLASSES = %w[PackageMetadata::SyncWorker]
+
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+end
diff --git a/db/migrate/20231103223224_backfill_zoekt_node_id_on_indexed_namespaces.rb b/db/migrate/20231103223224_backfill_zoekt_node_id_on_indexed_namespaces.rb
new file mode 100644
index 00000000000..7d6bb25f832
--- /dev/null
+++ b/db/migrate/20231103223224_backfill_zoekt_node_id_on_indexed_namespaces.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class BackfillZoektNodeIdOnIndexedNamespaces < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ sql = <<-SQL
+ UPDATE zoekt_indexed_namespaces
+ SET zoekt_node_id = (SELECT id FROM zoekt_nodes ORDER BY created_at DESC LIMIT 1)
+ SQL
+
+ execute(sql)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20231106145853_add_product_analytics_enabled_to_namespace_settings.rb b/db/migrate/20231106145853_add_product_analytics_enabled_to_namespace_settings.rb
new file mode 100644
index 00000000000..45b617be6ca
--- /dev/null
+++ b/db/migrate/20231106145853_add_product_analytics_enabled_to_namespace_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProductAnalyticsEnabledToNamespaceSettings < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ def change
+ add_column :namespace_settings, :product_analytics_enabled, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20231106212340_add_visibility_level_to_catalog_resources.rb b/db/migrate/20231106212340_add_visibility_level_to_catalog_resources.rb
new file mode 100644
index 00000000000..46150396c1e
--- /dev/null
+++ b/db/migrate/20231106212340_add_visibility_level_to_catalog_resources.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddVisibilityLevelToCatalogResources < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ enable_lock_retries!
+
+ def change
+ # This column must match the settings of `visibility_level` in the `projects` table.
+ # Backfill will be done as part of https://gitlab.com/gitlab-org/gitlab/-/issues/429056.
+ add_column :catalog_resources, :visibility_level, :integer, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20231107062104_add_network_policy_egress_to_agent.rb b/db/migrate/20231107062104_add_network_policy_egress_to_agent.rb
new file mode 100644
index 00000000000..c7f9da1831c
--- /dev/null
+++ b/db/migrate/20231107062104_add_network_policy_egress_to_agent.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddNetworkPolicyEgressToAgent < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ NETWORK_POLICY_EGRESS_DEFAULT = [{
+ allow: "0.0.0.0/0",
+ except: [
+ - "10.0.0.0/8",
+ - "172.16.0.0/12",
+ - "192.168.0.0/16"
+ ]
+ }]
+
+ def change
+ add_column :remote_development_agent_configs,
+ :network_policy_egress,
+ :jsonb,
+ null: false,
+ default: NETWORK_POLICY_EGRESS_DEFAULT
+ end
+end
diff --git a/db/migrate/20231107071201_add_project_authorizations_recalculated_at_to_user_details.rb b/db/migrate/20231107071201_add_project_authorizations_recalculated_at_to_user_details.rb
new file mode 100644
index 00000000000..c7f0ca83695
--- /dev/null
+++ b/db/migrate/20231107071201_add_project_authorizations_recalculated_at_to_user_details.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddProjectAuthorizationsRecalculatedAtToUserDetails < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ enable_lock_retries!
+
+ def change
+ add_column :user_details, :project_authorizations_recalculated_at, :datetime_with_timezone,
+ default: '2010-01-01', null: false
+ end
+end
diff --git a/db/migrate/20231107205734_add_update_namespace_name_to_application_settings.rb b/db/migrate/20231107205734_add_update_namespace_name_to_application_settings.rb
new file mode 100644
index 00000000000..a812166ed9d
--- /dev/null
+++ b/db/migrate/20231107205734_add_update_namespace_name_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddUpdateNamespaceNameToApplicationSettings < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ def change
+ add_column :application_settings, :update_namespace_name_rate_limit, :smallint, default: 120, null: false
+ end
+end
diff --git a/db/migrate/20231108072342_add_display_time_format_preference.rb b/db/migrate/20231108072342_add_display_time_format_preference.rb
new file mode 100644
index 00000000000..2f3773f73ef
--- /dev/null
+++ b/db/migrate/20231108072342_add_display_time_format_preference.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddDisplayTimeFormatPreference < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+ enable_lock_retries!
+
+ def change
+ add_column :user_preferences, :time_display_format, :integer, limit: 2, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb b/db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb
new file mode 100644
index 00000000000..06e0a7fc000
--- /dev/null
+++ b/db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddAllowProjectCreationForGuestAndBelowToApplicationSettings < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ def change
+ add_column(:application_settings, :allow_project_creation_for_guest_and_below, :boolean, default: true, null: false)
+ end
+end
diff --git a/db/migrate/20231109133153_drop_idx_namespaces_on_ldap_sync_last_successful_update_at_for_gitlab.rb b/db/migrate/20231109133153_drop_idx_namespaces_on_ldap_sync_last_successful_update_at_for_gitlab.rb
new file mode 100644
index 00000000000..1d171e3285c
--- /dev/null
+++ b/db/migrate/20231109133153_drop_idx_namespaces_on_ldap_sync_last_successful_update_at_for_gitlab.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class DropIdxNamespacesOnLdapSyncLastSuccessfulUpdateAtForGitlab < Gitlab::Database::Migration[2.2]
+ milestone '16.6'
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = :namespaces
+ INDEX_NAME = :index_namespaces_on_ldap_sync_last_successful_update_at
+
+ def up
+ return unless should_run?
+
+ remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
+ end
+
+ def down
+ return unless should_run?
+
+ add_concurrent_index TABLE_NAME, :ldap_sync_last_successful_update_at, name: INDEX_NAME
+ end
+
+ private
+
+ def should_run?
+ Gitlab.com_except_jh?
+ end
+end