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/20220907124320_add_internal_to_notes.rb9
-rw-r--r--db/migrate/20220907124320_add_internal_to_notes_renamed.rb11
-rw-r--r--db/migrate/20230728020644_add_snowplow_database_collector_hostname_to_application_settings.rb19
-rw-r--r--db/migrate/20230802205051_add_admin_merge_request_to_member_roles.rb17
-rw-r--r--db/migrate/20230804055559_add_rollup_progress_to_wi_progresses.rb9
-rw-r--r--db/migrate/20230807035953_add_index_to_abuse_reports_on_user_id_status_and_category.rb15
-rw-r--r--db/migrate/20230811144601_add_pages_multiple_versions_enabled_to_project_settings.rb9
-rw-r--r--db/migrate/20230814181359_add_decompress_archive_file_timeout_to_application_setting.rb9
-rw-r--r--db/migrate/20230814203548_add_merged_commit_sha_to_merge_requests.rb17
-rw-r--r--db/migrate/20230815072912_add_hashes_to_credit_card_validations.rb28
-rw-r--r--db/migrate/20230816210052_add_licenses_to_sbom_occurrences.rb7
-rw-r--r--db/migrate/20230817040352_init_bigint_conversion_for_shared_runners_duration.rb20
-rw-r--r--db/migrate/20230821000001_create_workspace_variables.rb14
-rw-r--r--db/migrate/20230821000002_add_personal_access_token_id_to_workspaces.rb33
-rw-r--r--db/migrate/20230821000003_add_config_version_to_workspaces.rb7
-rw-r--r--db/migrate/20230821081508_add_mr_requires_saml_auth_for_approval_to_group_mr_approval_settings.rb13
-rw-r--r--db/migrate/20230821101010_remove_crl_null.rb15
-rw-r--r--db/migrate/20230821133549_create_packages_nuget_symbols.rb24
-rw-r--r--db/migrate/20230822064649_add_organization_id_to_project.rb11
-rw-r--r--db/migrate/20230822151454_remove_free_user_cap_email_workers.rb18
-rw-r--r--db/migrate/20230822175304_add_okr_reminder_fields_to_work_item_progresses.rb7
-rw-r--r--db/migrate/20230823132142_create_instance_google_cloud_logging_configurations.rb23
-rw-r--r--db/migrate/20230823174108_add_patch_id_sha_on_approvals.rb13
-rw-r--r--db/migrate/20230824015840_add_finding_id_to_vulnerabilities.rb11
-rw-r--r--db/migrate/20230824022229_make_finding_id_on_vulnerabilities_invalid_foreign_key.rb14
-rw-r--r--db/migrate/20230828153646_extend_push_rules_regex_limits.rb38
-rw-r--r--db/migrate/20230829045459_add_search_rate_limit_allowlist_to_application_settings.rb7
-rw-r--r--db/migrate/20230830084959_validate_push_rules_constraints.rb25
-rw-r--r--db/migrate/20230830085501_remove_push_rules_regex_limits.rb17
-rw-r--r--db/migrate/20230831111051_add_approval_settings_to_scan_result_policies.rb10
-rw-r--r--db/migrate/20230901170145_update_vulnerability_reads_trigger_to_set_has_merge_request.rb211
-rw-r--r--db/migrate/20230903170000_create_packages_protection_rules.rb18
-rw-r--r--db/migrate/20230905040539_add_foreign_key_for_ci_pipeline_chat_data_for_pipeline_id_bigint.rb20
-rw-r--r--db/migrate/20230905061815_add_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb20
-rw-r--r--db/migrate/20230905234948_create_projects_visits_tables.rb19
-rw-r--r--db/migrate/20230905234949_create_groups_visits_tables.rb19
-rw-r--r--db/migrate/20230906072349_create_audit_events_amazon_s3_configurations.rb24
-rw-r--r--db/migrate/20230906100001_add_metadata_columns_to_packages_py_pi_metadata.rb34
-rw-r--r--db/migrate/20230906105445_add_audit_events_amazon_s3_configuration_limit_to_plan_limits.rb7
-rw-r--r--db/migrate/20230906175220_replace_sbom_occurrences_component_id_index.rb18
-rw-r--r--db/migrate/20230906185552_add_markdown_fields_to_review_llm_summary.rb23
-rw-r--r--db/migrate/20230906204934_restart_self_hosted_sent_notifications_bigint_conversion.rb36
-rw-r--r--db/migrate/20230906204935_restart_self_hosted_sent_notifications_backfill.rb56
-rw-r--r--db/migrate/20230907162613_add_force_full_reconciliation_to_workspaces.rb9
-rw-r--r--db/migrate/20230908155831_add_continuous_vuln_scans_toggle_to_security_project_settings.rb16
-rw-r--r--db/migrate/20230911095016_add_root_namespace_id_to_project_statistics.rb25
-rw-r--r--db/migrate/20230913171402_add_deleted_at_to_pages_deployments.rb7
-rw-r--r--db/migrate/20230913171403_add_pages_deployments_deleted_at_index.rb19
-rw-r--r--db/migrate/20230913235822_change_geo_node_statuses_last_event_id_integer_to_big_int.rb21
-rw-r--r--db/migrate/20230914001329_change_geo_node_statuses_cursor_last_event_id_integer_to_big_int.rb21
-rw-r--r--db/migrate/20230914185814_add_keyboard_shortcuts_toggle_to_user_preferences.rb9
-rw-r--r--db/migrate/20230918194153_add_merge_immediately_to_ci_cd_settings.rb13
52 files changed, 1106 insertions, 9 deletions
diff --git a/db/migrate/20220907124320_add_internal_to_notes.rb b/db/migrate/20220907124320_add_internal_to_notes.rb
deleted file mode 100644
index 081914f7830..00000000000
--- a/db/migrate/20220907124320_add_internal_to_notes.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# 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/20220907124320_add_internal_to_notes_renamed.rb b/db/migrate/20220907124320_add_internal_to_notes_renamed.rb
new file mode 100644
index 00000000000..e65bc503c04
--- /dev/null
+++ b/db/migrate/20220907124320_add_internal_to_notes_renamed.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+# Renamed from AddInternalToNotes to AddInternalToNotesRenamed to avoid collision with an Elasticsearch migration from
+# the same name. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129012
+class AddInternalToNotesRenamed < 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/20230728020644_add_snowplow_database_collector_hostname_to_application_settings.rb b/db/migrate/20230728020644_add_snowplow_database_collector_hostname_to_application_settings.rb
new file mode 100644
index 00000000000..edf27685b67
--- /dev/null
+++ b/db/migrate/20230728020644_add_snowplow_database_collector_hostname_to_application_settings.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddSnowplowDatabaseCollectorHostnameToApplicationSettings < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :application_settings, :snowplow_database_collector_hostname, :text, if_not_exists: true
+ end
+
+ add_text_limit :application_settings, :snowplow_database_collector_hostname, 255
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :application_settings, :snowplow_database_collector_hostname, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20230802205051_add_admin_merge_request_to_member_roles.rb b/db/migrate/20230802205051_add_admin_merge_request_to_member_roles.rb
new file mode 100644
index 00000000000..52560621c9a
--- /dev/null
+++ b/db/migrate/20230802205051_add_admin_merge_request_to_member_roles.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddAdminMergeRequestToMemberRoles < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ return if column_exists?(:member_roles, :admin_merge_request)
+
+ add_column :member_roles, :admin_merge_request, :boolean, default: false, null: false
+ end
+
+ def down
+ return unless column_exists?(:member_roles, :admin_merge_request)
+
+ remove_column :member_roles, :admin_merge_request
+ end
+end
diff --git a/db/migrate/20230804055559_add_rollup_progress_to_wi_progresses.rb b/db/migrate/20230804055559_add_rollup_progress_to_wi_progresses.rb
new file mode 100644
index 00000000000..53b8dd2b36f
--- /dev/null
+++ b/db/migrate/20230804055559_add_rollup_progress_to_wi_progresses.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRollupProgressToWiProgresses < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :work_item_progresses, :rollup_progress, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230807035953_add_index_to_abuse_reports_on_user_id_status_and_category.rb b/db/migrate/20230807035953_add_index_to_abuse_reports_on_user_id_status_and_category.rb
new file mode 100644
index 00000000000..583a5471145
--- /dev/null
+++ b/db/migrate/20230807035953_add_index_to_abuse_reports_on_user_id_status_and_category.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToAbuseReportsOnUserIdStatusAndCategory < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_abuse_reports_user_id_status_and_category'
+
+ def up
+ add_concurrent_index :abuse_reports, [:user_id, :status, :category], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :abuse_reports, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230811144601_add_pages_multiple_versions_enabled_to_project_settings.rb b/db/migrate/20230811144601_add_pages_multiple_versions_enabled_to_project_settings.rb
new file mode 100644
index 00000000000..1da3348621e
--- /dev/null
+++ b/db/migrate/20230811144601_add_pages_multiple_versions_enabled_to_project_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPagesMultipleVersionsEnabledToProjectSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :project_settings, :pages_multiple_versions_enabled, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230814181359_add_decompress_archive_file_timeout_to_application_setting.rb b/db/migrate/20230814181359_add_decompress_archive_file_timeout_to_application_setting.rb
new file mode 100644
index 00000000000..f57545424a6
--- /dev/null
+++ b/db/migrate/20230814181359_add_decompress_archive_file_timeout_to_application_setting.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDecompressArchiveFileTimeoutToApplicationSetting < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def change
+ add_column :application_settings, :decompress_archive_file_timeout, :integer, default: 210, null: false
+ end
+end
diff --git a/db/migrate/20230814203548_add_merged_commit_sha_to_merge_requests.rb b/db/migrate/20230814203548_add_merged_commit_sha_to_merge_requests.rb
new file mode 100644
index 00000000000..4c5d2c5c994
--- /dev/null
+++ b/db/migrate/20230814203548_add_merged_commit_sha_to_merge_requests.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddMergedCommitShaToMergeRequests < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :merge_requests, :merged_commit_sha, :bytea unless column_exists?(:merge_requests, :merged_commit_sha)
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :merge_requests, :merged_commit_sha if column_exists?(:merge_requests, :merged_commit_sha)
+ end
+ end
+end
diff --git a/db/migrate/20230815072912_add_hashes_to_credit_card_validations.rb b/db/migrate/20230815072912_add_hashes_to_credit_card_validations.rb
new file mode 100644
index 00000000000..46d14d64ad1
--- /dev/null
+++ b/db/migrate/20230815072912_add_hashes_to_credit_card_validations.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class AddHashesToCreditCardValidations < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :user_credit_card_validations, :last_digits_hash, :text, if_not_exists: true
+ add_column :user_credit_card_validations, :holder_name_hash, :text, if_not_exists: true
+ add_column :user_credit_card_validations, :expiration_date_hash, :text, if_not_exists: true
+ add_column :user_credit_card_validations, :network_hash, :text, if_not_exists: true
+ end
+
+ add_text_limit :user_credit_card_validations, :last_digits_hash, 44
+ add_text_limit :user_credit_card_validations, :holder_name_hash, 44
+ add_text_limit :user_credit_card_validations, :expiration_date_hash, 44
+ add_text_limit :user_credit_card_validations, :network_hash, 44
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :user_credit_card_validations, :last_digits_hash, if_exists: true
+ remove_column :user_credit_card_validations, :holder_name_hash, if_exists: true
+ remove_column :user_credit_card_validations, :expiration_date_hash, if_exists: true
+ remove_column :user_credit_card_validations, :network_hash, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20230816210052_add_licenses_to_sbom_occurrences.rb b/db/migrate/20230816210052_add_licenses_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..e6c7dac4a78
--- /dev/null
+++ b/db/migrate/20230816210052_add_licenses_to_sbom_occurrences.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddLicensesToSbomOccurrences < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :sbom_occurrences, :licenses, :jsonb, default: []
+ end
+end
diff --git a/db/migrate/20230817040352_init_bigint_conversion_for_shared_runners_duration.rb b/db/migrate/20230817040352_init_bigint_conversion_for_shared_runners_duration.rb
new file mode 100644
index 00000000000..c941cf583fb
--- /dev/null
+++ b/db/migrate/20230817040352_init_bigint_conversion_for_shared_runners_duration.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class InitBigintConversionForSharedRunnersDuration < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE_NAMES = %i[ci_project_monthly_usages ci_namespace_monthly_usages]
+ COLUMN_NAMES = %i[shared_runners_duration]
+
+ def up
+ TABLE_NAMES.each do |table_name|
+ initialize_conversion_of_integer_to_bigint table_name, COLUMN_NAMES
+ end
+ end
+
+ def down
+ TABLE_NAMES.each do |table_name|
+ revert_initialize_conversion_of_integer_to_bigint table_name, COLUMN_NAMES
+ end
+ end
+end
diff --git a/db/migrate/20230821000001_create_workspace_variables.rb b/db/migrate/20230821000001_create_workspace_variables.rb
new file mode 100644
index 00000000000..fd23b48c3c3
--- /dev/null
+++ b/db/migrate/20230821000001_create_workspace_variables.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateWorkspaceVariables < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :workspace_variables do |t|
+ t.references :workspace, index: true, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :variable_type, null: false, limit: 2
+ t.timestamps_with_timezone null: false
+ t.text :key, null: false, limit: 255
+ t.binary :encrypted_value, null: false
+ t.binary :encrypted_value_iv, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230821000002_add_personal_access_token_id_to_workspaces.rb b/db/migrate/20230821000002_add_personal_access_token_id_to_workspaces.rb
new file mode 100644
index 00000000000..8b4d5f25959
--- /dev/null
+++ b/db/migrate/20230821000002_add_personal_access_token_id_to_workspaces.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class AddPersonalAccessTokenIdToWorkspaces < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = "index_workspaces_on_personal_access_token_id"
+
+ def up
+ with_lock_retries do
+ add_column :workspaces, :personal_access_token_id, :bigint
+ end
+
+ add_concurrent_index :workspaces, :personal_access_token_id, name: INDEX_NAME
+
+ # Personal Access Tokens are revokable and are soft deleted, so the record should never actually be deleted.
+ # Therefore, `restrict` is the appropriate choice, because if a record ever is attempted to be deleted
+ # outside of Rails, this should be prevented, because `nullify` would result in an invalid state for the workspace,
+ # and `cascade` would delete the workspace.
+ add_concurrent_foreign_key :workspaces,
+ :personal_access_tokens,
+ column: :personal_access_token_id,
+ on_delete: :restrict
+ end
+
+ def down
+ remove_concurrent_index_by_name :workspaces, INDEX_NAME
+ remove_foreign_key_if_exists :workspaces, column: :personal_access_tokens
+
+ with_lock_retries do
+ remove_column :workspaces, :personal_access_token_id, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20230821000003_add_config_version_to_workspaces.rb b/db/migrate/20230821000003_add_config_version_to_workspaces.rb
new file mode 100644
index 00000000000..c9ddf53c785
--- /dev/null
+++ b/db/migrate/20230821000003_add_config_version_to_workspaces.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddConfigVersionToWorkspaces < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :workspaces, :config_version, :integer, default: 1, null: false
+ end
+end
diff --git a/db/migrate/20230821081508_add_mr_requires_saml_auth_for_approval_to_group_mr_approval_settings.rb b/db/migrate/20230821081508_add_mr_requires_saml_auth_for_approval_to_group_mr_approval_settings.rb
new file mode 100644
index 00000000000..b056ab02868
--- /dev/null
+++ b/db/migrate/20230821081508_add_mr_requires_saml_auth_for_approval_to_group_mr_approval_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddMrRequiresSamlAuthForApprovalToGroupMrApprovalSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column(
+ :group_merge_request_approval_settings,
+ :require_saml_auth_to_approve,
+ :boolean,
+ default: false,
+ null: false
+ )
+ end
+end
diff --git a/db/migrate/20230821101010_remove_crl_null.rb b/db/migrate/20230821101010_remove_crl_null.rb
new file mode 100644
index 00000000000..16fa512a65a
--- /dev/null
+++ b/db/migrate/20230821101010_remove_crl_null.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveCrlNull < Gitlab::Database::Migration[2.1]
+ def up
+ change_column_null :x509_certificates, :subject, true
+ change_column_null :x509_issuers, :subject, true
+ change_column_null :x509_issuers, :crl_url, true
+ end
+
+ def down
+ change_column_null :x509_certificates, :subject, false
+ change_column_null :x509_issuers, :subject, false
+ change_column_null :x509_issuers, :crl_url, false
+ end
+end
diff --git a/db/migrate/20230821133549_create_packages_nuget_symbols.rb b/db/migrate/20230821133549_create_packages_nuget_symbols.rb
new file mode 100644
index 00000000000..1ff43cdd93f
--- /dev/null
+++ b/db/migrate/20230821133549_create_packages_nuget_symbols.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreatePackagesNugetSymbols < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :packages_nuget_symbols do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :package,
+ foreign_key: { to_table: :packages_packages, on_delete: :nullify },
+ index: true,
+ type: :bigint
+ t.integer :size, null: false
+ t.integer :file_store, default: 1, limit: 2
+ t.text :file, null: false, limit: 255
+ t.text :file_path, null: false, limit: 255
+ t.text :signature, null: false, limit: 255
+ t.text :object_storage_key, null: false, limit: 255, index: { unique: true }
+
+ t.index [:signature, :file_path], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20230822064649_add_organization_id_to_project.rb b/db/migrate/20230822064649_add_organization_id_to_project.rb
new file mode 100644
index 00000000000..9607f711981
--- /dev/null
+++ b/db/migrate/20230822064649_add_organization_id_to_project.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddOrganizationIdToProject < Gitlab::Database::Migration[2.1]
+ DEFAULT_ORGANIZATION_ID = 1
+
+ enable_lock_retries!
+
+ def change
+ add_column :projects, :organization_id, :bigint, default: DEFAULT_ORGANIZATION_ID, null: true # rubocop:disable Migration/AddColumnsToWideTables
+ end
+end
diff --git a/db/migrate/20230822151454_remove_free_user_cap_email_workers.rb b/db/migrate/20230822151454_remove_free_user_cap_email_workers.rb
new file mode 100644
index 00000000000..6baba8822ab
--- /dev/null
+++ b/db/migrate/20230822151454_remove_free_user_cap_email_workers.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveFreeUserCapEmailWorkers < Gitlab::Database::Migration[2.1]
+ DEPRECATED_JOB_CLASSES = %w[
+ Namespaces::FreeUserCap::BackfillNotificationClearingJobsWorker
+ Namespaces::FreeUserCap::BackfillNotificationJobsWorker
+ Namespaces::FreeUserCap::NotificationClearingWorker
+ Namespaces::FreeUserCap::OverLimitNotificationWorker
+ ]
+ 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/20230822175304_add_okr_reminder_fields_to_work_item_progresses.rb b/db/migrate/20230822175304_add_okr_reminder_fields_to_work_item_progresses.rb
new file mode 100644
index 00000000000..7ca2e690521
--- /dev/null
+++ b/db/migrate/20230822175304_add_okr_reminder_fields_to_work_item_progresses.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddOkrReminderFieldsToWorkItemProgresses < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :work_item_progresses, :reminder_frequency, :integer, limit: 2, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20230823132142_create_instance_google_cloud_logging_configurations.rb b/db/migrate/20230823132142_create_instance_google_cloud_logging_configurations.rb
new file mode 100644
index 00000000000..c659264038d
--- /dev/null
+++ b/db/migrate/20230823132142_create_instance_google_cloud_logging_configurations.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class CreateInstanceGoogleCloudLoggingConfigurations < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ UNIQUE_INDEX_NAME = "unique_instance_google_cloud_logging_configurations"
+ UNIQUE_CONFIG_NAME_INDEX = "unique_instance_google_cloud_logging_configurations_name"
+
+ def change
+ create_table :audit_events_instance_google_cloud_logging_configurations do |t|
+ t.timestamps_with_timezone null: false
+ t.text :google_project_id_name, null: false, limit: 30
+ t.text :client_email, null: false, limit: 254
+ t.text :log_id_name, default: "audit_events", limit: 511
+ t.text :name, null: false, limit: 72
+ t.binary :encrypted_private_key, null: false
+ t.binary :encrypted_private_key_iv, null: false
+
+ t.index [:google_project_id_name, :log_id_name], unique: true, name: UNIQUE_INDEX_NAME
+ t.index :name, unique: true, name: UNIQUE_CONFIG_NAME_INDEX
+ end
+ end
+end
diff --git a/db/migrate/20230823174108_add_patch_id_sha_on_approvals.rb b/db/migrate/20230823174108_add_patch_id_sha_on_approvals.rb
new file mode 100644
index 00000000000..ef68b66d2e8
--- /dev/null
+++ b/db/migrate/20230823174108_add_patch_id_sha_on_approvals.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddPatchIdShaOnApprovals < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column :approvals, :patch_id_sha, :binary
+ end
+
+ def down
+ remove_column :approvals, :patch_id_sha
+ end
+end
diff --git a/db/migrate/20230824015840_add_finding_id_to_vulnerabilities.rb b/db/migrate/20230824015840_add_finding_id_to_vulnerabilities.rb
new file mode 100644
index 00000000000..a8a8e8c8757
--- /dev/null
+++ b/db/migrate/20230824015840_add_finding_id_to_vulnerabilities.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddFindingIdToVulnerabilities < Gitlab::Database::Migration[2.1]
+ def up
+ add_column :vulnerabilities, :finding_id, :bigint, if_not_exists: true
+ end
+
+ def down
+ remove_column :vulnerabilities, :finding_id
+ end
+end
diff --git a/db/migrate/20230824022229_make_finding_id_on_vulnerabilities_invalid_foreign_key.rb b/db/migrate/20230824022229_make_finding_id_on_vulnerabilities_invalid_foreign_key.rb
new file mode 100644
index 00000000000..e6ac5ea95ab
--- /dev/null
+++ b/db/migrate/20230824022229_make_finding_id_on_vulnerabilities_invalid_foreign_key.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class MakeFindingIdOnVulnerabilitiesInvalidForeignKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerabilities, :vulnerability_occurrences,
+ column: :finding_id, on_delete: :cascade, validate: false
+ end
+
+ def down
+ remove_foreign_key_if_exists :vulnerabilities, column: :finding_id
+ end
+end
diff --git a/db/migrate/20230828153646_extend_push_rules_regex_limits.rb b/db/migrate/20230828153646_extend_push_rules_regex_limits.rb
new file mode 100644
index 00000000000..ba5e8e54f9f
--- /dev/null
+++ b/db/migrate/20230828153646_extend_push_rules_regex_limits.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+class ExtendPushRulesRegexLimits < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ REGEX_COLUMNS = %i[
+ force_push_regex
+ delete_branch_regex
+ commit_message_regex
+ author_email_regex
+ file_name_regex
+ branch_name_regex
+ ].freeze
+
+ LONG_REGEX_COLUMNS = %i[commit_message_negative_regex]
+
+ def up
+ REGEX_COLUMNS.each do |column_name|
+ add_check_constraint :push_rules, "char_length(#{column_name}) <= 511", "#{column_name}_size_constraint",
+ validate: false
+ end
+
+ LONG_REGEX_COLUMNS.each do |column_name|
+ add_check_constraint :push_rules, "char_length(#{column_name}) <= 2047", "#{column_name}_size_constraint",
+ validate: false
+ end
+ end
+
+ def down
+ REGEX_COLUMNS.each do |column_name|
+ remove_check_constraint :push_rules, "#{column_name}_size_constraint"
+ end
+
+ LONG_REGEX_COLUMNS.each do |column_name|
+ remove_check_constraint :push_rules, "#{column_name}_size_constraint"
+ end
+ end
+end
diff --git a/db/migrate/20230829045459_add_search_rate_limit_allowlist_to_application_settings.rb b/db/migrate/20230829045459_add_search_rate_limit_allowlist_to_application_settings.rb
new file mode 100644
index 00000000000..135f2d7ff10
--- /dev/null
+++ b/db/migrate/20230829045459_add_search_rate_limit_allowlist_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddSearchRateLimitAllowlistToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :search_rate_limit_allowlist, :text, array: true, default: [], null: false
+ end
+end
diff --git a/db/migrate/20230830084959_validate_push_rules_constraints.rb b/db/migrate/20230830084959_validate_push_rules_constraints.rb
new file mode 100644
index 00000000000..99b5d680642
--- /dev/null
+++ b/db/migrate/20230830084959_validate_push_rules_constraints.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class ValidatePushRulesConstraints < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ REGEX_COLUMNS = %i[
+ force_push_regex
+ delete_branch_regex
+ commit_message_regex
+ commit_message_negative_regex
+ author_email_regex
+ file_name_regex
+ branch_name_regex
+ ].freeze
+
+ def up
+ REGEX_COLUMNS.each do |column_name|
+ validate_check_constraint :push_rules, "#{column_name}_size_constraint"
+ end
+ end
+
+ def down
+ # No op
+ end
+end
diff --git a/db/migrate/20230830085501_remove_push_rules_regex_limits.rb b/db/migrate/20230830085501_remove_push_rules_regex_limits.rb
new file mode 100644
index 00000000000..31d85e3ec11
--- /dev/null
+++ b/db/migrate/20230830085501_remove_push_rules_regex_limits.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RemovePushRulesRegexLimits < Gitlab::Database::Migration[2.1]
+ def up
+ change_column :push_rules, :force_push_regex, :string, limit: nil
+ change_column :push_rules, :delete_branch_regex, :string, limit: nil
+ change_column :push_rules, :commit_message_regex, :string, limit: nil
+ change_column :push_rules, :commit_message_negative_regex, :string, limit: nil
+ change_column :push_rules, :author_email_regex, :string, limit: nil
+ change_column :push_rules, :file_name_regex, :string, limit: nil
+ change_column :push_rules, :branch_name_regex, :string, limit: nil
+ end
+
+ def down
+ # No op
+ end
+end
diff --git a/db/migrate/20230831111051_add_approval_settings_to_scan_result_policies.rb b/db/migrate/20230831111051_add_approval_settings_to_scan_result_policies.rb
new file mode 100644
index 00000000000..3bd3f58c2dd
--- /dev/null
+++ b/db/migrate/20230831111051_add_approval_settings_to_scan_result_policies.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddApprovalSettingsToScanResultPolicies < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :scan_result_policies, :project_approval_settings, :jsonb, default: {}, null: false
+ add_column :scan_result_policies, :commits, :smallint
+ end
+end
diff --git a/db/migrate/20230901170145_update_vulnerability_reads_trigger_to_set_has_merge_request.rb b/db/migrate/20230901170145_update_vulnerability_reads_trigger_to_set_has_merge_request.rb
new file mode 100644
index 00000000000..7b5a4645f85
--- /dev/null
+++ b/db/migrate/20230901170145_update_vulnerability_reads_trigger_to_set_has_merge_request.rb
@@ -0,0 +1,211 @@
+# frozen_string_literal: true
+
+class UpdateVulnerabilityReadsTriggerToSetHasMergeRequest < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_or_update_vulnerability_reads()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_on_default_branch boolean;
+ present_on_default_branch boolean;
+ namespace_id bigint;
+ has_issues boolean;
+ has_merge_request boolean;
+ BEGIN
+ IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
+ RETURN NULL;
+ END IF;
+
+ IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
+ INTO
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ IF present_on_default_branch IS NOT true THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ projects.namespace_id
+ INTO
+ namespace_id
+ FROM
+ projects
+ WHERE
+ projects.id = NEW.project_id;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.vulnerability_id)
+ INTO
+ has_issues;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_merge_request_links WHERE vulnerability_merge_request_links.vulnerability_id = NEW.vulnerability_id)
+ INTO
+ has_merge_request;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues, has_merge_request)
+ VALUES (NEW.vulnerability_id, namespace_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint), has_issues, has_merge_request)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$
+ SQL
+
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_vulnerability_reads_from_vulnerability()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ scanner_id bigint;
+ uuid uuid;
+ location_image text;
+ cluster_agent_id text;
+ casted_cluster_agent_id bigint;
+ namespace_id bigint;
+ has_issues boolean;
+ has_merge_request boolean;
+ BEGIN
+ SELECT
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint), projects.namespace_id
+ INTO
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, namespace_id
+ FROM
+ vulnerability_occurrences v_o
+ INNER JOIN projects ON projects.id = v_o.project_id
+ WHERE
+ v_o.vulnerability_id = NEW.id
+ LIMIT 1;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.id)
+ INTO
+ has_issues;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_merge_request_links WHERE vulnerability_merge_request_links.vulnerability_id = NEW.id)
+ INTO
+ has_merge_request;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues, has_merge_request)
+ VALUES (NEW.id, namespace_id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues, has_merge_request)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_or_update_vulnerability_reads()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_on_default_branch boolean;
+ present_on_default_branch boolean;
+ namespace_id bigint;
+ has_issues boolean;
+ BEGIN
+ IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
+ RETURN NULL;
+ END IF;
+
+ IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
+ INTO
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ IF present_on_default_branch IS NOT true THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ projects.namespace_id
+ INTO
+ namespace_id
+ FROM
+ projects
+ WHERE
+ projects.id = NEW.project_id;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.vulnerability_id)
+ INTO
+ has_issues;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues)
+ VALUES (NEW.vulnerability_id, namespace_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint), has_issues)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$
+ SQL
+
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_vulnerability_reads_from_vulnerability()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ scanner_id bigint;
+ uuid uuid;
+ location_image text;
+ cluster_agent_id text;
+ casted_cluster_agent_id bigint;
+ namespace_id bigint;
+ has_issues boolean;
+ BEGIN
+ SELECT
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint), projects.namespace_id
+ INTO
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, namespace_id
+ FROM
+ vulnerability_occurrences v_o
+ INNER JOIN projects ON projects.id = v_o.project_id
+ WHERE
+ v_o.vulnerability_id = NEW.id
+ LIMIT 1;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.id)
+ INTO
+ has_issues;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues)
+ VALUES (NEW.id, namespace_id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$
+ SQL
+ end
+end
diff --git a/db/migrate/20230903170000_create_packages_protection_rules.rb b/db/migrate/20230903170000_create_packages_protection_rules.rb
new file mode 100644
index 00000000000..d5e8a4af558
--- /dev/null
+++ b/db/migrate/20230903170000_create_packages_protection_rules.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreatePackagesProtectionRules < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :packages_protection_rules do |t|
+ t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.integer :push_protected_up_to_access_level, null: false
+ t.integer :package_type, limit: 2, null: false
+ t.text :package_name_pattern, limit: 255, null: false
+
+ t.index [:project_id, :package_type, :package_name_pattern], unique: true,
+ name: :i_packages_unique_project_id_package_type_package_name_pattern
+ end
+ end
+end
diff --git a/db/migrate/20230905040539_add_foreign_key_for_ci_pipeline_chat_data_for_pipeline_id_bigint.rb b/db/migrate/20230905040539_add_foreign_key_for_ci_pipeline_chat_data_for_pipeline_id_bigint.rb
new file mode 100644
index 00000000000..64d304b3727
--- /dev/null
+++ b/db/migrate/20230905040539_add_foreign_key_for_ci_pipeline_chat_data_for_pipeline_id_bigint.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddForeignKeyForCiPipelineChatDataForPipelineIdBigint < Gitlab::Database::Migration[2.1]
+ TABLE_NAME = :ci_pipeline_chat_data
+ REFERENCING_TABLE_NAME = :ci_pipelines
+ COLUMN_NAME = :pipeline_id_convert_to_bigint
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(
+ TABLE_NAME, REFERENCING_TABLE_NAME,
+ column: COLUMN_NAME, on_delete: :cascade, reverse_lock_order: true
+ )
+ end
+
+ def down
+ remove_foreign_key_if_exists TABLE_NAME, column: COLUMN_NAME
+ end
+end
diff --git a/db/migrate/20230905061815_add_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb b/db/migrate/20230905061815_add_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb
new file mode 100644
index 00000000000..72ff8399a16
--- /dev/null
+++ b/db/migrate/20230905061815_add_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddForeignKeyForCiPipelineMessagesPipelineIdBigint < Gitlab::Database::Migration[2.1]
+ TABLE_NAME = :ci_pipeline_messages
+ REFERENCING_TABLE_NAME = :ci_pipelines
+ COLUMN_NAME = :pipeline_id_convert_to_bigint
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(
+ TABLE_NAME, REFERENCING_TABLE_NAME,
+ column: COLUMN_NAME, on_delete: :cascade, validate: false, reverse_lock_order: true
+ )
+ end
+
+ def down
+ remove_foreign_key_if_exists TABLE_NAME, column: COLUMN_NAME
+ end
+end
diff --git a/db/migrate/20230905234948_create_projects_visits_tables.rb b/db/migrate/20230905234948_create_projects_visits_tables.rb
new file mode 100644
index 00000000000..b67615b6a22
--- /dev/null
+++ b/db/migrate/20230905234948_create_projects_visits_tables.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateProjectsVisitsTables < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :projects_visits, primary_key: [:id, :visited_at],
+ options: 'PARTITION BY RANGE (visited_at)' do |t|
+ t.bigserial :id, null: false
+ t.bigint :entity_id, null: false, index: true
+ t.bigint :user_id, null: false
+ t.datetime_with_timezone :visited_at, null: false
+ end
+
+ add_index(:projects_visits, [:user_id, :entity_id, :visited_at])
+ end
+
+ def down
+ drop_table :projects_visits
+ end
+end
diff --git a/db/migrate/20230905234949_create_groups_visits_tables.rb b/db/migrate/20230905234949_create_groups_visits_tables.rb
new file mode 100644
index 00000000000..f02e6e64220
--- /dev/null
+++ b/db/migrate/20230905234949_create_groups_visits_tables.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateGroupsVisitsTables < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :groups_visits, primary_key: [:id, :visited_at],
+ options: 'PARTITION BY RANGE (visited_at)' do |t|
+ t.bigserial :id, null: false
+ t.bigint :entity_id, null: false, index: true
+ t.bigint :user_id, null: false
+ t.datetime_with_timezone :visited_at, null: false
+ end
+
+ add_index(:groups_visits, [:user_id, :entity_id, :visited_at])
+ end
+
+ def down
+ drop_table :groups_visits
+ end
+end
diff --git a/db/migrate/20230906072349_create_audit_events_amazon_s3_configurations.rb b/db/migrate/20230906072349_create_audit_events_amazon_s3_configurations.rb
new file mode 100644
index 00000000000..6cdb4a0f0c2
--- /dev/null
+++ b/db/migrate/20230906072349_create_audit_events_amazon_s3_configurations.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateAuditEventsAmazonS3Configurations < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ UNIQUE_NAME = "unique_amazon_s3_configurations_namespace_id_and_name"
+ UNIQUE_BUCKET_NAME = "unique_amazon_s3_configurations_namespace_id_and_bucket_name"
+
+ def change
+ create_table :audit_events_amazon_s3_configurations do |t|
+ t.timestamps_with_timezone null: false
+ t.references :namespace, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.text :access_key_xid, null: false, limit: 128
+ t.text :name, null: false, limit: 72
+ t.text :bucket_name, null: false, limit: 63
+ t.text :aws_region, null: false, limit: 50
+ t.binary :encrypted_secret_access_key, null: false
+ t.binary :encrypted_secret_access_key_iv, null: false
+
+ t.index [:namespace_id, :name], unique: true, name: UNIQUE_NAME
+ t.index [:namespace_id, :bucket_name], unique: true, name: UNIQUE_BUCKET_NAME
+ end
+ end
+end
diff --git a/db/migrate/20230906100001_add_metadata_columns_to_packages_py_pi_metadata.rb b/db/migrate/20230906100001_add_metadata_columns_to_packages_py_pi_metadata.rb
new file mode 100644
index 00000000000..4cbc0a5bf3e
--- /dev/null
+++ b/db/migrate/20230906100001_add_metadata_columns_to_packages_py_pi_metadata.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class AddMetadataColumnsToPackagesPyPiMetadata < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :packages_pypi_metadata, :metadata_version, :text, null: true, if_not_exists: true
+ add_column :packages_pypi_metadata, :summary, :text, null: true, if_not_exists: true
+ add_column :packages_pypi_metadata, :keywords, :text, null: true, if_not_exists: true
+ add_column :packages_pypi_metadata, :author_email, :text, null: true, if_not_exists: true
+ add_column :packages_pypi_metadata, :description, :text, null: true, if_not_exists: true
+ add_column :packages_pypi_metadata, :description_content_type, :text, null: true, if_not_exists: true
+ end
+
+ add_text_limit :packages_pypi_metadata, :metadata_version, 16
+ add_text_limit :packages_pypi_metadata, :summary, 255
+ add_text_limit :packages_pypi_metadata, :keywords, 255
+ add_text_limit :packages_pypi_metadata, :author_email, 2048
+ add_text_limit :packages_pypi_metadata, :description, 4000
+ add_text_limit :packages_pypi_metadata, :description_content_type, 128
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :packages_pypi_metadata, :metadata_version, if_exists: true
+ remove_column :packages_pypi_metadata, :summary, if_exists: true
+ remove_column :packages_pypi_metadata, :keywords, if_exists: true
+ remove_column :packages_pypi_metadata, :author_email, if_exists: true
+ remove_column :packages_pypi_metadata, :description, if_exists: true
+ remove_column :packages_pypi_metadata, :description_content_type, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20230906105445_add_audit_events_amazon_s3_configuration_limit_to_plan_limits.rb b/db/migrate/20230906105445_add_audit_events_amazon_s3_configuration_limit_to_plan_limits.rb
new file mode 100644
index 00000000000..4d0a83a9948
--- /dev/null
+++ b/db/migrate/20230906105445_add_audit_events_amazon_s3_configuration_limit_to_plan_limits.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddAuditEventsAmazonS3ConfigurationLimitToPlanLimits < Gitlab::Database::Migration[2.1]
+ def change
+ add_column(:plan_limits, :audit_events_amazon_s3_configurations, :integer, default: 5, null: false)
+ end
+end
diff --git a/db/migrate/20230906175220_replace_sbom_occurrences_component_id_index.rb b/db/migrate/20230906175220_replace_sbom_occurrences_component_id_index.rb
new file mode 100644
index 00000000000..9f377675b80
--- /dev/null
+++ b/db/migrate/20230906175220_replace_sbom_occurrences_component_id_index.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class ReplaceSbomOccurrencesComponentIdIndex < Gitlab::Database::Migration[2.1]
+ REMOVED_INDEX_NAME = "index_sbom_occurrences_on_component_id"
+ ADDED_INDEX_NAME = "index_sbom_occurrences_on_component_id_and_id"
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :sbom_occurrences, %i[component_id id], name: ADDED_INDEX_NAME
+ remove_concurrent_index_by_name :sbom_occurrences, name: REMOVED_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :sbom_occurrences, :component_id, name: REMOVED_INDEX_NAME
+ remove_concurrent_index_by_name :sbom_occurrences, name: ADDED_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230906185552_add_markdown_fields_to_review_llm_summary.rb b/db/migrate/20230906185552_add_markdown_fields_to_review_llm_summary.rb
new file mode 100644
index 00000000000..6e0c0fa5675
--- /dev/null
+++ b/db/migrate/20230906185552_add_markdown_fields_to_review_llm_summary.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddMarkdownFieldsToReviewLlmSummary < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ # rubocop:disable Migration/AddLimitToTextColumns
+ add_column :merge_request_review_llm_summaries,
+ :cached_markdown_version,
+ :integer,
+ null: true
+ add_column :merge_request_review_llm_summaries,
+ :content_html,
+ :text,
+ null: true
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+
+ def down
+ remove_column :merge_request_review_llm_summaries, :cached_markdown_version
+ remove_column :merge_request_review_llm_summaries, :content_html
+ end
+end
diff --git a/db/migrate/20230906204934_restart_self_hosted_sent_notifications_bigint_conversion.rb b/db/migrate/20230906204934_restart_self_hosted_sent_notifications_bigint_conversion.rb
new file mode 100644
index 00000000000..8dbeb873bab
--- /dev/null
+++ b/db/migrate/20230906204934_restart_self_hosted_sent_notifications_bigint_conversion.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class RestartSelfHostedSentNotificationsBigintConversion < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ disable_ddl_transaction!
+
+ TABLE = :sent_notifications
+ COLUMNS = %i[id]
+
+ def up
+ return if should_skip? || id_is_bigint? || id_convert_to_bigint_exist?
+
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ return if should_skip? || id_is_bigint?
+
+ revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def should_skip?
+ com_or_dev_or_test_but_not_jh?
+ end
+
+ def id_is_bigint?
+ table_columns = columns(TABLE)
+ column_id = table_columns.find { |c| c.name == 'id' }
+ column_id.sql_type == 'bigint'
+ end
+
+ def id_convert_to_bigint_exist?
+ column_exists?(TABLE.to_s, 'id_convert_to_bigint')
+ end
+end
diff --git a/db/migrate/20230906204935_restart_self_hosted_sent_notifications_backfill.rb b/db/migrate/20230906204935_restart_self_hosted_sent_notifications_backfill.rb
new file mode 100644
index 00000000000..21c1798179f
--- /dev/null
+++ b/db/migrate/20230906204935_restart_self_hosted_sent_notifications_backfill.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+class RestartSelfHostedSentNotificationsBackfill < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ TABLE = :sent_notifications
+ COLUMNS = %i[id]
+
+ def up
+ return if should_skip? || id_is_bigint? || already_backfilled?
+
+ # rubocop: disable Migration/BatchMigrationsPostOnly
+ delete_batched_background_migration(
+ 'CopyColumnUsingBackgroundMigrationJob',
+ :sent_notifications,
+ :id,
+ [["id"], ["id_convert_to_bigint"]]
+ )
+ # rubocop: enable Migration/BatchMigrationsPostOnly
+
+ backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ return if should_skip? || id_is_bigint? || already_backfilled?
+
+ revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def should_skip?
+ com_or_dev_or_test_but_not_jh?
+ end
+
+ def id_is_bigint?
+ table_columns = columns(TABLE)
+ column_id = table_columns.find { |c| c.name == 'id' }
+ column_id.sql_type == 'bigint'
+ end
+
+ def already_backfilled?
+ res = connection.execute <<~SQL
+ SELECT
+ id_convert_to_bigint
+ FROM
+ sent_notifications
+ ORDER BY
+ id ASC
+ LIMIT 1
+ SQL
+ return false if res.ntuples == 0
+
+ res.first['id_convert_to_bigint'].to_i != 0
+ end
+end
diff --git a/db/migrate/20230907162613_add_force_full_reconciliation_to_workspaces.rb b/db/migrate/20230907162613_add_force_full_reconciliation_to_workspaces.rb
new file mode 100644
index 00000000000..bd0b9b9bf69
--- /dev/null
+++ b/db/migrate/20230907162613_add_force_full_reconciliation_to_workspaces.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddForceFullReconciliationToWorkspaces < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :workspaces, :force_full_reconciliation, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230908155831_add_continuous_vuln_scans_toggle_to_security_project_settings.rb b/db/migrate/20230908155831_add_continuous_vuln_scans_toggle_to_security_project_settings.rb
new file mode 100644
index 00000000000..3411e6b3ef2
--- /dev/null
+++ b/db/migrate/20230908155831_add_continuous_vuln_scans_toggle_to_security_project_settings.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddContinuousVulnScansToggleToSecurityProjectSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+ TABLE_NAME = :project_security_settings
+ COLUMN_NAME = :continuous_vulnerability_scans_enabled
+
+ def up
+ add_column TABLE_NAME, COLUMN_NAME, :boolean, null: false,
+ default: false
+ end
+
+ def down
+ remove_column TABLE_NAME, COLUMN_NAME
+ end
+end
diff --git a/db/migrate/20230911095016_add_root_namespace_id_to_project_statistics.rb b/db/migrate/20230911095016_add_root_namespace_id_to_project_statistics.rb
new file mode 100644
index 00000000000..969aeb9bf9c
--- /dev/null
+++ b/db/migrate/20230911095016_add_root_namespace_id_to_project_statistics.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddRootNamespaceIdToProjectStatistics < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = "index_project_statistics_on_root_namespace_id"
+
+ def up
+ unless column_exists?(:project_statistics, :root_namespace_id)
+ add_column :project_statistics, :root_namespace_id, :bigint
+ end
+
+ add_concurrent_foreign_key :project_statistics, :namespaces,
+ column: :root_namespace_id,
+ on_delete: :nullify
+
+ add_concurrent_index :project_statistics, :root_namespace_id, name: INDEX_NAME
+ end
+
+ def down
+ return unless column_exists?(:project_statistics, :root_namespace_id)
+
+ remove_column :project_statistics, :root_namespace_id, :bigint
+ end
+end
diff --git a/db/migrate/20230913171402_add_deleted_at_to_pages_deployments.rb b/db/migrate/20230913171402_add_deleted_at_to_pages_deployments.rb
new file mode 100644
index 00000000000..15716f8fbfb
--- /dev/null
+++ b/db/migrate/20230913171402_add_deleted_at_to_pages_deployments.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddDeletedAtToPagesDeployments < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :pages_deployments, :deleted_at, :datetime_with_timezone, null: true
+ end
+end
diff --git a/db/migrate/20230913171403_add_pages_deployments_deleted_at_index.rb b/db/migrate/20230913171403_add_pages_deployments_deleted_at_index.rb
new file mode 100644
index 00000000000..f519e54265f
--- /dev/null
+++ b/db/migrate/20230913171403_add_pages_deployments_deleted_at_index.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddPagesDeploymentsDeletedAtIndex < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX = 'pages_deployments_deleted_at_index'
+ COLUMNS = [:id, :project_id, :path_prefix]
+
+ def up
+ add_concurrent_index :pages_deployments,
+ COLUMNS,
+ where: 'deleted_at IS NULL',
+ name: INDEX
+ end
+
+ def down
+ remove_concurrent_index :pages_deployments, COLUMNS, name: INDEX
+ end
+end
diff --git a/db/migrate/20230913235822_change_geo_node_statuses_last_event_id_integer_to_big_int.rb b/db/migrate/20230913235822_change_geo_node_statuses_last_event_id_integer_to_big_int.rb
new file mode 100644
index 00000000000..618e6ce6ec9
--- /dev/null
+++ b/db/migrate/20230913235822_change_geo_node_statuses_last_event_id_integer_to_big_int.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ChangeGeoNodeStatusesLastEventIdIntegerToBigInt < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ execute "ALTER TABLE geo_node_statuses ALTER COLUMN last_event_id TYPE bigint;"
+ end
+
+ execute "ANALYZE geo_node_statuses;"
+ end
+
+ def down
+ with_lock_retries do
+ execute "ALTER TABLE geo_node_statuses ALTER COLUMN last_event_id TYPE integer;"
+ end
+
+ execute "ANALYZE geo_node_statuses;"
+ end
+end
diff --git a/db/migrate/20230914001329_change_geo_node_statuses_cursor_last_event_id_integer_to_big_int.rb b/db/migrate/20230914001329_change_geo_node_statuses_cursor_last_event_id_integer_to_big_int.rb
new file mode 100644
index 00000000000..f36089f746f
--- /dev/null
+++ b/db/migrate/20230914001329_change_geo_node_statuses_cursor_last_event_id_integer_to_big_int.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ChangeGeoNodeStatusesCursorLastEventIdIntegerToBigInt < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ execute "ALTER TABLE geo_node_statuses ALTER COLUMN cursor_last_event_id TYPE bigint;"
+ end
+
+ execute "ANALYZE geo_node_statuses;"
+ end
+
+ def down
+ with_lock_retries do
+ execute "ALTER TABLE geo_node_statuses ALTER COLUMN cursor_last_event_id TYPE integer;"
+ end
+
+ execute "ANALYZE geo_node_statuses;"
+ end
+end
diff --git a/db/migrate/20230914185814_add_keyboard_shortcuts_toggle_to_user_preferences.rb b/db/migrate/20230914185814_add_keyboard_shortcuts_toggle_to_user_preferences.rb
new file mode 100644
index 00000000000..b7de3f95c7f
--- /dev/null
+++ b/db/migrate/20230914185814_add_keyboard_shortcuts_toggle_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddKeyboardShortcutsToggleToUserPreferences < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :user_preferences, :keyboard_shortcuts_enabled, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230918194153_add_merge_immediately_to_ci_cd_settings.rb b/db/migrate/20230918194153_add_merge_immediately_to_ci_cd_settings.rb
new file mode 100644
index 00000000000..eee1ba6f781
--- /dev/null
+++ b/db/migrate/20230918194153_add_merge_immediately_to_ci_cd_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddMergeImmediatelyToCiCdSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column :project_ci_cd_settings, :merge_trains_skip_train_allowed, :boolean, default: false, null: false
+ end
+
+ def down
+ remove_column :project_ci_cd_settings, :merge_trains_skip_train_allowed
+ end
+end