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/20220406193806_add_maven_package_requests_forwarding_to_application_settings.rb13
-rw-r--r--db/migrate/20220603125200_add_show_diff_preview_in_email_to_namespace_settings.rb9
-rw-r--r--db/migrate/20220711142148_add_invitation_flow_enforcement_to_application_settings.rb10
-rw-r--r--db/migrate/20220726171440_create_ghost_user_migrations.rb12
-rw-r--r--db/migrate/20220726171450_add_user_fk_to_ghost_user_migrations.rb15
-rw-r--r--db/migrate/20220803004853_add_auto_ban_user_to_namespace_settings.rb10
-rw-r--r--db/migrate/20220803235114_add_auto_ban_user_to_application_settings.rb8
-rw-r--r--db/migrate/20220815152905_create_vulnerability_advisories.rb25
-rw-r--r--db/migrate/20220816135816_create_sbom_vulnerable_component_versions.rb18
-rw-r--r--db/migrate/20220817122907_re_add_show_diff_preview_in_email_to_project_settings.rb9
-rw-r--r--db/migrate/20220818095225_add_max_pages_custom_domains_per_project.rb20
-rw-r--r--db/migrate/20220818132108_add_deleted_on_to_ml_experiments.rb7
-rw-r--r--db/migrate/20220819153725_add_vulnerability_advisory_foreign_key_to_sbom_vulnerable_component_versions.rb19
-rw-r--r--db/migrate/20220819162852_add_sbom_component_version_foreign_key_to_sbom_vulnerable_component_versions.rb19
-rw-r--r--db/migrate/20220822102651_add_namespace_id_to_broadcast_message.rb9
-rw-r--r--db/migrate/20220822103638_add_index_and_foreign_key_to_broadcast_message.rb17
-rw-r--r--db/migrate/20220824175648_limit_namespaces_sync_triggers_to_traversal_ids_update.rb35
-rw-r--r--db/migrate/20220824194103_remove_existing_work_item_type_backfill_migrations.rb22
-rw-r--r--db/migrate/20220825105631_add_cube_api_key_to_application_settings.rb11
-rw-r--r--db/migrate/20220825134827_remove_not_null_constraint_for_confidence_columns.rb15
-rw-r--r--db/migrate/20220828094411_add_rpm_max_file_size_to_plan_limits.rb9
-rw-r--r--db/migrate/20220828131848_create_packages_rpm_metadata.rb30
-rw-r--r--db/migrate/20220829183356_replace_index_on_credit_card_validations.rb20
-rw-r--r--db/migrate/20220830082928_add_text_limit_to_cube_api_base_url.rb13
-rw-r--r--db/migrate/20220830114228_create_dora_configuration_table.rb16
-rw-r--r--db/migrate/20220831182105_add_constraints_view.rb32
-rw-r--r--db/migrate/20220901035722_add_temp_project_member_index.rb16
-rw-r--r--db/migrate/20220901124637_add_last_downloaded_at_to_packages.rb7
-rw-r--r--db/migrate/20220901131828_add_environments_project_name_lower_pattern_ops_index.rb15
-rw-r--r--db/migrate/20220901212027_add_merge_request_id_to_environments.rb7
-rw-r--r--db/migrate/20220902065314_create_ci_partitions.rb9
-rw-r--r--db/migrate/20220902065316_create_default_partition_record.rb21
-rw-r--r--db/migrate/20220902065317_add_partition_id_to_ci_builds.rb11
-rw-r--r--db/migrate/20220902065558_add_partition_id_to_ci_builds_metadata.rb9
-rw-r--r--db/migrate/20220902065611_add_partition_id_to_ci_job_artifacts.rb9
-rw-r--r--db/migrate/20220902065623_add_partition_id_to_ci_pipelines.rb9
-rw-r--r--db/migrate/20220902065635_add_partition_id_to_ci_stages.rb9
-rw-r--r--db/migrate/20220902065647_add_partition_id_to_ci_pipeline_variables.rb9
-rw-r--r--db/migrate/20220902165931_index_evironments_on_merge_request_id.rb15
-rw-r--r--db/migrate/20220902170131_add_fk_constraint_to_environments_merge_request_id.rb13
-rw-r--r--db/migrate/20220906093857_add_column_branch_filter_strategy_to_web_hooks.rb7
-rw-r--r--db/migrate/20220906155105_add_start_time_and_end_time_and_status_to_ml_candidates.rb9
-rw-r--r--db/migrate/20220906204832_add_locked_to_ci_pipeline_artifacts.rb20
-rw-r--r--db/migrate/20220907124320_add_internal_to_notes.rb9
-rw-r--r--db/migrate/20220909091410_add_dismissal_reason_to_vulnerability_state_transitions.rb7
-rw-r--r--db/migrate/20220909094752_add_free_user_cap_over_limt_notified_at_to_namespace_details.rb20
-rw-r--r--db/migrate/20220909113809_add_environments_project_name_lower_pattern_ops_state_index.rb15
-rw-r--r--db/migrate/20220912180807_add_epoch_column_to_rpm_metadata.rb7
-rw-r--r--db/migrate/20220913082930_rename_iterations_cadences_last_run_date_to_next_run_date.rb13
-rw-r--r--db/migrate/20220914005141_change_namespace_id_not_null_in_members.rb13
-rw-r--r--db/migrate/20220914010233_change_members_namespace_foreign_key_on_delete_constraint.rb30
-rw-r--r--db/migrate/20220915140802_create_merge_request_predictions.rb20
52 files changed, 752 insertions, 0 deletions
diff --git a/db/migrate/20220406193806_add_maven_package_requests_forwarding_to_application_settings.rb b/db/migrate/20220406193806_add_maven_package_requests_forwarding_to_application_settings.rb
new file mode 100644
index 00000000000..60b2efd3e9c
--- /dev/null
+++ b/db/migrate/20220406193806_add_maven_package_requests_forwarding_to_application_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddMavenPackageRequestsForwardingToApplicationSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ add_column(:application_settings, :maven_package_requests_forwarding, :boolean, default: true, null: false)
+ end
+
+ def down
+ remove_column(:application_settings, :maven_package_requests_forwarding)
+ end
+end
diff --git a/db/migrate/20220603125200_add_show_diff_preview_in_email_to_namespace_settings.rb b/db/migrate/20220603125200_add_show_diff_preview_in_email_to_namespace_settings.rb
new file mode 100644
index 00000000000..ad32d589840
--- /dev/null
+++ b/db/migrate/20220603125200_add_show_diff_preview_in_email_to_namespace_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddShowDiffPreviewInEmailToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :show_diff_preview_in_email, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20220711142148_add_invitation_flow_enforcement_to_application_settings.rb b/db/migrate/20220711142148_add_invitation_flow_enforcement_to_application_settings.rb
new file mode 100644
index 00000000000..f323faf9aa1
--- /dev/null
+++ b/db/migrate/20220711142148_add_invitation_flow_enforcement_to_application_settings.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddInvitationFlowEnforcementToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :invitation_flow_enforcement,
+ :boolean,
+ default: false,
+ null: false
+ end
+end
diff --git a/db/migrate/20220726171440_create_ghost_user_migrations.rb b/db/migrate/20220726171440_create_ghost_user_migrations.rb
new file mode 100644
index 00000000000..c64ca4f7765
--- /dev/null
+++ b/db/migrate/20220726171440_create_ghost_user_migrations.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateGhostUserMigrations < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :ghost_user_migrations do |t|
+ t.bigint :user_id, index: { unique: true }, null: false
+ t.bigint :initiator_user_id
+ t.timestamps_with_timezone null: false
+ t.boolean :hard_delete, default: false, null: false
+ end
+ end
+end
diff --git a/db/migrate/20220726171450_add_user_fk_to_ghost_user_migrations.rb b/db/migrate/20220726171450_add_user_fk_to_ghost_user_migrations.rb
new file mode 100644
index 00000000000..5904d132d1b
--- /dev/null
+++ b/db/migrate/20220726171450_add_user_fk_to_ghost_user_migrations.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUserFkToGhostUserMigrations < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ghost_user_migrations, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :ghost_user_migrations, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20220803004853_add_auto_ban_user_to_namespace_settings.rb b/db/migrate/20220803004853_add_auto_ban_user_to_namespace_settings.rb
new file mode 100644
index 00000000000..6e03177ce7a
--- /dev/null
+++ b/db/migrate/20220803004853_add_auto_ban_user_to_namespace_settings.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddAutoBanUserToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :auto_ban_user_on_excessive_projects_download, :boolean,
+ default: false, null: false
+ end
+end
diff --git a/db/migrate/20220803235114_add_auto_ban_user_to_application_settings.rb b/db/migrate/20220803235114_add_auto_ban_user_to_application_settings.rb
new file mode 100644
index 00000000000..3b57c340921
--- /dev/null
+++ b/db/migrate/20220803235114_add_auto_ban_user_to_application_settings.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddAutoBanUserToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :auto_ban_user_on_excessive_projects_download, :boolean,
+ default: false, null: false
+ end
+end
diff --git a/db/migrate/20220815152905_create_vulnerability_advisories.rb b/db/migrate/20220815152905_create_vulnerability_advisories.rb
new file mode 100644
index 00000000000..f01a17c6352
--- /dev/null
+++ b/db/migrate/20220815152905_create_vulnerability_advisories.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityAdvisories < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :vulnerability_advisories, id: false do |t|
+ t.uuid :uuid, null: false
+ t.timestamps_with_timezone null: false
+ t.primary_key :id
+ t.date :created_date, null: false
+ t.date :published_date, null: false
+ t.text :description, limit: 2048
+ t.text :title, limit: 2048
+ t.text :component_name, limit: 2048
+ t.text :solution, limit: 2048
+ t.text :not_impacted, limit: 2048
+ t.text :cvss_v2, limit: 128
+ t.text :cvss_v3, limit: 128
+ t.text :affected_range, limit: 32
+ t.text :identifiers, array: true, default: []
+ t.text :fixed_versions, array: true, default: []
+ t.text :urls, array: true, default: []
+ t.text :links, array: true, default: []
+ end
+ end
+end
diff --git a/db/migrate/20220816135816_create_sbom_vulnerable_component_versions.rb b/db/migrate/20220816135816_create_sbom_vulnerable_component_versions.rb
new file mode 100644
index 00000000000..6f50376f6fa
--- /dev/null
+++ b/db/migrate/20220816135816_create_sbom_vulnerable_component_versions.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateSbomVulnerableComponentVersions < Gitlab::Database::Migration[2.0]
+ ADVISORY_INDEX_NAME = "index_vulnerable_component_versions_on_vulnerability_advisory"
+ SBOM_COMPONENT_INDEX_NAME = "index_vulnerable_component_versions_on_sbom_component_version"
+
+ def change
+ create_table :sbom_vulnerable_component_versions do |t|
+ t.references :vulnerability_advisory,
+ index: { name: ADVISORY_INDEX_NAME }
+
+ t.references :sbom_component_version,
+ index: { name: SBOM_COMPONENT_INDEX_NAME }
+
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/migrate/20220817122907_re_add_show_diff_preview_in_email_to_project_settings.rb b/db/migrate/20220817122907_re_add_show_diff_preview_in_email_to_project_settings.rb
new file mode 100644
index 00000000000..bb5649e3a99
--- /dev/null
+++ b/db/migrate/20220817122907_re_add_show_diff_preview_in_email_to_project_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class ReAddShowDiffPreviewInEmailToProjectSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :project_settings, :show_diff_preview_in_email, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20220818095225_add_max_pages_custom_domains_per_project.rb b/db/migrate/20220818095225_add_max_pages_custom_domains_per_project.rb
new file mode 100644
index 00000000000..c5e1f5aede6
--- /dev/null
+++ b/db/migrate/20220818095225_add_max_pages_custom_domains_per_project.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddMaxPagesCustomDomainsPerProject < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = "app_settings_max_pages_custom_domains_per_project_check"
+
+ def up
+ return if column_exists?(:application_settings, :max_pages_custom_domains_per_project)
+
+ add_column :application_settings, :max_pages_custom_domains_per_project, :integer, null: false, default: 0
+ add_check_constraint :application_settings, "max_pages_custom_domains_per_project >= 0", CONSTRAINT_NAME
+ end
+
+ def down
+ return unless column_exists?(:application_settings, :max_pages_custom_domains_per_project)
+
+ remove_column :application_settings, :max_pages_custom_domains_per_project
+ end
+end
diff --git a/db/migrate/20220818132108_add_deleted_on_to_ml_experiments.rb b/db/migrate/20220818132108_add_deleted_on_to_ml_experiments.rb
new file mode 100644
index 00000000000..e6ba9f78553
--- /dev/null
+++ b/db/migrate/20220818132108_add_deleted_on_to_ml_experiments.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddDeletedOnToMlExperiments < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :ml_experiments, :deleted_on, :datetime_with_timezone, index: true
+ end
+end
diff --git a/db/migrate/20220819153725_add_vulnerability_advisory_foreign_key_to_sbom_vulnerable_component_versions.rb b/db/migrate/20220819153725_add_vulnerability_advisory_foreign_key_to_sbom_vulnerable_component_versions.rb
new file mode 100644
index 00000000000..7f0c817875f
--- /dev/null
+++ b/db/migrate/20220819153725_add_vulnerability_advisory_foreign_key_to_sbom_vulnerable_component_versions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddVulnerabilityAdvisoryForeignKeyToSbomVulnerableComponentVersions < Gitlab::Database::Migration[2.0]
+ SOURCE_TABLE = :sbom_vulnerable_component_versions
+ TARGET_TABLE = :vulnerability_advisories
+ COLUMN = :vulnerability_advisory_id
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key SOURCE_TABLE, TARGET_TABLE, column: COLUMN, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key SOURCE_TABLE, column: COLUMN
+ end
+ end
+end
diff --git a/db/migrate/20220819162852_add_sbom_component_version_foreign_key_to_sbom_vulnerable_component_versions.rb b/db/migrate/20220819162852_add_sbom_component_version_foreign_key_to_sbom_vulnerable_component_versions.rb
new file mode 100644
index 00000000000..a4f2005693c
--- /dev/null
+++ b/db/migrate/20220819162852_add_sbom_component_version_foreign_key_to_sbom_vulnerable_component_versions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddSbomComponentVersionForeignKeyToSbomVulnerableComponentVersions < Gitlab::Database::Migration[2.0]
+ SOURCE_TABLE = :sbom_vulnerable_component_versions
+ TARGET_TABLE = :sbom_component_versions
+ COLUMN = :sbom_component_version_id
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key SOURCE_TABLE, TARGET_TABLE, column: COLUMN, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key SOURCE_TABLE, column: COLUMN
+ end
+ end
+end
diff --git a/db/migrate/20220822102651_add_namespace_id_to_broadcast_message.rb b/db/migrate/20220822102651_add_namespace_id_to_broadcast_message.rb
new file mode 100644
index 00000000000..5413f447366
--- /dev/null
+++ b/db/migrate/20220822102651_add_namespace_id_to_broadcast_message.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNamespaceIdToBroadcastMessage < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :broadcast_messages, :namespace_id, :bigint
+ end
+end
diff --git a/db/migrate/20220822103638_add_index_and_foreign_key_to_broadcast_message.rb b/db/migrate/20220822103638_add_index_and_foreign_key_to_broadcast_message.rb
new file mode 100644
index 00000000000..a577e5ad157
--- /dev/null
+++ b/db/migrate/20220822103638_add_index_and_foreign_key_to_broadcast_message.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexAndForeignKeyToBroadcastMessage < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_broadcast_messages_on_namespace_id'
+
+ def up
+ add_concurrent_index :broadcast_messages, :namespace_id, name: INDEX_NAME
+ add_concurrent_foreign_key :broadcast_messages, :namespaces, column: :namespace_id, on_delete: :cascade
+ end
+
+ def down
+ remove_foreign_key_if_exists :broadcast_messages, column: :namespace_id
+ remove_concurrent_index_by_name :broadcast_messages, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220824175648_limit_namespaces_sync_triggers_to_traversal_ids_update.rb b/db/migrate/20220824175648_limit_namespaces_sync_triggers_to_traversal_ids_update.rb
new file mode 100644
index 00000000000..142744b5493
--- /dev/null
+++ b/db/migrate/20220824175648_limit_namespaces_sync_triggers_to_traversal_ids_update.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class LimitNamespacesSyncTriggersToTraversalIdsUpdate < Gitlab::Database::Migration[2.0]
+ include Gitlab::Database::SchemaHelpers
+
+ enable_lock_retries!
+
+ TABLE_NAME = 'namespaces'
+ EVENT_TABLE_NAME = 'namespaces_sync_events'
+ FUNCTION_NAME = 'insert_namespaces_sync_event'
+ OLD_TRIGGER_ON_INSERT = 'trigger_namespaces_parent_id_on_insert'
+ OLD_TRIGGER_ON_UPDATE = 'trigger_namespaces_parent_id_on_update'
+ NEW_TRIGGER_ON_UPDATE = 'trigger_namespaces_traversal_ids_on_update'
+
+ def up
+ create_trigger(TABLE_NAME, NEW_TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do
+ <<~SQL
+ WHEN (OLD.traversal_ids IS DISTINCT FROM NEW.traversal_ids)
+ SQL
+ end
+ drop_trigger(TABLE_NAME, OLD_TRIGGER_ON_UPDATE)
+ drop_trigger(TABLE_NAME, OLD_TRIGGER_ON_INSERT)
+ end
+
+ # Revert both triggers to the version defined in db/migrate/20211011141242_create_namespaces_sync_trigger.rb
+ def down
+ create_trigger(TABLE_NAME, OLD_TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT')
+ create_trigger(TABLE_NAME, OLD_TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do
+ <<~SQL
+ WHEN (OLD.parent_id IS DISTINCT FROM NEW.parent_id)
+ SQL
+ end
+ drop_trigger(TABLE_NAME, NEW_TRIGGER_ON_UPDATE)
+ end
+end
diff --git a/db/migrate/20220824194103_remove_existing_work_item_type_backfill_migrations.rb b/db/migrate/20220824194103_remove_existing_work_item_type_backfill_migrations.rb
new file mode 100644
index 00000000000..ed970e30099
--- /dev/null
+++ b/db/migrate/20220824194103_remove_existing_work_item_type_backfill_migrations.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class RemoveExistingWorkItemTypeBackfillMigrations < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ JOB_CLASS_NAME = 'BackfillWorkItemTypeIdForIssues'
+
+ class BatchedMigration < MigrationRecord
+ self.table_name = 'batched_background_migrations'
+ end
+
+ def up
+ # cleaning up so we can remove a custom batching strategy that is no longer necessary
+ # some environments might already have this background migrations scheduled and probably completed
+ BatchedMigration.where(job_class_name: JOB_CLASS_NAME).delete_all
+ end
+
+ def down
+ # no-op
+ # we will reschedule this migration in the future, no need to add back here
+ end
+end
diff --git a/db/migrate/20220825105631_add_cube_api_key_to_application_settings.rb b/db/migrate/20220825105631_add_cube_api_key_to_application_settings.rb
new file mode 100644
index 00000000000..6ee5ad52315
--- /dev/null
+++ b/db/migrate/20220825105631_add_cube_api_key_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddCubeApiKeyToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ # rubocop:disable Migration/AddLimitToTextColumns
+ add_column :application_settings, :cube_api_base_url, :text
+ add_column :application_settings, :encrypted_cube_api_key, :binary
+ add_column :application_settings, :encrypted_cube_api_key_iv, :binary
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+end
diff --git a/db/migrate/20220825134827_remove_not_null_constraint_for_confidence_columns.rb b/db/migrate/20220825134827_remove_not_null_constraint_for_confidence_columns.rb
new file mode 100644
index 00000000000..e41d93ebf8b
--- /dev/null
+++ b/db/migrate/20220825134827_remove_not_null_constraint_for_confidence_columns.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveNotNullConstraintForConfidenceColumns < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ change_column_null :vulnerabilities, :confidence, true
+ change_column_null :vulnerability_occurrences, :confidence, true
+ change_column_null :security_findings, :confidence, true
+ end
+
+ def down
+ # no-op: We can not set `NOT NULL` constraint here as there can be NULL values already.
+ end
+end
diff --git a/db/migrate/20220828094411_add_rpm_max_file_size_to_plan_limits.rb b/db/migrate/20220828094411_add_rpm_max_file_size_to_plan_limits.rb
new file mode 100644
index 00000000000..32489fd5bce
--- /dev/null
+++ b/db/migrate/20220828094411_add_rpm_max_file_size_to_plan_limits.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRpmMaxFileSizeToPlanLimits < Gitlab::Database::Migration[2.0]
+ DOWNTIME = false
+
+ def change
+ add_column :plan_limits, :rpm_max_file_size, :bigint, default: 5.gigabytes, null: false
+ end
+end
diff --git a/db/migrate/20220828131848_create_packages_rpm_metadata.rb b/db/migrate/20220828131848_create_packages_rpm_metadata.rb
new file mode 100644
index 00000000000..bfaa441fc78
--- /dev/null
+++ b/db/migrate/20220828131848_create_packages_rpm_metadata.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class CreatePackagesRpmMetadata < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :packages_rpm_metadata, id: false do |t|
+ t.references :package,
+ primary_key: true,
+ default: nil,
+ index: true,
+ foreign_key: { to_table: :packages_packages, on_delete: :cascade },
+ type: :bigint
+ t.text :release, default: '1', null: false, limit: 128
+ t.text :summary, default: '', null: false, limit: 1000
+ t.text :description, default: '', null: false, limit: 5000
+ t.text :arch, default: '', null: false, limit: 255
+ t.text :license, null: true, limit: 1000
+ t.text :url, null: true, limit: 1000
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :packages_rpm_metadata
+ end
+ end
+end
diff --git a/db/migrate/20220829183356_replace_index_on_credit_card_validations.rb b/db/migrate/20220829183356_replace_index_on_credit_card_validations.rb
new file mode 100644
index 00000000000..05fa7f75feb
--- /dev/null
+++ b/db/migrate/20220829183356_replace_index_on_credit_card_validations.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ReplaceIndexOnCreditCardValidations < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ OLD_INDEX_NAME = 'index_user_credit_card_validations_meta_data_full_match'
+ NEW_INDEX_NAME = 'index_user_credit_card_validations_meta_data_full_match_lower'
+ OLD_FIELDS = [:holder_name, :expiration_date, :last_digits, :credit_card_validated_at]
+ NEW_FIELDS = 'lower(holder_name), expiration_date, last_digits, credit_card_validated_at'
+
+ def up
+ add_concurrent_index :user_credit_card_validations, NEW_FIELDS, name: NEW_INDEX_NAME
+ remove_concurrent_index :user_credit_card_validations, OLD_FIELDS, name: OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :user_credit_card_validations, OLD_FIELDS, name: OLD_INDEX_NAME
+ remove_concurrent_index :user_credit_card_validations, NEW_FIELDS, name: NEW_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220830082928_add_text_limit_to_cube_api_base_url.rb b/db/migrate/20220830082928_add_text_limit_to_cube_api_base_url.rb
new file mode 100644
index 00000000000..7bab796a47f
--- /dev/null
+++ b/db/migrate/20220830082928_add_text_limit_to_cube_api_base_url.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToCubeApiBaseUrl < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :application_settings, :cube_api_base_url, 512
+ end
+
+ def down
+ remove_text_limit :application_settings, :cube_api_base_url
+ end
+end
diff --git a/db/migrate/20220830114228_create_dora_configuration_table.rb b/db/migrate/20220830114228_create_dora_configuration_table.rb
new file mode 100644
index 00000000000..ee5960d14b6
--- /dev/null
+++ b/db/migrate/20220830114228_create_dora_configuration_table.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateDoraConfigurationTable < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ create_table :dora_configurations do |t|
+ t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.text :branches_for_lead_time_for_changes, null: false, array: true, default: []
+ end
+ end
+
+ def down
+ drop_table :dora_configurations
+ end
+end
diff --git a/db/migrate/20220831182105_add_constraints_view.rb b/db/migrate/20220831182105_add_constraints_view.rb
new file mode 100644
index 00000000000..03c183b6e9f
--- /dev/null
+++ b/db/migrate/20220831182105_add_constraints_view.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class AddConstraintsView < Gitlab::Database::Migration[2.0]
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE VIEW postgres_constraints
+ AS
+ SELECT
+ pg_constraint.oid AS oid,
+ pg_constraint.conname AS name,
+ pg_constraint.contype AS constraint_type,
+ pg_constraint.convalidated AS constraint_valid,
+ (SELECT array_agg(attname ORDER BY ordering)
+ FROM unnest(pg_constraint.conkey) WITH ORDINALITY attnums(attnum, ordering)
+ INNER JOIN pg_attribute ON pg_attribute.attnum = attnums.attnum AND pg_attribute.attrelid = pg_class.oid
+ ) AS column_names,
+ pg_namespace.nspname::text || '.'::text || pg_class.relname::text AS table_identifier,
+ -- pg_constraint reports a 0 oid rather than null if the constraint is not a partition child constraint.
+ nullif(pg_constraint.conparentid, 0) AS parent_constraint_oid,
+ pg_get_constraintdef(pg_constraint.oid) AS definition
+ FROM pg_constraint
+ INNER JOIN pg_class ON pg_constraint.conrelid = pg_class.oid
+ INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid;
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ DROP VIEW postgres_constraints;
+ SQL
+ end
+end
diff --git a/db/migrate/20220901035722_add_temp_project_member_index.rb b/db/migrate/20220901035722_add_temp_project_member_index.rb
new file mode 100644
index 00000000000..0765ef09b5c
--- /dev/null
+++ b/db/migrate/20220901035722_add_temp_project_member_index.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTempProjectMemberIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TABLE_NAME = :members
+ INDEX_NAME = 'index_project_members_on_id_temp'
+
+ def up
+ add_concurrent_index TABLE_NAME, :id, name: INDEX_NAME, where: "source_type = 'Project'"
+ end
+
+ def down
+ remove_concurrent_index TABLE_NAME, :id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220901124637_add_last_downloaded_at_to_packages.rb b/db/migrate/20220901124637_add_last_downloaded_at_to_packages.rb
new file mode 100644
index 00000000000..0172ab573ea
--- /dev/null
+++ b/db/migrate/20220901124637_add_last_downloaded_at_to_packages.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddLastDownloadedAtToPackages < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :packages_packages, :last_downloaded_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20220901131828_add_environments_project_name_lower_pattern_ops_index.rb b/db/migrate/20220901131828_add_environments_project_name_lower_pattern_ops_index.rb
new file mode 100644
index 00000000000..d8b7cd9be28
--- /dev/null
+++ b/db/migrate/20220901131828_add_environments_project_name_lower_pattern_ops_index.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddEnvironmentsProjectNameLowerPatternOpsIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_environments_on_project_name_varchar_pattern_ops'
+
+ def up
+ add_concurrent_index :environments, 'project_id, lower(name) varchar_pattern_ops', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :environments, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220901212027_add_merge_request_id_to_environments.rb b/db/migrate/20220901212027_add_merge_request_id_to_environments.rb
new file mode 100644
index 00000000000..4a230c737ae
--- /dev/null
+++ b/db/migrate/20220901212027_add_merge_request_id_to_environments.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddMergeRequestIdToEnvironments < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :environments, :merge_request_id, :bigint
+ end
+end
diff --git a/db/migrate/20220902065314_create_ci_partitions.rb b/db/migrate/20220902065314_create_ci_partitions.rb
new file mode 100644
index 00000000000..1a8a4f172f8
--- /dev/null
+++ b/db/migrate/20220902065314_create_ci_partitions.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class CreateCiPartitions < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :ci_partitions do |t|
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/migrate/20220902065316_create_default_partition_record.rb b/db/migrate/20220902065316_create_default_partition_record.rb
new file mode 100644
index 00000000000..6493fb23d4c
--- /dev/null
+++ b/db/migrate/20220902065316_create_default_partition_record.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreateDefaultPartitionRecord < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ def up
+ execute(<<~SQL)
+ INSERT INTO "ci_partitions" ("id", "created_at", "updated_at")
+ VALUES (100, now(), now());
+ SQL
+
+ reset_pk_sequence!('ci_partitions')
+ end
+
+ def down
+ execute(<<~SQL)
+ DELETE FROM "ci_partitions" WHERE "ci_partitions"."id" = 100;
+ SQL
+ end
+end
diff --git a/db/migrate/20220902065317_add_partition_id_to_ci_builds.rb b/db/migrate/20220902065317_add_partition_id_to_ci_builds.rb
new file mode 100644
index 00000000000..6257164b44e
--- /dev/null
+++ b/db/migrate/20220902065317_add_partition_id_to_ci_builds.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddPartitionIdToCiBuilds < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ # rubocop:disable Migration/AddColumnsToWideTables
+ def change
+ add_column :ci_builds, :partition_id, :bigint, default: 100, null: false
+ end
+ # rubocop:enable Migration/AddColumnsToWideTables
+end
diff --git a/db/migrate/20220902065558_add_partition_id_to_ci_builds_metadata.rb b/db/migrate/20220902065558_add_partition_id_to_ci_builds_metadata.rb
new file mode 100644
index 00000000000..e04ea99539f
--- /dev/null
+++ b/db/migrate/20220902065558_add_partition_id_to_ci_builds_metadata.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPartitionIdToCiBuildsMetadata < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_builds_metadata, :partition_id, :bigint, default: 100, null: false
+ end
+end
diff --git a/db/migrate/20220902065611_add_partition_id_to_ci_job_artifacts.rb b/db/migrate/20220902065611_add_partition_id_to_ci_job_artifacts.rb
new file mode 100644
index 00000000000..1d9eeb0330e
--- /dev/null
+++ b/db/migrate/20220902065611_add_partition_id_to_ci_job_artifacts.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPartitionIdToCiJobArtifacts < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_job_artifacts, :partition_id, :bigint, default: 100, null: false
+ end
+end
diff --git a/db/migrate/20220902065623_add_partition_id_to_ci_pipelines.rb b/db/migrate/20220902065623_add_partition_id_to_ci_pipelines.rb
new file mode 100644
index 00000000000..bb3e7c27ee8
--- /dev/null
+++ b/db/migrate/20220902065623_add_partition_id_to_ci_pipelines.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPartitionIdToCiPipelines < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_pipelines, :partition_id, :bigint, default: 100, null: false
+ end
+end
diff --git a/db/migrate/20220902065635_add_partition_id_to_ci_stages.rb b/db/migrate/20220902065635_add_partition_id_to_ci_stages.rb
new file mode 100644
index 00000000000..0ddbf491ee9
--- /dev/null
+++ b/db/migrate/20220902065635_add_partition_id_to_ci_stages.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPartitionIdToCiStages < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_stages, :partition_id, :bigint, default: 100, null: false
+ end
+end
diff --git a/db/migrate/20220902065647_add_partition_id_to_ci_pipeline_variables.rb b/db/migrate/20220902065647_add_partition_id_to_ci_pipeline_variables.rb
new file mode 100644
index 00000000000..14f17b371b4
--- /dev/null
+++ b/db/migrate/20220902065647_add_partition_id_to_ci_pipeline_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPartitionIdToCiPipelineVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_pipeline_variables, :partition_id, :bigint, default: 100, null: false
+ end
+end
diff --git a/db/migrate/20220902165931_index_evironments_on_merge_request_id.rb b/db/migrate/20220902165931_index_evironments_on_merge_request_id.rb
new file mode 100644
index 00000000000..9d9f84e94ee
--- /dev/null
+++ b/db/migrate/20220902165931_index_evironments_on_merge_request_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class IndexEvironmentsOnMergeRequestId < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_environments_on_merge_request_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :environments, :merge_request_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :environments, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220902170131_add_fk_constraint_to_environments_merge_request_id.rb b/db/migrate/20220902170131_add_fk_constraint_to_environments_merge_request_id.rb
new file mode 100644
index 00000000000..863aefe56fb
--- /dev/null
+++ b/db/migrate/20220902170131_add_fk_constraint_to_environments_merge_request_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddFkConstraintToEnvironmentsMergeRequestId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :environments, :merge_requests, column: :merge_request_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :environments, column: :merge_request_id
+ end
+end
diff --git a/db/migrate/20220906093857_add_column_branch_filter_strategy_to_web_hooks.rb b/db/migrate/20220906093857_add_column_branch_filter_strategy_to_web_hooks.rb
new file mode 100644
index 00000000000..739bedda9e0
--- /dev/null
+++ b/db/migrate/20220906093857_add_column_branch_filter_strategy_to_web_hooks.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddColumnBranchFilterStrategyToWebHooks < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :web_hooks, :branch_filter_strategy, :integer, null: false, default: 0, limit: 2
+ end
+end
diff --git a/db/migrate/20220906155105_add_start_time_and_end_time_and_status_to_ml_candidates.rb b/db/migrate/20220906155105_add_start_time_and_end_time_and_status_to_ml_candidates.rb
new file mode 100644
index 00000000000..68138881139
--- /dev/null
+++ b/db/migrate/20220906155105_add_start_time_and_end_time_and_status_to_ml_candidates.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddStartTimeAndEndTimeAndStatusToMlCandidates < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :ml_candidates, :start_time, :bigint
+ add_column :ml_candidates, :end_time, :bigint
+ add_column :ml_candidates, :status, :smallint, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20220906204832_add_locked_to_ci_pipeline_artifacts.rb b/db/migrate/20220906204832_add_locked_to_ci_pipeline_artifacts.rb
new file mode 100644
index 00000000000..dae4c560bb2
--- /dev/null
+++ b/db/migrate/20220906204832_add_locked_to_ci_pipeline_artifacts.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddLockedToCiPipelineArtifacts < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_pipeline_artifacts'
+ COLUMN_NAME = 'locked'
+
+ def up
+ with_lock_retries do
+ add_column TABLE_NAME, COLUMN_NAME, :smallint, default: 2
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column TABLE_NAME, COLUMN_NAME
+ end
+ end
+end
diff --git a/db/migrate/20220907124320_add_internal_to_notes.rb b/db/migrate/20220907124320_add_internal_to_notes.rb
new file mode 100644
index 00000000000..081914f7830
--- /dev/null
+++ b/db/migrate/20220907124320_add_internal_to_notes.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddInternalToNotes < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column(:notes, :internal, :boolean, default: false, null: false)
+ end
+end
diff --git a/db/migrate/20220909091410_add_dismissal_reason_to_vulnerability_state_transitions.rb b/db/migrate/20220909091410_add_dismissal_reason_to_vulnerability_state_transitions.rb
new file mode 100644
index 00000000000..01fcb3aa6e1
--- /dev/null
+++ b/db/migrate/20220909091410_add_dismissal_reason_to_vulnerability_state_transitions.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddDismissalReasonToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :vulnerability_state_transitions, :dismissal_reason, :smallint
+ end
+end
diff --git a/db/migrate/20220909094752_add_free_user_cap_over_limt_notified_at_to_namespace_details.rb b/db/migrate/20220909094752_add_free_user_cap_over_limt_notified_at_to_namespace_details.rb
new file mode 100644
index 00000000000..775705eae73
--- /dev/null
+++ b/db/migrate/20220909094752_add_free_user_cap_over_limt_notified_at_to_namespace_details.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddFreeUserCapOverLimtNotifiedAtToNamespaceDetails < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'namespace_details'
+ COLUMN_NAME = 'free_user_cap_over_limt_notified_at'
+
+ def up
+ with_lock_retries do
+ add_column(TABLE_NAME, COLUMN_NAME, :datetime_with_timezone)
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column TABLE_NAME, COLUMN_NAME
+ end
+ end
+end
diff --git a/db/migrate/20220909113809_add_environments_project_name_lower_pattern_ops_state_index.rb b/db/migrate/20220909113809_add_environments_project_name_lower_pattern_ops_state_index.rb
new file mode 100644
index 00000000000..870c809beb6
--- /dev/null
+++ b/db/migrate/20220909113809_add_environments_project_name_lower_pattern_ops_state_index.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddEnvironmentsProjectNameLowerPatternOpsStateIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_environments_on_project_name_varchar_pattern_ops_state'
+
+ def up
+ add_concurrent_index :environments, 'project_id, lower(name) varchar_pattern_ops, state', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :environments, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220912180807_add_epoch_column_to_rpm_metadata.rb b/db/migrate/20220912180807_add_epoch_column_to_rpm_metadata.rb
new file mode 100644
index 00000000000..842d917c8a3
--- /dev/null
+++ b/db/migrate/20220912180807_add_epoch_column_to_rpm_metadata.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddEpochColumnToRpmMetadata < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :packages_rpm_metadata, :epoch, :integer, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20220913082930_rename_iterations_cadences_last_run_date_to_next_run_date.rb b/db/migrate/20220913082930_rename_iterations_cadences_last_run_date_to_next_run_date.rb
new file mode 100644
index 00000000000..2adc4202b79
--- /dev/null
+++ b/db/migrate/20220913082930_rename_iterations_cadences_last_run_date_to_next_run_date.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameIterationsCadencesLastRunDateToNextRunDate < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :iterations_cadences, :last_run_date, :next_run_date
+ end
+
+ def down
+ undo_rename_column_concurrently :iterations_cadences, :last_run_date, :next_run_date
+ end
+end
diff --git a/db/migrate/20220914005141_change_namespace_id_not_null_in_members.rb b/db/migrate/20220914005141_change_namespace_id_not_null_in_members.rb
new file mode 100644
index 00000000000..250746b95b8
--- /dev/null
+++ b/db/migrate/20220914005141_change_namespace_id_not_null_in_members.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ChangeNamespaceIdNotNullInMembers < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_not_null_constraint :members, :member_namespace_id, validate: false
+ end
+
+ def down
+ remove_not_null_constraint :members, :member_namespace_id
+ end
+end
diff --git a/db/migrate/20220914010233_change_members_namespace_foreign_key_on_delete_constraint.rb b/db/migrate/20220914010233_change_members_namespace_foreign_key_on_delete_constraint.rb
new file mode 100644
index 00000000000..2ee98d59c3e
--- /dev/null
+++ b/db/migrate/20220914010233_change_members_namespace_foreign_key_on_delete_constraint.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class ChangeMembersNamespaceForeignKeyOnDeleteConstraint < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TARGET_COLUMN = :member_namespace_id
+
+ def up
+ # add the new FK before removing the old one
+ add_concurrent_foreign_key(
+ :members,
+ :namespaces,
+ column: TARGET_COLUMN,
+ name: fk_name("#{TARGET_COLUMN}_new"),
+ on_delete: :cascade,
+ validate: false
+ )
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(:members, column: TARGET_COLUMN, name: fk_name("#{TARGET_COLUMN}_new"))
+ end
+ end
+
+ def fk_name(column_name)
+ # generate a FK name
+ concurrent_foreign_key_name(:members, column_name)
+ end
+end
diff --git a/db/migrate/20220915140802_create_merge_request_predictions.rb b/db/migrate/20220915140802_create_merge_request_predictions.rb
new file mode 100644
index 00000000000..20cd7e58092
--- /dev/null
+++ b/db/migrate/20220915140802_create_merge_request_predictions.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CreateMergeRequestPredictions < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ create_table :merge_request_predictions, id: false do |t|
+ t.references :merge_request,
+ primary_key: true, null: false, type: :bigint,
+ index: false, foreign_key: { on_delete: :cascade }
+
+ t.timestamps_with_timezone null: false
+ t.jsonb :suggested_reviewers, null: false, default: {}
+ end
+ end
+
+ def down
+ drop_table :merge_request_predictions
+ end
+end