diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /db | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'db')
313 files changed, 4132 insertions, 288 deletions
diff --git a/db/click_house/main/20230707151359_create_ci_finished_builds.sql b/db/click_house/main/20230707151359_create_ci_finished_builds.sql new file mode 100644 index 00000000000..6b1b846518d --- /dev/null +++ b/db/click_house/main/20230707151359_create_ci_finished_builds.sql @@ -0,0 +1,33 @@ +-- source table for CI analytics, almost useless on it's own, but it's a basis for creating materialized views +CREATE TABLE ci_finished_builds +( + id UInt64 DEFAULT 0, + project_id UInt64 DEFAULT 0, + pipeline_id UInt64 DEFAULT 0, + status LowCardinality(String) DEFAULT '', + + --- Fields to calculate timings + created_at DateTime64(6, 'UTC') DEFAULT now(), + queued_at DateTime64(6, 'UTC') DEFAULT now(), + finished_at DateTime64(6, 'UTC') DEFAULT now(), + started_at DateTime64(6, 'UTC') DEFAULT now(), + + runner_id UInt64 DEFAULT 0, + runner_manager_system_xid String DEFAULT '', + + --- Runner fields + runner_run_untagged Boolean DEFAULT FALSE, + runner_type UInt8 DEFAULT 0, + runner_manager_version LowCardinality(String) DEFAULT '', + runner_manager_revision LowCardinality(String) DEFAULT '', + runner_manager_platform LowCardinality(String) DEFAULT '', + runner_manager_architecture LowCardinality(String) DEFAULT '', + + --- Materialized columns + duration Int64 MATERIALIZED age('second', started_at, finished_at), + queueing_duration Int64 MATERIALIZED age('second', queued_at, started_at) + --- This table is incomplete, we'll add more fields before starting the data migration +) +ENGINE = ReplacingMergeTree -- Using ReplacingMergeTree just in case we accidentally insert the same data twice +ORDER BY (status, runner_type, project_id, finished_at, id) +PARTITION BY toYear(finished_at) diff --git a/db/click_house/main/20230719101806_create_ci_finished_builds_aggregated_queueing_delay_percentiles.sql b/db/click_house/main/20230719101806_create_ci_finished_builds_aggregated_queueing_delay_percentiles.sql new file mode 100644 index 00000000000..56889ffc0d4 --- /dev/null +++ b/db/click_house/main/20230719101806_create_ci_finished_builds_aggregated_queueing_delay_percentiles.sql @@ -0,0 +1,11 @@ +CREATE TABLE ci_finished_builds_aggregated_queueing_delay_percentiles +( + status LowCardinality(String) DEFAULT '', + runner_type UInt8 DEFAULT 0, + started_at_bucket DateTime64(6, 'UTC') DEFAULT now(), + + count_builds AggregateFunction(count), + queueing_duration_quantile AggregateFunction(quantile, Int64) +) +ENGINE = AggregatingMergeTree() +ORDER BY (started_at_bucket, status, runner_type) diff --git a/db/click_house/main/20230808070520_create_events_cursor.sql b/db/click_house/main/20230808070520_create_events_cursor.sql new file mode 100644 index 00000000000..effc3c64f60 --- /dev/null +++ b/db/click_house/main/20230808070520_create_events_cursor.sql @@ -0,0 +1,9 @@ +CREATE TABLE sync_cursors +( + table_name LowCardinality(String) DEFAULT '', + primary_key_value UInt64 DEFAULT 0, + recorded_at DateTime64(6, 'UTC') DEFAULT now() +) +ENGINE = ReplacingMergeTree(recorded_at) +ORDER BY (table_name) +PRIMARY KEY (table_name) diff --git a/db/click_house/main/20230808140217_create_ci_finished_builds_aggregated_queueing_delay_percentiles_mv.sql b/db/click_house/main/20230808140217_create_ci_finished_builds_aggregated_queueing_delay_percentiles_mv.sql new file mode 100644 index 00000000000..504e2d87609 --- /dev/null +++ b/db/click_house/main/20230808140217_create_ci_finished_builds_aggregated_queueing_delay_percentiles_mv.sql @@ -0,0 +1,12 @@ +CREATE MATERIALIZED VIEW ci_finished_builds_aggregated_queueing_delay_percentiles_mv +TO ci_finished_builds_aggregated_queueing_delay_percentiles +AS +SELECT + status, + runner_type, + toStartOfInterval(started_at, INTERVAL 5 minute) AS started_at_bucket, + + countState(*) as count_builds, + quantileState(queueing_duration) AS queueing_duration_quantile +FROM ci_finished_builds +GROUP BY status, runner_type, started_at_bucket diff --git a/db/docs/audit_events_amazon_s3_configurations.yml b/db/docs/audit_events_amazon_s3_configurations.yml new file mode 100644 index 00000000000..fa4945186ea --- /dev/null +++ b/db/docs/audit_events_amazon_s3_configurations.yml @@ -0,0 +1,10 @@ +--- +table_name: audit_events_amazon_s3_configurations +classes: + - AuditEvents::AmazonS3Configuration +feature_categories: + - audit_events +description: Stores Amazon S3 configurations associated used for audit event streaming. +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/333371 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/docs/audit_events_instance_google_cloud_logging_configurations.yml b/db/docs/audit_events_instance_google_cloud_logging_configurations.yml new file mode 100644 index 00000000000..059ab59d860 --- /dev/null +++ b/db/docs/audit_events_instance_google_cloud_logging_configurations.yml @@ -0,0 +1,10 @@ +--- +table_name: audit_events_instance_google_cloud_logging_configurations +classes: + - AuditEvents::Instance::GoogleCloudLoggingConfiguration +feature_categories: + - audit_events +description: Stores Instance level Google Cloud Logging configurations associated with IAM service accounts, used for generating access tokens. +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/423036 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/docs/batched_background_migrations/backfill_has_merge_request_of_vulnerability_reads.yml b/db/docs/batched_background_migrations/backfill_has_merge_request_of_vulnerability_reads.yml new file mode 100644 index 00000000000..c6bf73622f6 --- /dev/null +++ b/db/docs/batched_background_migrations/backfill_has_merge_request_of_vulnerability_reads.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: BackfillHasMergeRequestOfVulnerabilityReads +description: Backfills has_merge_request column for vulnerability_reads table. +feature_category: database +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130952 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/backfill_nuget_normalized_version.yml b/db/docs/batched_background_migrations/backfill_nuget_normalized_version.yml new file mode 100644 index 00000000000..b0ea13472d4 --- /dev/null +++ b/db/docs/batched_background_migrations/backfill_nuget_normalized_version.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: BackfillNugetNormalizedVersion +description: Introduce a batched background migration to backfill the normalized_version column in packages_nuget_metadata table. +feature_category: package_registry +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128675 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/backfill_project_statistics_storage_size_with_recent_size.yml b/db/docs/batched_background_migrations/backfill_project_statistics_storage_size_with_recent_size.yml new file mode 100644 index 00000000000..1ff17fd4099 --- /dev/null +++ b/db/docs/batched_background_migrations/backfill_project_statistics_storage_size_with_recent_size.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: BackfillProjectStatisticsStorageSizeWithRecentSize +description: Refreshes ProjectStatistics to use recent_objects_size for repository_size +feature_category: consumables_cost_management +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128730 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/backfill_user_preferences_with_defaults.yml b/db/docs/batched_background_migrations/backfill_user_preferences_with_defaults.yml new file mode 100644 index 00000000000..bee4b1f38a9 --- /dev/null +++ b/db/docs/batched_background_migrations/backfill_user_preferences_with_defaults.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: BackfillUserPreferencesWithDefaults +description: Backfills the user_preferences table columns with their default values +feature_category: user_profile +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125774 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/backfill_users_with_defaults.yml b/db/docs/batched_background_migrations/backfill_users_with_defaults.yml new file mode 100644 index 00000000000..ecc86fd665c --- /dev/null +++ b/db/docs/batched_background_migrations/backfill_users_with_defaults.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: BackfillUsersWithDefaults +description: Backfills the users table columns with their default values +feature_category: user_profile +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125881 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/backfill_workspace_personal_access_token.yml b/db/docs/batched_background_migrations/backfill_workspace_personal_access_token.yml new file mode 100644 index 00000000000..53433fbb1c7 --- /dev/null +++ b/db/docs/batched_background_migrations/backfill_workspace_personal_access_token.yml @@ -0,0 +1,5 @@ +migration_job_name: BackfillWorkspacePersonalAccessToken +description: Create personal access token for workspaces without one +feature_category: remote_development +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/131516 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/convert_credit_card_validation_data_to_hashes.yml b/db/docs/batched_background_migrations/convert_credit_card_validation_data_to_hashes.yml new file mode 100644 index 00000000000..4835f0ac59f --- /dev/null +++ b/db/docs/batched_background_migrations/convert_credit_card_validation_data_to_hashes.yml @@ -0,0 +1,8 @@ +--- +migration_job_name: ConvertCreditCardValidationDataToHashes +description: | + This migration converts a credit card's expiration_date, last_digits, network & holder_name + to hash and store values in new columns. +feature_category: user_profile +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129350 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/create_compliance_standards_adherence.yml b/db/docs/batched_background_migrations/create_compliance_standards_adherence.yml new file mode 100644 index 00000000000..6ab1282358b --- /dev/null +++ b/db/docs/batched_background_migrations/create_compliance_standards_adherence.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: CreateComplianceStandardsAdherence +description: This migration creates 'project_compliance_standards_adherence' table for existing projects +feature_category: compliance_management +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/413235 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/fix_namespace_ids_of_vulnerability_reads.yml b/db/docs/batched_background_migrations/fix_namespace_ids_of_vulnerability_reads.yml new file mode 100644 index 00000000000..1bee359aef5 --- /dev/null +++ b/db/docs/batched_background_migrations/fix_namespace_ids_of_vulnerability_reads.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: FixNamespaceIdsOfVulnerabilityReads +description: Fixes the data integrity issues for `namespace_id` attribute of `vulnerability_reads` table +feature_category: vulnerability_management +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129244 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/populate_denormalized_columns_for_sbom_occurrences.yml b/db/docs/batched_background_migrations/populate_denormalized_columns_for_sbom_occurrences.yml new file mode 100644 index 00000000000..b85ae1c22d6 --- /dev/null +++ b/db/docs/batched_background_migrations/populate_denormalized_columns_for_sbom_occurrences.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: PopulateDenormalizedColumnsForSbomOccurrences +description: Populates the denormalized columns for `sbom_occurrences` table. +feature_category: dependency_management +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129486 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/sync_scan_result_policies.yml b/db/docs/batched_background_migrations/sync_scan_result_policies.yml new file mode 100644 index 00000000000..16786572139 --- /dev/null +++ b/db/docs/batched_background_migrations/sync_scan_result_policies.yml @@ -0,0 +1,8 @@ +--- +migration_job_name: SyncScanResultPolicies +description: Security policies are stored as YAML files in the security policy project. This migration + syncs existing policies to a DB table scan_result_policies by kicking off Sidekiq sync job + for all security policy configurations. +feature_category: security_policy_management +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128378 +milestone: 16.4 diff --git a/db/docs/batched_background_migrations/update_users_set_external_if_service_account.yml b/db/docs/batched_background_migrations/update_users_set_external_if_service_account.yml new file mode 100644 index 00000000000..1b89359b270 --- /dev/null +++ b/db/docs/batched_background_migrations/update_users_set_external_if_service_account.yml @@ -0,0 +1,6 @@ +--- +migration_job_name: UpdateUsersSetExternalIfServiceAccount +description: Update external value for users of type Service Account +feature_category: system_access +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130597 +milestone: 16.4 diff --git a/db/docs/groups_visits.yml b/db/docs/groups_visits.yml new file mode 100644 index 00000000000..99e424d3946 --- /dev/null +++ b/db/docs/groups_visits.yml @@ -0,0 +1,10 @@ +--- +table_name: groups_visits +classes: +- Users::GroupVisit +feature_categories: +- navigation +description: Tracks group visits so we can suggest groups that are recently and frequently visited. +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123554 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/docs/integrations.yml b/db/docs/integrations.yml index 0619a59556f..d0246caaf12 100644 --- a/db/docs/integrations.yml +++ b/db/docs/integrations.yml @@ -62,4 +62,4 @@ description: | https://gitlab.com/gitlab-org/gitlab/-/commit/1dab19d0d7b25cb5af27b8d10c8b615b2d38c2cf introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64562 milestone: '9.4' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell diff --git a/db/docs/issues.yml b/db/docs/issues.yml index 369dc907d57..a7f24665677 100644 --- a/db/docs/issues.yml +++ b/db/docs/issues.yml @@ -8,4 +8,4 @@ feature_categories: description: Information describing issues, which is also used by the WorkItem class introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/9ba1224867665844b117fa037e1465bb706b3685 milestone: "<6.0" -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell diff --git a/db/docs/members.yml b/db/docs/members.yml index 1a617d27a4b..0d756c18d74 100644 --- a/db/docs/members.yml +++ b/db/docs/members.yml @@ -10,4 +10,4 @@ feature_categories: description: Stores members per namespace introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/3503b504eabf95487fc3fb49df953a7d694da4fe milestone: '7.4' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell diff --git a/db/docs/merge_request_predictions.yml b/db/docs/merge_request_predictions.yml index 9d1ef61c66a..eea738f9526 100644 --- a/db/docs/merge_request_predictions.yml +++ b/db/docs/merge_request_predictions.yml @@ -3,7 +3,7 @@ table_name: merge_request_predictions classes: - MergeRequest::Predictions feature_categories: -- workflow_automation +- code_review_workflow description: Includes machine learning model predictions introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/97622 milestone: '15.4' diff --git a/db/docs/notification_settings.yml b/db/docs/notification_settings.yml index c048163a790..a59131b8fe5 100644 --- a/db/docs/notification_settings.yml +++ b/db/docs/notification_settings.yml @@ -7,4 +7,4 @@ feature_categories: description: User preferences for receiving notifications related to various actions within the application introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/31b0e53015e38e51d9c02cca85c9279600b1bf85 milestone: '8.7' -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell diff --git a/db/docs/p_ci_builds.yml b/db/docs/p_ci_builds.yml index 757d609dd4b..ca01e89de09 100644 --- a/db/docs/p_ci_builds.yml +++ b/db/docs/p_ci_builds.yml @@ -2,15 +2,10 @@ table_name: p_ci_builds classes: - Ci::Bridge -- Ci::Bridge::Partitioned - Ci::Build -- Ci::Build::Partitioned - Ci::Processable -- Ci::Processable::Partitioned - CommitStatus -- CommitStatus::Partitioned - GenericCommitStatus -- GenericCommitStatus::Partitioned feature_categories: - continuous_integration description: Routing table for ci_builds diff --git a/db/docs/packages_nuget_symbols.yml b/db/docs/packages_nuget_symbols.yml new file mode 100644 index 00000000000..d78b52ce826 --- /dev/null +++ b/db/docs/packages_nuget_symbols.yml @@ -0,0 +1,10 @@ +--- +table_name: packages_nuget_symbols +classes: +- Packages::Nuget::Symbol +feature_categories: +- package_registry +description: Nuget package symbols +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129916 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/docs/packages_packages.yml b/db/docs/packages_packages.yml index d2e08350ab7..b7abcf73ab2 100644 --- a/db/docs/packages_packages.yml +++ b/db/docs/packages_packages.yml @@ -1,6 +1,7 @@ --- table_name: packages_packages classes: +- Packages::MlModel::Package - Packages::Package feature_categories: - package_registry diff --git a/db/docs/packages_protection_rules.yml b/db/docs/packages_protection_rules.yml new file mode 100644 index 00000000000..3007c956e26 --- /dev/null +++ b/db/docs/packages_protection_rules.yml @@ -0,0 +1,10 @@ +--- +table_name: packages_protection_rules +classes: +- Packages::Protection::Rule +feature_categories: +- package_registry +description: Represents package protection rules for package registry. +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124776 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/docs/projects_visits.yml b/db/docs/projects_visits.yml new file mode 100644 index 00000000000..23c10fd8568 --- /dev/null +++ b/db/docs/projects_visits.yml @@ -0,0 +1,10 @@ +--- +table_name: projects_visits +classes: +- Users::ProjectVisit +feature_categories: +- navigation +description: Tracks project visits so we can suggest projects that are recently and frequently visited. +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123554 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/docs/web_hooks.yml b/db/docs/web_hooks.yml index 6300a2f7c32..6ab83f4d775 100644 --- a/db/docs/web_hooks.yml +++ b/db/docs/web_hooks.yml @@ -11,4 +11,4 @@ feature_categories: description: Webhooks data with the custom HTTP callbacks that a user defines. introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/edab46e9fa5f568b1423c0021e81d30453d7dc1e milestone: "<6.0" -gitlab_schema: gitlab_main +gitlab_schema: gitlab_main_cell diff --git a/db/docs/workspace_variables.yml b/db/docs/workspace_variables.yml new file mode 100644 index 00000000000..f3eef551225 --- /dev/null +++ b/db/docs/workspace_variables.yml @@ -0,0 +1,10 @@ +--- +table_name: workspace_variables +classes: +- RemoteDevelopment::WorkspaceVariable +feature_categories: +- remote_development +description: Remote Development Workspace variables +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129688 +milestone: '16.4' +gitlab_schema: gitlab_main diff --git a/db/gitlab_schemas/gitlab_main_cell.yaml b/db/gitlab_schemas/gitlab_main_cell.yaml index 1119c10a9b8..53f6f30dfbd 100644 --- a/db/gitlab_schemas/gitlab_main_cell.yaml +++ b/db/gitlab_schemas/gitlab_main_cell.yaml @@ -7,8 +7,5 @@ allow_cross_transactions: - gitlab_internal - gitlab_shared - gitlab_main - # Temporarily allow cross-DB transactions between clusterwide and cell schemas - # This is to be removed once we annotate all cross-DBs between those - - gitlab_main_clusterwide allow_cross_foreign_keys: - gitlab_main 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 diff --git a/db/post_migrate/20220920124709_backfill_internal_on_notes.rb b/db/post_migrate/20220920124709_backfill_internal_on_notes_renamed.rb index 0d737195907..a9de69243f6 100644 --- a/db/post_migrate/20220920124709_backfill_internal_on_notes.rb +++ b/db/post_migrate/20220920124709_backfill_internal_on_notes_renamed.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true -class BackfillInternalOnNotes < Gitlab::Database::Migration[2.0] +# Renamed from BackfillInternalOnNotes to BackfillInternalOnNotesRenamed to avoid collision with an Elasticsearch +# migration from the same name. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129012 +class BackfillInternalOnNotesRenamed < Gitlab::Database::Migration[2.0] MIGRATION = 'BackfillInternalOnNotes' DELAY_INTERVAL = 2.minutes TABLE = :notes diff --git a/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb b/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb index aaea55ce331..c7a7d966911 100644 --- a/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb +++ b/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class RebalancePartitionIdCiPipeline < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes - TABLE = :ci_pipelines - BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 200 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :id, []) + # no-op end end diff --git a/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb b/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb index 6165c266a82..a4514e958f9 100644 --- a/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb +++ b/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class RebalancePartitionIdCiBuild < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes.freeze - TABLE = :ci_builds - BATCH_SIZE = 5_000 - SUB_BATCH_SIZE = 500 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :id, []) + # no-op end end diff --git a/db/post_migrate/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb b/db/post_migrate/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb index 9901e6af4ae..8bf1239146c 100644 --- a/db/post_migrate/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb +++ b/db/post_migrate/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsForCiPipelineVariable < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes.freeze - TABLE = :ci_pipeline_variables - BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 200 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :id, []) + # no-op end end diff --git a/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb b/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb index d1b25639638..7c6ff6c3b4f 100644 --- a/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb +++ b/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsForCiJobArtifact < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes - TABLE = :ci_job_artifacts - BATCH_SIZE = 5_000 - SUB_BATCH_SIZE = 500 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :id, []) + # no-op end end diff --git a/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb b/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb index c3ec614a37f..f05a53dda5f 100644 --- a/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb +++ b/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsForCiStage < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes.freeze - TABLE = :ci_stages - BATCH_SIZE = 3_000 - SUB_BATCH_SIZE = 300 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :id, []) + # no-op end end diff --git a/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb b/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb index d21d986ee31..4ff3d1a2789 100644 --- a/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb +++ b/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsForCiBuildReportResult < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes.freeze - TABLE = :ci_build_report_results - BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 200 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :build_id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :build_id, []) + # no-op end end diff --git a/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb b/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb index 25087dcbfa4..f682527a296 100644 --- a/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb +++ b/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsForCiBuildTraceMetadata < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes.freeze - TABLE = :ci_build_trace_metadata - BATCH_SIZE = 3_000 - SUB_BATCH_SIZE = 300 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :build_id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :build_id, []) + # no-op end end diff --git a/db/post_migrate/20230209140102_fix_partition_ids_for_ci_build_metadata.rb b/db/post_migrate/20230209140102_fix_partition_ids_for_ci_build_metadata.rb index 07fcbcc3ad7..785db1be079 100644 --- a/db/post_migrate/20230209140102_fix_partition_ids_for_ci_build_metadata.rb +++ b/db/post_migrate/20230209140102_fix_partition_ids_for_ci_build_metadata.rb @@ -1,30 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsForCiBuildMetadata < Gitlab::Database::Migration[2.1] - MIGRATION = 'RebalancePartitionId' - DELAY_INTERVAL = 2.minutes - TABLE = :p_ci_builds_metadata - BATCH_SIZE = 5_000 - SUB_BATCH_SIZE = 500 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) + # no-op end def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, TABLE, :id, []) + # no-op end end diff --git a/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb b/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb index 0a201c51467..64f5bc4bb5e 100644 --- a/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb +++ b/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb @@ -1,20 +1,8 @@ # frozen_string_literal: true class FixPartitionIdsForCiJobVariables < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - BATCH_SIZE = 50 - def up - return unless Gitlab.com? - - define_batchable_model(:ci_job_variables) - .where(partition_id: 101) - .each_batch(of: BATCH_SIZE) do |batch| - batch.update_all(partition_id: 100) - sleep 0.1 - end + # no-op end def down diff --git a/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb b/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb index c05b759c2d0..bbacd13389b 100644 --- a/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb +++ b/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb @@ -1,36 +1,11 @@ # frozen_string_literal: true class FixPartitionIdsOnCiSourcesPipelines < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - BATCH_SIZE = 50 - def up - return unless Gitlab.com? - - model = define_batchable_model(:ci_sources_pipelines) - - batch_update_records(model, :partition_id, from: 101, to: 100, source_partition_id: 100) - batch_update_records(model, :source_partition_id, from: 101, to: 100) + # no-op end def down # no-op end - - private - - def batch_update_records(model, column, from:, to:, **updates) - updates.reverse_merge!(column => to) - - model - .where(model.arel_table[column].eq(from)) - .each_batch(of: BATCH_SIZE) { |batch| update_records(batch, updates) } - end - - def update_records(relation, updates) - relation.update_all(updates) - sleep 0.1 - end end diff --git a/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb b/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb index cb7fc04166f..a5a78dcbbd1 100644 --- a/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb +++ b/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb @@ -3,6 +3,9 @@ class CleanupProjectPipelineStatusKey < Gitlab::Database::Migration[2.1] disable_ddl_transaction! + # TODO: to remove after feature-flag in duplicate-jobs client middleware is removed + restrict_gitlab_migration gitlab_schema: :gitlab_main + MIGRATION_WORKER_CLASS = 'BackfillProjectPipelineStatusTtl' def up diff --git a/db/post_migrate/20230802212443_add_current_user_todos_widget_to_epic_work_item_type.rb b/db/post_migrate/20230802212443_add_current_user_todos_widget_to_epic_work_item_type.rb new file mode 100644 index 00000000000..958a5d6edb9 --- /dev/null +++ b/db/post_migrate/20230802212443_add_current_user_todos_widget_to_epic_work_item_type.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +class AddCurrentUserTodosWidgetToEpicWorkItemType < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + EPIC_ENUM_VALUE = 7 + WIDGET_NAME = 'Current user todos' + WIDGET_ENUM_VALUE = 15 + + class MigrationWorkItemType < MigrationRecord + self.table_name = 'work_item_types' + end + + class MigrationWidgetDefinition < MigrationRecord + self.table_name = 'work_item_widget_definitions' + end + + def up + epic_work_item_type = MigrationWorkItemType.find_by(base_type: EPIC_ENUM_VALUE, namespace_id: nil) + + # Epic type should exist in production applications, checking here to avoid failures + # if inconsistent data is present. + return say('Epic work item type does not exist, skipping widget creation') unless epic_work_item_type + + widgets = [ + { + work_item_type_id: epic_work_item_type.id, + name: WIDGET_NAME, + widget_type: WIDGET_ENUM_VALUE + } + ] + + MigrationWidgetDefinition.upsert_all( + widgets, + unique_by: :index_work_item_widget_definitions_on_default_witype_and_name + ) + end + + def down + epic_work_item_type = MigrationWorkItemType.find_by(base_type: EPIC_ENUM_VALUE, namespace_id: nil) + + return say('Epic work item type does not exist, skipping widget removal') unless epic_work_item_type + + widget_definition = MigrationWidgetDefinition.find_by( + work_item_type_id: epic_work_item_type.id, + widget_type: WIDGET_ENUM_VALUE, + name: WIDGET_NAME, + namespace_id: nil + ) + + return say('Widget definition not found, skipping widget removal') unless widget_definition + + widget_definition.destroy + end +end diff --git a/db/post_migrate/20230804122825_add_unique_index_on_uuid_convert_string_to_uuid.rb b/db/post_migrate/20230804122825_add_unique_index_on_uuid_convert_string_to_uuid.rb new file mode 100644 index 00000000000..ac94bca4de4 --- /dev/null +++ b/db/post_migrate/20230804122825_add_unique_index_on_uuid_convert_string_to_uuid.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddUniqueIndexOnUuidConvertStringToUuid < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = "index_vulnerability_occurrences_on_uuid_1" + + def up + add_concurrent_index( + :vulnerability_occurrences, + :uuid_convert_string_to_uuid, + unique: true, + name: INDEX_NAME + ) + end + + def down + remove_concurrent_index_by_name( + :vulnerability_occurrences, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20230804123252_add_unique_index_on_uuid_convert_string_to_uuid_including_vulnerability_id.rb b/db/post_migrate/20230804123252_add_unique_index_on_uuid_convert_string_to_uuid_including_vulnerability_id.rb new file mode 100644 index 00000000000..7906ed48db6 --- /dev/null +++ b/db/post_migrate/20230804123252_add_unique_index_on_uuid_convert_string_to_uuid_including_vulnerability_id.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddUniqueIndexOnUuidConvertStringToUuidIncludingVulnerabilityId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = "index_vuln_findings_on_uuid_including_vuln_id_1" + + def up + execute <<~SQL + CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME} + ON vulnerability_occurrences(uuid_convert_string_to_uuid) + INCLUDE(vulnerability_id) + SQL + end + + def down + remove_concurrent_index_by_name( + :vulnerability_occurrences, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20230808200355_remove_application_settings_dashboard_columns.rb b/db/post_migrate/20230808200355_remove_application_settings_dashboard_columns.rb new file mode 100644 index 00000000000..41a1074cbcf --- /dev/null +++ b/db/post_migrate/20230808200355_remove_application_settings_dashboard_columns.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class RemoveApplicationSettingsDashboardColumns < Gitlab::Database::Migration[2.1] + def change + remove_column :application_settings, :dashboard_enforcement_limit, :integer, default: 0, null: false + remove_column :application_settings, :dashboard_limit_new_namespace_creation_enforcement_date, :date + end +end diff --git a/db/post_migrate/20230809170822_ensure_system_note_metadata_bigint_backfill_is_finished_for_self_managed.rb b/db/post_migrate/20230809170822_ensure_system_note_metadata_bigint_backfill_is_finished_for_self_managed.rb new file mode 100644 index 00000000000..cf157a8b575 --- /dev/null +++ b/db/post_migrate/20230809170822_ensure_system_note_metadata_bigint_backfill_is_finished_for_self_managed.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class EnsureSystemNoteMetadataBigintBackfillIsFinishedForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + return if com_or_dev_or_test_but_not_jh? + + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'system_note_metadata', + column_name: 'id', + job_arguments: [['note_id'], ['note_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230809174702_swap_system_note_metadata_note_id_to_bigint_for_self_managed.rb b/db/post_migrate/20230809174702_swap_system_note_metadata_note_id_to_bigint_for_self_managed.rb new file mode 100644 index 00000000000..65aec4dd5d9 --- /dev/null +++ b/db/post_migrate/20230809174702_swap_system_note_metadata_note_id_to_bigint_for_self_managed.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +class SwapSystemNoteMetadataNoteIdToBigintForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'system_note_metadata' + + def up + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return if columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return unless columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + private + + def swap + # This will replace the existing index_system_note_metadata_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_system_note_metadata_on_note_id_convert_to_bigint' + + # This will replace the existing fk_d83a918cb1 + add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, + name: 'fk_system_note_metadata_note_id_convert_to_bigint', + on_delete: :cascade + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id TO note_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_convert_to_bigint TO note_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_tmp TO note_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:note_id, :note_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + # Swap defaults + change_column_default TABLE_NAME, :note_id, nil + change_column_default TABLE_NAME, :note_id_convert_to_bigint, 0 + + execute 'DROP INDEX IF EXISTS index_system_note_metadata_on_note_id' + rename_index TABLE_NAME, 'index_system_note_metadata_on_note_id_convert_to_bigint', + 'index_system_note_metadata_on_note_id' + + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_d83a918cb1" + rename_constraint(TABLE_NAME, 'fk_system_note_metadata_note_id_convert_to_bigint', 'fk_d83a918cb1') + end + end +end diff --git a/db/post_migrate/20230809203254_ensure_issue_user_mentions_bigint_backfill_is_finished_for_self_managed.rb b/db/post_migrate/20230809203254_ensure_issue_user_mentions_bigint_backfill_is_finished_for_self_managed.rb new file mode 100644 index 00000000000..37d95697f56 --- /dev/null +++ b/db/post_migrate/20230809203254_ensure_issue_user_mentions_bigint_backfill_is_finished_for_self_managed.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class EnsureIssueUserMentionsBigintBackfillIsFinishedForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + return if com_or_dev_or_test_but_not_jh? + + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'issue_user_mentions', + column_name: 'id', + job_arguments: [['note_id'], ['note_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230809210550_swap_issue_user_mentions_note_id_to_bigint_for_self_managed.rb b/db/post_migrate/20230809210550_swap_issue_user_mentions_note_id_to_bigint_for_self_managed.rb new file mode 100644 index 00000000000..f0502a2c08a --- /dev/null +++ b/db/post_migrate/20230809210550_swap_issue_user_mentions_note_id_to_bigint_for_self_managed.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +class SwapIssueUserMentionsNoteIdToBigintForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'issue_user_mentions' + + def up + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return if columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return unless columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + def swap + # This will replace the existing index_issue_user_mentions_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_issue_user_mentions_on_note_id_convert_to_bigint', + where: 'note_id_convert_to_bigint IS NOT NULL' + + # This will replace the existing issue_user_mentions_on_issue_id_and_note_id_index + add_concurrent_index TABLE_NAME, [:issue_id, :note_id_convert_to_bigint], unique: true, + name: 'tmp_issue_user_mentions_on_issue_id_and_note_id_index' + + # This will replace the existing issue_user_mentions_on_issue_id_index + add_concurrent_index TABLE_NAME, :issue_id, unique: true, + name: 'tmp_issue_user_mentions_on_issue_id_index', + where: 'note_id_convert_to_bigint IS NULL' + + # This will replace the existing fk_rails_3861d9fefa + add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, + name: 'fk_issue_user_mentions_note_id_convert_to_bigint', + on_delete: :cascade + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id TO note_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_convert_to_bigint TO note_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_tmp TO note_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:note_id, :note_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + execute 'DROP INDEX IF EXISTS index_issue_user_mentions_on_note_id' + rename_index TABLE_NAME, 'index_issue_user_mentions_on_note_id_convert_to_bigint', + 'index_issue_user_mentions_on_note_id' + + execute 'DROP INDEX IF EXISTS issue_user_mentions_on_issue_id_and_note_id_index' + rename_index TABLE_NAME, 'tmp_issue_user_mentions_on_issue_id_and_note_id_index', + 'issue_user_mentions_on_issue_id_and_note_id_index' + + execute 'DROP INDEX IF EXISTS issue_user_mentions_on_issue_id_index' + rename_index TABLE_NAME, 'tmp_issue_user_mentions_on_issue_id_index', + 'issue_user_mentions_on_issue_id_index' + + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_3861d9fefa" + rename_constraint(TABLE_NAME, 'fk_issue_user_mentions_note_id_convert_to_bigint', 'fk_rails_3861d9fefa') + end + end +end diff --git a/db/post_migrate/20230810112715_ensure_note_diff_files_bigint_backfill_is_finished_for_self_hosts.rb b/db/post_migrate/20230810112715_ensure_note_diff_files_bigint_backfill_is_finished_for_self_hosts.rb new file mode 100644 index 00000000000..f6be8be3008 --- /dev/null +++ b/db/post_migrate/20230810112715_ensure_note_diff_files_bigint_backfill_is_finished_for_self_hosts.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class EnsureNoteDiffFilesBigintBackfillIsFinishedForSelfHosts < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'note_diff_files', + column_name: 'id', + job_arguments: [['diff_note_id'], ['diff_note_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230810113227_swap_note_diff_files_note_id_to_bigint_for_self_hosts.rb b/db/post_migrate/20230810113227_swap_note_diff_files_note_id_to_bigint_for_self_hosts.rb new file mode 100644 index 00000000000..682996234d6 --- /dev/null +++ b/db/post_migrate/20230810113227_swap_note_diff_files_note_id_to_bigint_for_self_hosts.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +class SwapNoteDiffFilesNoteIdToBigintForSelfHosts < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'note_diff_files' + + def up + return if should_skip? + return if temp_column_removed?(TABLE_NAME, :diff_note_id) + return if columns_swapped?(TABLE_NAME, :diff_note_id) + + swap + end + + def down + return if should_skip? + return if temp_column_removed?(TABLE_NAME, :diff_note_id) + return unless columns_swapped?(TABLE_NAME, :diff_note_id) + + swap + end + + def swap + # This will replace the existing index_note_diff_files_on_diff_note_id + add_concurrent_index TABLE_NAME, :diff_note_id_convert_to_bigint, unique: true, + name: 'index_note_diff_files_on_diff_note_id_convert_to_bigint' + + # This will replace the existing fk_rails_3d66047aeb + add_concurrent_foreign_key TABLE_NAME, :notes, column: :diff_note_id_convert_to_bigint, + name: 'fk_note_diff_files_diff_note_id_convert_to_bigint', + on_delete: :cascade + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN diff_note_id TO diff_note_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN diff_note_id_convert_to_bigint TO diff_note_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN diff_note_id_tmp TO diff_note_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:diff_note_id, :diff_note_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + # Swap defaults + change_column_default TABLE_NAME, :diff_note_id, nil + change_column_default TABLE_NAME, :diff_note_id_convert_to_bigint, 0 + + execute 'DROP INDEX IF EXISTS index_note_diff_files_on_diff_note_id' + rename_index TABLE_NAME, 'index_note_diff_files_on_diff_note_id_convert_to_bigint', + 'index_note_diff_files_on_diff_note_id' + + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_3d66047aeb" + rename_constraint(TABLE_NAME, 'fk_note_diff_files_diff_note_id_convert_to_bigint', 'fk_rails_3d66047aeb') + end + end + + def should_skip? + com_or_dev_or_test_but_not_jh? + end +end diff --git a/db/post_migrate/20230810124545_schedule_fixing_namespace_ids_of_vulnerability_reads.rb b/db/post_migrate/20230810124545_schedule_fixing_namespace_ids_of_vulnerability_reads.rb new file mode 100644 index 00000000000..0ff461cc1d1 --- /dev/null +++ b/db/post_migrate/20230810124545_schedule_fixing_namespace_ids_of_vulnerability_reads.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class ScheduleFixingNamespaceIdsOfVulnerabilityReads < Gitlab::Database::Migration[2.1] + MIGRATION = 'FixNamespaceIdsOfVulnerabilityReads' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :vulnerability_reads, + :vulnerability_id, + job_interval: 2.minutes, + batch_size: 10_000, + sub_batch_size: 100 + ) + end + + def down + delete_batched_background_migration(MIGRATION, :vulnerability_reads, :vulnerability_id, []) + end +end diff --git a/db/post_migrate/20230811103457_queue_backfill_nuget_normalized_version.rb b/db/post_migrate/20230811103457_queue_backfill_nuget_normalized_version.rb new file mode 100644 index 00000000000..52e2b7c36eb --- /dev/null +++ b/db/post_migrate/20230811103457_queue_backfill_nuget_normalized_version.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class QueueBackfillNugetNormalizedVersion < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + MIGRATION = "BackfillNugetNormalizedVersion" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 6000 + SUB_BATCH_SIZE = 250 + + def up + queue_batched_background_migration( + MIGRATION, + :packages_nuget_metadata, + :package_id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :packages_nuget_metadata, :package_id, []) + end +end diff --git a/db/post_migrate/20230811185901_remove_application_settings_dashboard_notification_limit_column.rb b/db/post_migrate/20230811185901_remove_application_settings_dashboard_notification_limit_column.rb new file mode 100644 index 00000000000..cfd112316ee --- /dev/null +++ b/db/post_migrate/20230811185901_remove_application_settings_dashboard_notification_limit_column.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveApplicationSettingsDashboardNotificationLimitColumn < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + remove_column :application_settings, :dashboard_notification_limit, :integer, default: 0, null: false + end +end diff --git a/db/post_migrate/20230811211544_backfill_alert_management_prometheus_integrations.rb b/db/post_migrate/20230811211544_backfill_alert_management_prometheus_integrations.rb new file mode 100644 index 00000000000..96d098f2f0a --- /dev/null +++ b/db/post_migrate/20230811211544_backfill_alert_management_prometheus_integrations.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# Migrate Integrations::Prometheus records to 'alert_management_http_integrations', +# corresponding to Metrics Dashboard removal in 16.0. +# See https://gitlab.com/gitlab-org/gitlab/-/issues/338838 for more details. +class BackfillAlertManagementPrometheusIntegrations < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + BATCH_SIZE = 10 + + def up + each_batch_range(:project_alerting_settings, of: BATCH_SIZE) do |min, max| + execute <<~SQL + INSERT INTO alert_management_http_integrations ( + project_id, + encrypted_token, + encrypted_token_iv, + active, + name, + endpoint_identifier, + type_identifier, + created_at, + updated_at + ) SELECT + project_alerting_settings.project_id, + project_alerting_settings.encrypted_token, + project_alerting_settings.encrypted_token_iv, + COALESCE(integrations.active, FALSE), + 'Prometheus', + 'legacy-prometheus', + 1, --type_identifiers { http: 0, prometheus: 1 } + CURRENT_TIMESTAMP, + CURRENT_TIMESTAMP + FROM project_alerting_settings + LEFT JOIN integrations + ON project_alerting_settings.project_id = integrations.project_id + AND integrations.type_new = 'Integrations::Prometheus' + WHERE project_alerting_settings.project_id BETWEEN #{min} AND #{max} + ON CONFLICT DO NOTHING + SQL + end + end + + def down + execute <<~SQL + DELETE FROM alert_management_http_integrations + WHERE type_identifier = 1 --type_identifiers { http: 0, prometheus: 1 } + AND endpoint_identifier = 'legacy-prometheus' + SQL + end +end diff --git a/db/post_migrate/20230815140656_queue_populate_denormalized_columns_for_sbom_occurrences.rb b/db/post_migrate/20230815140656_queue_populate_denormalized_columns_for_sbom_occurrences.rb new file mode 100644 index 00000000000..c27b12c55f0 --- /dev/null +++ b/db/post_migrate/20230815140656_queue_populate_denormalized_columns_for_sbom_occurrences.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class QueuePopulateDenormalizedColumnsForSbomOccurrences < Gitlab::Database::Migration[2.1] + MIGRATION = "PopulateDenormalizedColumnsForSbomOccurrences" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 5_000 + SUB_BATCH_SIZE = 100 + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :sbom_occurrences, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :sbom_occurrences, :id, []) + end +end diff --git a/db/post_migrate/20230815160428_rename_plans_titles_with_legacy_plan_names.rb b/db/post_migrate/20230815160428_rename_plans_titles_with_legacy_plan_names.rb new file mode 100644 index 00000000000..3d4a8064a89 --- /dev/null +++ b/db/post_migrate/20230815160428_rename_plans_titles_with_legacy_plan_names.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RenamePlansTitlesWithLegacyPlanNames < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main_clusterwide + + def up + execute "UPDATE plans SET title = 'Premium' WHERE name = 'premium'" + execute "UPDATE plans SET title = 'Ultimate' WHERE name = 'ultimate'" + end + + def down + # no-op + + # We don't know or even want to revert back to the old plan titles. + end +end diff --git a/db/post_migrate/20230816111730_ensure_id_uniqueness_for_p_ci_builds_v3.rb b/db/post_migrate/20230816111730_ensure_id_uniqueness_for_p_ci_builds_v3.rb new file mode 100644 index 00000000000..c91525e0998 --- /dev/null +++ b/db/post_migrate/20230816111730_ensure_id_uniqueness_for_p_ci_builds_v3.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class EnsureIdUniquenessForPCiBuildsV3 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::SchemaHelpers + + enable_lock_retries! + + TABLE_NAME = :p_ci_builds + FUNCTION_NAME = :assign_p_ci_builds_id_value + TRIGGER_NAME = :assign_p_ci_builds_id_trigger + + def up + return if trigger_exists?(:ci_builds, TRIGGER_NAME) + + change_column_default(TABLE_NAME, :id, nil) + + create_trigger_function(FUNCTION_NAME) do + <<~SQL + IF NEW."id" IS NOT NULL THEN + RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored'; + END IF; + NEW."id" := nextval('ci_builds_id_seq'::regclass); + RETURN NEW; + SQL + end + + Gitlab::Database::PostgresPartitionedTable.each_partition(TABLE_NAME) do |partition| + create_trigger(partition.identifier, TRIGGER_NAME, FUNCTION_NAME, fires: 'BEFORE INSERT') + end + end + + def down + execute(<<~SQL.squish) + ALTER TABLE #{TABLE_NAME} + ALTER COLUMN id SET DEFAULT nextval('ci_builds_id_seq'::regclass); + + DROP FUNCTION IF EXISTS #{FUNCTION_NAME} CASCADE; + SQL + end +end diff --git a/db/post_migrate/20230816152540_ensure_dum_note_id_bigint_backfill_is_finished_for_self_managed.rb b/db/post_migrate/20230816152540_ensure_dum_note_id_bigint_backfill_is_finished_for_self_managed.rb new file mode 100644 index 00000000000..2379fa93ccc --- /dev/null +++ b/db/post_migrate/20230816152540_ensure_dum_note_id_bigint_backfill_is_finished_for_self_managed.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class EnsureDumNoteIdBigintBackfillIsFinishedForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + disable_ddl_transaction! + + def up + return if com_or_dev_or_test_but_not_jh? + + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'design_user_mentions', + column_name: 'id', + job_arguments: [['note_id'], ['note_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230816152639_swap_design_user_mentions_note_id_to_big_int_for_self_managed.rb b/db/post_migrate/20230816152639_swap_design_user_mentions_note_id_to_big_int_for_self_managed.rb new file mode 100644 index 00000000000..9c72bef752f --- /dev/null +++ b/db/post_migrate/20230816152639_swap_design_user_mentions_note_id_to_big_int_for_self_managed.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +class SwapDesignUserMentionsNoteIdToBigIntForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'design_user_mentions' + + def up + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return if columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return unless columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + private + + def swap + # This will replace the existing index_design_user_mentions_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_design_user_mentions_on_note_id_convert_to_bigint' + + # This will replace the existing fk_rails_8de8c6d632 + add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, + name: 'fk_design_user_mentions_note_id_convert_to_bigint', + on_delete: :cascade + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id TO note_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_convert_to_bigint TO note_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_tmp TO note_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:note_id, :note_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + # Swap defaults + change_column_default TABLE_NAME, :note_id, nil + change_column_default TABLE_NAME, :note_id_convert_to_bigint, 0 + + execute 'DROP INDEX IF EXISTS index_design_user_mentions_on_note_id' + rename_index TABLE_NAME, 'index_design_user_mentions_on_note_id_convert_to_bigint', + 'index_design_user_mentions_on_note_id' + + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_8de8c6d632" + rename_constraint(TABLE_NAME, 'fk_design_user_mentions_note_id_convert_to_bigint', 'fk_rails_8de8c6d632') + end + end +end diff --git a/db/post_migrate/20230816210503_ensure_mr_user_mentions_note_id_bigint_backfill_is_finished_for_self_managed.rb b/db/post_migrate/20230816210503_ensure_mr_user_mentions_note_id_bigint_backfill_is_finished_for_self_managed.rb new file mode 100644 index 00000000000..c3971e93526 --- /dev/null +++ b/db/post_migrate/20230816210503_ensure_mr_user_mentions_note_id_bigint_backfill_is_finished_for_self_managed.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class EnsureMrUserMentionsNoteIdBigintBackfillIsFinishedForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + return if com_or_dev_or_test_but_not_jh? + + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'merge_request_user_mentions', + column_name: 'id', + job_arguments: [['note_id'], ['note_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230816213228_swap_merge_request_user_mentions_note_id_to_bigint_for_self_managed.rb b/db/post_migrate/20230816213228_swap_merge_request_user_mentions_note_id_to_bigint_for_self_managed.rb new file mode 100644 index 00000000000..93765da66dd --- /dev/null +++ b/db/post_migrate/20230816213228_swap_merge_request_user_mentions_note_id_to_bigint_for_self_managed.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +class SwapMergeRequestUserMentionsNoteIdToBigintForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'merge_request_user_mentions' + + def up + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return if columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :note_id) + return unless columns_swapped?(TABLE_NAME, :note_id) + + swap + end + + def swap + # This will replace the existing index_merge_request_user_mentions_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_merge_request_user_mentions_note_id_convert_to_bigint', + where: 'note_id_convert_to_bigint IS NOT NULL' + + # This will replace the existing merge_request_user_mentions_on_mr_id_and_note_id_index + add_concurrent_index TABLE_NAME, [:merge_request_id, :note_id_convert_to_bigint], unique: true, + name: 'mr_user_mentions_on_mr_id_and_note_id_convert_to_bigint_index' + + # This will replace the existing merge_request_user_mentions_on_mr_id_index + add_concurrent_index TABLE_NAME, :merge_request_id, unique: true, + name: 'merge_request_user_mentions_on_mr_id_index_convert_to_bigint', + where: 'note_id_convert_to_bigint IS NULL' + + # This will replace the existing fk_rails_c440b9ea31 + add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, + name: 'fk_merge_request_user_mentions_note_id_convert_to_bigint', + on_delete: :cascade + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id TO note_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_convert_to_bigint TO note_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_tmp TO note_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:note_id, :note_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + execute 'DROP INDEX IF EXISTS index_merge_request_user_mentions_on_note_id' + rename_index TABLE_NAME, 'index_merge_request_user_mentions_note_id_convert_to_bigint', + 'index_merge_request_user_mentions_on_note_id' + + execute 'DROP INDEX IF EXISTS merge_request_user_mentions_on_mr_id_and_note_id_index' + rename_index TABLE_NAME, 'mr_user_mentions_on_mr_id_and_note_id_convert_to_bigint_index', + 'merge_request_user_mentions_on_mr_id_and_note_id_index' + + execute 'DROP INDEX IF EXISTS merge_request_user_mentions_on_mr_id_index' + rename_index TABLE_NAME, 'merge_request_user_mentions_on_mr_id_index_convert_to_bigint', + 'merge_request_user_mentions_on_mr_id_index' + + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_c440b9ea31" + rename_constraint(TABLE_NAME, 'fk_merge_request_user_mentions_note_id_convert_to_bigint', 'fk_rails_c440b9ea31') + end + end +end diff --git a/db/post_migrate/20230817050946_backfill_shared_runners_duration_for_project_bigint_conversion.rb b/db/post_migrate/20230817050946_backfill_shared_runners_duration_for_project_bigint_conversion.rb new file mode 100644 index 00000000000..9ad079efb47 --- /dev/null +++ b/db/post_migrate/20230817050946_backfill_shared_runners_duration_for_project_bigint_conversion.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class BackfillSharedRunnersDurationForProjectBigintConversion < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_ci + + TABLE_NAME = :ci_project_monthly_usages + COLUMN_NAMES = %i[shared_runners_duration] + + def up + backfill_conversion_of_integer_to_bigint(TABLE_NAME, COLUMN_NAMES, sub_batch_size: 250) + end + + def down + revert_backfill_conversion_of_integer_to_bigint(TABLE_NAME, COLUMN_NAMES) + end +end diff --git a/db/post_migrate/20230817111753_ensure_events_bigint_backfill_is_finished_for_self_hosts.rb b/db/post_migrate/20230817111753_ensure_events_bigint_backfill_is_finished_for_self_hosts.rb new file mode 100644 index 00000000000..e80676253db --- /dev/null +++ b/db/post_migrate/20230817111753_ensure_events_bigint_backfill_is_finished_for_self_hosts.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class EnsureEventsBigintBackfillIsFinishedForSelfHosts < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'events', + column_name: 'id', + job_arguments: [['target_id'], ['target_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230817111938_swap_events_target_id_to_bigint_for_self_hosts.rb b/db/post_migrate/20230817111938_swap_events_target_id_to_bigint_for_self_hosts.rb new file mode 100644 index 00000000000..52165bf1dd7 --- /dev/null +++ b/db/post_migrate/20230817111938_swap_events_target_id_to_bigint_for_self_hosts.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +class SwapEventsTargetIdToBigintForSelfHosts < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'events' + + def up + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :target_id) + return if columns_swapped?(TABLE_NAME, :target_id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :target_id) + return unless columns_swapped?(TABLE_NAME, :target_id) + + swap + end + + private + + def swap + # This will replace the existing index_events_on_target_type_and_target_id_and_fingerprint + add_concurrent_index TABLE_NAME, [:target_type, :target_id_convert_to_bigint, :fingerprint], + name: :index_events_on_target_type_and_target_id_bigint_fingerprint, + unique: true + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN target_id TO target_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN target_id_convert_to_bigint TO target_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN target_id_tmp TO target_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:target_id, :target_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + execute 'DROP INDEX IF EXISTS index_events_on_target_type_and_target_id_and_fingerprint' + rename_index TABLE_NAME, 'index_events_on_target_type_and_target_id_bigint_fingerprint', + 'index_events_on_target_type_and_target_id_and_fingerprint' + end + end +end diff --git a/db/post_migrate/20230817143507_ensure_award_emoji_bigint_backfill_is_finished_for_self_hosts.rb b/db/post_migrate/20230817143507_ensure_award_emoji_bigint_backfill_is_finished_for_self_hosts.rb new file mode 100644 index 00000000000..de25c03c0d5 --- /dev/null +++ b/db/post_migrate/20230817143507_ensure_award_emoji_bigint_backfill_is_finished_for_self_hosts.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class EnsureAwardEmojiBigintBackfillIsFinishedForSelfHosts < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'award_emoji', + column_name: 'id', + job_arguments: [['awardable_id'], ['awardable_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230817143637_swap_award_emoji_note_id_to_bigint_for_self_hosts.rb b/db/post_migrate/20230817143637_swap_award_emoji_note_id_to_bigint_for_self_hosts.rb new file mode 100644 index 00000000000..d5c28f8a066 --- /dev/null +++ b/db/post_migrate/20230817143637_swap_award_emoji_note_id_to_bigint_for_self_hosts.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +class SwapAwardEmojiNoteIdToBigintForSelfHosts < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'award_emoji' + + def up + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :awardable_id) + return if columns_swapped?(TABLE_NAME, :awardable_id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + return if temp_column_removed?(TABLE_NAME, :awardable_id) + return unless columns_swapped?(TABLE_NAME, :awardable_id) + + swap + end + + private + + def swap + # This will replace the existing idx_award_emoji_on_user_emoji_name_awardable_type_awardable_id + add_concurrent_index TABLE_NAME, [:user_id, :name, :awardable_type, :awardable_id_convert_to_bigint], + name: 'tmp_award_emoji_on_user_emoji_name_awardable_type_awardable_id' + + # This will replace the existing index_award_emoji_on_awardable_type_and_awardable_id + add_concurrent_index TABLE_NAME, [:awardable_type, :awardable_id_convert_to_bigint], + name: 'tmp_index_award_emoji_on_awardable_type_and_awardable_id' + + with_lock_retries(raise_on_exhaustion: true) do + execute "LOCK TABLE #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" + + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN awardable_id TO awardable_id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN awardable_id_convert_to_bigint TO awardable_id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN awardable_id_tmp TO awardable_id_convert_to_bigint" + + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:awardable_id, :awardable_id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + execute 'DROP INDEX IF EXISTS idx_award_emoji_on_user_emoji_name_awardable_type_awardable_id' + rename_index TABLE_NAME, 'tmp_award_emoji_on_user_emoji_name_awardable_type_awardable_id', + 'idx_award_emoji_on_user_emoji_name_awardable_type_awardable_id' + + execute 'DROP INDEX IF EXISTS index_award_emoji_on_awardable_type_and_awardable_id' + rename_index TABLE_NAME, 'tmp_index_award_emoji_on_awardable_type_and_awardable_id', + 'index_award_emoji_on_awardable_type_and_awardable_id' + end + end +end diff --git a/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb b/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb new file mode 100644 index 00000000000..39a45774676 --- /dev/null +++ b/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class PrepareRemovalIndexSuccessDeploymentsOnClusterIdAndEnvironmentId < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_successful_deployments_on_cluster_id_and_environment_id' + + # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/402514 + def up + prepare_async_index_removal :deployments, %i[cluster_id environment_id], name: INDEX_NAME + end + + def down + unprepare_async_index :deployments, %i[cluster_id environment_id], name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230818050946_backfill_shared_runners_duration_for_namespace_bigint_conversion.rb b/db/post_migrate/20230818050946_backfill_shared_runners_duration_for_namespace_bigint_conversion.rb new file mode 100644 index 00000000000..3171008ee3a --- /dev/null +++ b/db/post_migrate/20230818050946_backfill_shared_runners_duration_for_namespace_bigint_conversion.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class BackfillSharedRunnersDurationForNamespaceBigintConversion < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_ci + + TABLE_NAME = :ci_namespace_monthly_usages + COLUMN_NAMES = %i[shared_runners_duration] + + def up + backfill_conversion_of_integer_to_bigint(TABLE_NAME, COLUMN_NAMES, sub_batch_size: 250) + end + + def down + revert_backfill_conversion_of_integer_to_bigint(TABLE_NAME, COLUMN_NAMES) + end +end diff --git a/db/post_migrate/20230818055517_prepare_removal_index_deployments_on_id_where_cluster_id_present.rb b/db/post_migrate/20230818055517_prepare_removal_index_deployments_on_id_where_cluster_id_present.rb new file mode 100644 index 00000000000..c66143809d2 --- /dev/null +++ b/db/post_migrate/20230818055517_prepare_removal_index_deployments_on_id_where_cluster_id_present.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class PrepareRemovalIndexDeploymentsOnIdWhereClusterIdPresent < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_deployments_on_id_where_cluster_id_present' + + # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/402510 + def up + prepare_async_index_removal :deployments, :id, name: INDEX_NAME + end + + def down + unprepare_async_index :deployments, :id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230818083610_queue_backfill_users_with_defaults.rb b/db/post_migrate/20230818083610_queue_backfill_users_with_defaults.rb new file mode 100644 index 00000000000..b027ef10ddc --- /dev/null +++ b/db/post_migrate/20230818083610_queue_backfill_users_with_defaults.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class QueueBackfillUsersWithDefaults < Gitlab::Database::Migration[2.1] + MIGRATION = "BackfillUsersWithDefaults" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 3_000 + SUB_BATCH_SIZE = 200 + MAX_BATCH_SIZE = 10_000 + + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :users, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE, + max_batch_size: MAX_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :users, :id, []) + end +end diff --git a/db/post_migrate/20230818085219_queue_backfill_user_preferences_with_defaults.rb b/db/post_migrate/20230818085219_queue_backfill_user_preferences_with_defaults.rb new file mode 100644 index 00000000000..0651f21f240 --- /dev/null +++ b/db/post_migrate/20230818085219_queue_backfill_user_preferences_with_defaults.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class QueueBackfillUserPreferencesWithDefaults < Gitlab::Database::Migration[2.1] + MIGRATION = "BackfillUserPreferencesWithDefaults" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 3_000 + SUB_BATCH_SIZE = 200 + MAX_BATCH_SIZE = 10_000 + + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :user_preferences, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE, + max_batch_size: MAX_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :user_preferences, :id, []) + end +end diff --git a/db/post_migrate/20230818142801_queue_create_compliance_standards_adherence.rb b/db/post_migrate/20230818142801_queue_create_compliance_standards_adherence.rb new file mode 100644 index 00000000000..33d6dd30e44 --- /dev/null +++ b/db/post_migrate/20230818142801_queue_create_compliance_standards_adherence.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class QueueCreateComplianceStandardsAdherence < Gitlab::Database::Migration[2.1] + MIGRATION = "CreateComplianceStandardsAdherence" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10_000 + SUB_BATCH_SIZE = 500 + + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + return unless Gitlab.ee? # Standards adherence is available only in EE version + + queue_batched_background_migration( + MIGRATION, + :projects, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :projects, :id, []) + end +end diff --git a/db/post_migrate/20230821081603_queue_convert_credit_card_validation_data_to_hashes.rb b/db/post_migrate/20230821081603_queue_convert_credit_card_validation_data_to_hashes.rb new file mode 100644 index 00000000000..00a1840366b --- /dev/null +++ b/db/post_migrate/20230821081603_queue_convert_credit_card_validation_data_to_hashes.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class QueueConvertCreditCardValidationDataToHashes < Gitlab::Database::Migration[2.1] + MIGRATION = "ConvertCreditCardValidationDataToHashes" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 1000 + SUB_BATCH_SIZE = 100 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :user_credit_card_validations, + :user_id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :user_credit_card_validations, :user_id, []) + end +end diff --git a/db/post_migrate/20230822064841_prepare_index_for_org_id_on_projects.rb b/db/post_migrate/20230822064841_prepare_index_for_org_id_on_projects.rb new file mode 100644 index 00000000000..1f822a440a4 --- /dev/null +++ b/db/post_migrate/20230822064841_prepare_index_for_org_id_on_projects.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class PrepareIndexForOrgIdOnProjects < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_projects_on_organization_id' + + def up + prepare_async_index :projects, :organization_id, name: INDEX_NAME + end + + def down + unprepare_async_index :projects, :organization_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230822104028_delete_project_callout_three.rb b/db/post_migrate/20230822104028_delete_project_callout_three.rb new file mode 100644 index 00000000000..9ba9b3f806a --- /dev/null +++ b/db/post_migrate/20230822104028_delete_project_callout_three.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class DeleteProjectCalloutThree < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + BATCH_SIZE = 1000 + ULTIMATE_FEATURE_REMOVAL_BANNER_FEATURE_NAME = 3 + + def up + each_batch_range('user_project_callouts', scope: ->(table) { table.all }, of: BATCH_SIZE) do |min, max| + execute <<~SQL + DELETE FROM user_project_callouts + WHERE feature_name = #{ULTIMATE_FEATURE_REMOVAL_BANNER_FEATURE_NAME} + AND id BETWEEN #{min} AND #{max} + SQL + end + end + + def down + # NO-OP + end +end diff --git a/db/post_migrate/20230822125256_drop_temporary_index_on_vulnerability_reads_dismissal_reason.rb b/db/post_migrate/20230822125256_drop_temporary_index_on_vulnerability_reads_dismissal_reason.rb new file mode 100644 index 00000000000..e1b74a1b46c --- /dev/null +++ b/db/post_migrate/20230822125256_drop_temporary_index_on_vulnerability_reads_dismissal_reason.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class DropTemporaryIndexOnVulnerabilityReadsDismissalReason < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = "tmp_idx_vuln_reads_where_dismissal_reason_null" + DISMISSED_STATE = 2 + + def up + remove_concurrent_index_by_name( + :vulnerability_reads, + INDEX_NAME + ) + end + + def down + add_concurrent_index( + :vulnerability_reads, + %i[id], + where: "state = #{DISMISSED_STATE} AND dismissal_reason IS NULL", + name: INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20230822153124_remove_free_user_cap_email_workers_related_columns.rb b/db/post_migrate/20230822153124_remove_free_user_cap_email_workers_related_columns.rb new file mode 100644 index 00000000000..3ae0459fcdc --- /dev/null +++ b/db/post_migrate/20230822153124_remove_free_user_cap_email_workers_related_columns.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class RemoveFreeUserCapEmailWorkersRelatedColumns < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE_NAME = 'namespace_details' + OVER_LIMIT_CHECK_COLUMN_NAME = 'next_over_limit_check_at' + OVER_LIMIT_CHECK_INDEX = 'index_next_over_limit_check_at_asc_order' + OVER_LIMIT_NOTIFIED_AT_COLUMN_NAME = 'free_user_cap_over_limit_notified_at' + OVER_LIMIT_NOTIFIED_AT_INDEX = 'index_fuc_over_limit_notified_at' + + def up + remove_columns TABLE_NAME, OVER_LIMIT_CHECK_COLUMN_NAME, OVER_LIMIT_NOTIFIED_AT_COLUMN_NAME + end + + def down + unless column_exists?(TABLE_NAME, OVER_LIMIT_CHECK_COLUMN_NAME) + add_column TABLE_NAME, OVER_LIMIT_CHECK_COLUMN_NAME, :datetime_with_timezone + end + + unless column_exists?(TABLE_NAME, OVER_LIMIT_NOTIFIED_AT_COLUMN_NAME) + add_column TABLE_NAME, OVER_LIMIT_NOTIFIED_AT_COLUMN_NAME, :datetime_with_timezone + end + + add_concurrent_index TABLE_NAME, OVER_LIMIT_CHECK_COLUMN_NAME, name: OVER_LIMIT_CHECK_INDEX, + order: { next_over_limit_check_at: 'ASC NULLS FIRST' } + add_concurrent_index TABLE_NAME, OVER_LIMIT_NOTIFIED_AT_COLUMN_NAME, name: OVER_LIMIT_NOTIFIED_AT_INDEX + end +end diff --git a/db/post_migrate/20230822154640_add_async_index_on_merge_requests_target_project_id_and_merged_commit_sha.rb b/db/post_migrate/20230822154640_add_async_index_on_merge_requests_target_project_id_and_merged_commit_sha.rb new file mode 100644 index 00000000000..148a9f4c073 --- /dev/null +++ b/db/post_migrate/20230822154640_add_async_index_on_merge_requests_target_project_id_and_merged_commit_sha.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddAsyncIndexOnMergeRequestsTargetProjectIdAndMergedCommitSha < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_merge_requests_on_target_project_id_and_merged_commit_sha' + INDEX_COLUMNS = %i[target_project_id merged_commit_sha] + + disable_ddl_transaction! + + # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/418822 + def up + prepare_async_index :merge_requests, INDEX_COLUMNS, name: INDEX_NAME + end + + def down + unprepare_async_index :merge_requests, INDEX_COLUMNS, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230822195852_remove_pa_jitsu_related_settings.rb b/db/post_migrate/20230822195852_remove_pa_jitsu_related_settings.rb new file mode 100644 index 00000000000..9d36cbac956 --- /dev/null +++ b/db/post_migrate/20230822195852_remove_pa_jitsu_related_settings.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RemovePaJitsuRelatedSettings < Gitlab::Database::Migration[2.1] + def up + # Changed to a no-op, this migration was reverted after + # an incident during a deploy to staging.gitlab.com + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/16274 + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230823085627_add_temp_index_for_project_statistics_updated_at.rb b/db/post_migrate/20230823085627_add_temp_index_for_project_statistics_updated_at.rb new file mode 100644 index 00000000000..a242413266d --- /dev/null +++ b/db/post_migrate/20230823085627_add_temp_index_for_project_statistics_updated_at.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddTempIndexForProjectStatisticsUpdatedAt < Gitlab::Database::Migration[2.1] + INDEX_PROJECT_STATISTICS_UPDATED_AT = 'tmp_index_project_statistics_updated_at' + + disable_ddl_transaction! + + def up + # Temporary index is to be used to trigger a refresh of project_statistics repository_size + add_concurrent_index :project_statistics, [:project_id, :updated_at], + name: INDEX_PROJECT_STATISTICS_UPDATED_AT, + where: "repository_size > 0" + end + + def down + remove_concurrent_index_by_name :project_statistics, INDEX_PROJECT_STATISTICS_UPDATED_AT + end +end diff --git a/db/post_migrate/20230823090001_queue_backfill_project_statistics_storage_size_with_recent_size.rb b/db/post_migrate/20230823090001_queue_backfill_project_statistics_storage_size_with_recent_size.rb new file mode 100644 index 00000000000..b841e912ebf --- /dev/null +++ b/db/post_migrate/20230823090001_queue_backfill_project_statistics_storage_size_with_recent_size.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class QueueBackfillProjectStatisticsStorageSizeWithRecentSize < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + MIGRATION = "BackfillProjectStatisticsStorageSizeWithRecentSize" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 1000 + SUB_BATCH_SIZE = 100 + + def up + queue_batched_background_migration( + MIGRATION, + :project_statistics, + :project_id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :project_statistics, :project_id, []) + end +end diff --git a/db/post_migrate/20230823140934_add_linked_items_widget_to_ticket_work_item_type.rb b/db/post_migrate/20230823140934_add_linked_items_widget_to_ticket_work_item_type.rb new file mode 100644 index 00000000000..9f97bd8cc0d --- /dev/null +++ b/db/post_migrate/20230823140934_add_linked_items_widget_to_ticket_work_item_type.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +class AddLinkedItemsWidgetToTicketWorkItemType < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + TICKET_ENUM_VALUE = 8 + WIDGET_NAME = 'Linked items' + WIDGET_ENUM_VALUE = 17 + + class MigrationWorkItemType < MigrationRecord + self.table_name = 'work_item_types' + end + + class MigrationWidgetDefinition < MigrationRecord + self.table_name = 'work_item_widget_definitions' + end + + def up + # New instances will not run this migration and add this type via fixtures + # checking if record exists mostly because migration specs will run all migrations + # and that will conflict with the preloaded base work item types + ticket_work_item_type = MigrationWorkItemType.find_by(base_type: TICKET_ENUM_VALUE, namespace_id: nil) + + return say('Ticket work item type does not exist, skipping widget creation') unless ticket_work_item_type + + widgets = [ + { + work_item_type_id: ticket_work_item_type.id, + name: WIDGET_NAME, + widget_type: WIDGET_ENUM_VALUE + } + ] + + MigrationWidgetDefinition.upsert_all( + widgets, + unique_by: :index_work_item_widget_definitions_on_default_witype_and_name + ) + end + + def down + ticket_work_item_type = MigrationWorkItemType.find_by(base_type: TICKET_ENUM_VALUE, namespace_id: nil) + + return say('Ticket work item type does not exist, skipping widget removal') unless ticket_work_item_type + + MigrationWidgetDefinition.where(work_item_type_id: ticket_work_item_type.id, widget_type: WIDGET_ENUM_VALUE) + .delete_all + end +end diff --git a/db/post_migrate/20230823143519_remove_users_notification_settings_user_id_fk.rb b/db/post_migrate/20230823143519_remove_users_notification_settings_user_id_fk.rb new file mode 100644 index 00000000000..2e8b634e108 --- /dev/null +++ b/db/post_migrate/20230823143519_remove_users_notification_settings_user_id_fk.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class RemoveUsersNotificationSettingsUserIdFk < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + FOREIGN_KEY_NAME = "fk_0c95e91db7" + + def up + return unless foreign_key_exists?(:notification_settings, :users, name: FOREIGN_KEY_NAME) + + with_lock_retries do + remove_foreign_key_if_exists(:notification_settings, :users, + name: FOREIGN_KEY_NAME, reverse_lock_order: true) + end + end + + def down + add_concurrent_foreign_key(:notification_settings, :users, + name: FOREIGN_KEY_NAME, column: :user_id, + target_column: :id, on_delete: :cascade) + end +end diff --git a/db/post_migrate/20230823144846_remove_users_members_user_id_fk.rb b/db/post_migrate/20230823144846_remove_users_members_user_id_fk.rb new file mode 100644 index 00000000000..59f97d7c26a --- /dev/null +++ b/db/post_migrate/20230823144846_remove_users_members_user_id_fk.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class RemoveUsersMembersUserIdFk < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + FOREIGN_KEY_NAME = "fk_2e88fb7ce9" + + def up + return unless foreign_key_exists?(:members, :users, name: FOREIGN_KEY_NAME) + + with_lock_retries do + remove_foreign_key_if_exists(:members, :users, + name: FOREIGN_KEY_NAME, reverse_lock_order: true) + end + end + + def down + add_concurrent_foreign_key(:members, :users, + name: FOREIGN_KEY_NAME, column: :user_id, + target_column: :id, on_delete: :cascade) + end +end diff --git a/db/post_migrate/20230823145053_ensure_notes_bigint_backfill_is_finished_for_self_managed.rb b/db/post_migrate/20230823145053_ensure_notes_bigint_backfill_is_finished_for_self_managed.rb new file mode 100644 index 00000000000..c16313bb27d --- /dev/null +++ b/db/post_migrate/20230823145053_ensure_notes_bigint_backfill_is_finished_for_self_managed.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class EnsureNotesBigintBackfillIsFinishedForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + return if com_or_dev_or_test_but_not_jh? + + # Same as was defined in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119913 + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'notes', + column_name: 'id', + job_arguments: [['id'], ['id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230823145126_swap_notes_id_to_bigint_for_self_managed.rb b/db/post_migrate/20230823145126_swap_notes_id_to_bigint_for_self_managed.rb new file mode 100644 index 00000000000..ddfaefc452b --- /dev/null +++ b/db/post_migrate/20230823145126_swap_notes_id_to_bigint_for_self_managed.rb @@ -0,0 +1,183 @@ +# frozen_string_literal: true + +class SwapNotesIdToBigintForSelfManaged < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'notes' + PK_INDEX_NAME = 'index_notes_on_id_convert_to_bigint' + + SECONDARY_INDEXES = [ + { + original_name: :index_notes_on_author_id_and_created_at_and_id, + temporary_name: :index_notes_on_author_id_created_at_id_convert_to_bigint, + columns: [:author_id, :created_at, :id_convert_to_bigint], + options: {} + }, + { + original_name: :index_notes_on_id_where_confidential, + temporary_name: :index_notes_on_id_convert_to_bigint_where_confidential, + columns: [:id_convert_to_bigint], + options: { where: 'confidential = true' } + }, + { + original_name: :index_notes_on_id_where_internal, + temporary_name: :index_notes_on_id_convert_to_bigint_where_internal, + columns: [:id_convert_to_bigint], + options: { where: 'internal = true' } + }, + { + original_name: :index_notes_on_project_id_and_id_and_system_false, + temporary_name: :index_notes_on_project_id_id_convert_to_bigint_system_false, + columns: [:project_id, :id_convert_to_bigint], + options: { where: 'NOT system' } + }, + { + original_name: :note_mentions_temp_index, + temporary_name: :note_mentions_temp_index_convert_to_bigint, + columns: [:id_convert_to_bigint, :noteable_type], + options: { where: "note ~~ '%@%'::text" } + } + ] + + REFERENCING_FOREIGN_KEYS = [ + [:todos, :fk_91d1f47b13, :note_id, :cascade], + [:incident_management_timeline_events, :fk_d606a2a890, :promoted_from_note_id, :nullify], + [:system_note_metadata, :fk_d83a918cb1, :note_id, :cascade], + [:diff_note_positions, :fk_rails_13c7212859, :note_id, :cascade], + [:epic_user_mentions, :fk_rails_1c65976a49, :note_id, :cascade], + [:suggestions, :fk_rails_33b03a535c, :note_id, :cascade], + [:issue_user_mentions, :fk_rails_3861d9fefa, :note_id, :cascade], + [:note_diff_files, :fk_rails_3d66047aeb, :diff_note_id, :cascade], + [:snippet_user_mentions, :fk_rails_4d3f96b2cb, :note_id, :cascade], + [:design_user_mentions, :fk_rails_8de8c6d632, :note_id, :cascade], + [:vulnerability_user_mentions, :fk_rails_a18600f210, :note_id, :cascade], + [:commit_user_mentions, :fk_rails_a6760813e0, :note_id, :cascade], + [:merge_request_user_mentions, :fk_rails_c440b9ea31, :note_id, :cascade], + [:note_metadata, :fk_rails_d853224d37, :note_id, :cascade], + [:alert_management_alert_user_mentions, :fk_rails_eb2de0cdef, :note_id, :cascade], + [:timelogs, :fk_timelogs_note_id, :note_id, :nullify] + ] + + def up + return if com_or_dev_or_test_but_not_jh? + + return if temp_column_removed?(TABLE_NAME, :id) + + return if columns_swapped?(TABLE_NAME, :id) + + swap + end + + def down + return if com_or_dev_or_test_but_not_jh? + + return if temp_column_removed?(TABLE_NAME, :id) + + return unless columns_swapped?(TABLE_NAME, :id) + + swap + end + + private + + def swap + create_indexes + + create_referencing_foreign_keys + + replace_referencing_foreign_keys + + with_lock_retries(raise_on_exhaustion: true) do + # Swap the original and new column names + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN id TO id_tmp" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN id_convert_to_bigint TO id" + execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN id_tmp TO id_convert_to_bigint" + + # Reset the function so PG drops the plan cache for the incorrect integer type + function_name = Gitlab::Database::UnidirectionalCopyTrigger + .on_table(TABLE_NAME, connection: connection) + .name(:id, :id_convert_to_bigint) + execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL" + + # Swap defaults of the two columns, and change ownership of the sequence to the new id + execute "ALTER SEQUENCE notes_id_seq OWNED BY #{TABLE_NAME}.id" + change_column_default TABLE_NAME, :id, -> { "nextval('notes_id_seq'::regclass)" } + change_column_default TABLE_NAME, :id_convert_to_bigint, 0 + + # Swap the PK constraint from the original column to the new column. + # We deliberately don't CASCADE here because the old FKs should be removed already + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT notes_pkey" + rename_index TABLE_NAME, PK_INDEX_NAME, 'notes_pkey' + execute "ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT notes_pkey PRIMARY KEY USING INDEX notes_pkey" + + rename_secondary_indexes # rubocop:disable Migration/WithLockRetriesDisallowedMethod + end + end + + # Copy existing indexes from the original column to the new column + def create_indexes + add_concurrent_index TABLE_NAME, :id_convert_to_bigint, unique: true, name: PK_INDEX_NAME + + SECONDARY_INDEXES.each do |index_definition| + options = index_definition[:options] + options[:name] = index_definition[:temporary_name] + + add_concurrent_index(TABLE_NAME, index_definition[:columns], options) + end + end + + # Remove old column indexes and change new column indexes to have the original names + def rename_secondary_indexes + SECONDARY_INDEXES.each do |index_definition| + remove_index(TABLE_NAME, name: index_definition[:original_name], if_exists: true) # rubocop:disable Migration/RemoveIndex + rename_index(TABLE_NAME, index_definition[:temporary_name], index_definition[:original_name]) + end + end + + # Copy existing FKs from the original column to the new column + # + # @note Don't attempt to create the FK if one already exists from the table to the new column. + # The check in `add_concurrent_foreign_key` already checks for this, but it looks for the foreign key + # with the new name only (containing the `_tmp` suffix). Since we might partially rename FKs and re-run + # the migration, we also have to check and see if a FK exists on those columns that might not + # match the `_tmp` name. + def create_referencing_foreign_keys + REFERENCING_FOREIGN_KEYS.each do |(from_table, name, column, on_delete)| + next if foreign_key_exists?(from_table, TABLE_NAME, column: column, + primary_key: :id_convert_to_bigint, name: name) + + add_concurrent_foreign_key( + from_table, + TABLE_NAME, + column: column, + target_column: :id_convert_to_bigint, + name: "#{name}_tmp", + on_delete: on_delete, + reverse_lock_order: true + ) + end + end + + # Remove existing FKs from the referencing tables, so we don't have to lock on them when we drop the existing PK + # + # @note Don't attempt to replace the FK unless it exists and points at the original column. This could happen if the + # migration is re-run due to failing midway. + def replace_referencing_foreign_keys + REFERENCING_FOREIGN_KEYS.each do |(from_table, name, column, _)| + next unless foreign_key_exists?(from_table, TABLE_NAME, column: column, primary_key: :id, name: name) + + with_lock_retries(raise_on_exhaustion: true) do + temporary_name = "#{name}_tmp" + + # Explicitly lock table in order of parent, child to attempt to avoid deadlocks + execute "LOCK TABLE #{TABLE_NAME}, #{from_table} IN ACCESS EXCLUSIVE MODE" + + remove_foreign_key(from_table, TABLE_NAME, column: column, primary_key: :id, name: name) + + rename_constraint(from_table, temporary_name, name) + end + end + end +end diff --git a/db/post_migrate/20230823161514_remove_namespaces_routes_namespace_id_fk.rb b/db/post_migrate/20230823161514_remove_namespaces_routes_namespace_id_fk.rb new file mode 100644 index 00000000000..a640ac686ed --- /dev/null +++ b/db/post_migrate/20230823161514_remove_namespaces_routes_namespace_id_fk.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class RemoveNamespacesRoutesNamespaceIdFk < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + FOREIGN_KEY_NAME = "fk_bb2e5b8968" + + def up + return unless foreign_key_exists?(:routes, :namespaces, name: FOREIGN_KEY_NAME) + + with_lock_retries do + remove_foreign_key_if_exists(:routes, :namespaces, + name: FOREIGN_KEY_NAME, reverse_lock_order: true) + end + end + + def down + add_concurrent_foreign_key(:routes, :namespaces, + name: FOREIGN_KEY_NAME, column: :namespace_id, + target_column: :id, on_delete: :cascade) + end +end diff --git a/db/post_migrate/20230823194111_remove_pages_deployments_project_id_path_prefix_unique_index.rb b/db/post_migrate/20230823194111_remove_pages_deployments_project_id_path_prefix_unique_index.rb new file mode 100644 index 00000000000..9390a06b0bb --- /dev/null +++ b/db/post_migrate/20230823194111_remove_pages_deployments_project_id_path_prefix_unique_index.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class RemovePagesDeploymentsProjectIdPathPrefixUniqueIndex < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :pages_deployments, + 'index_pages_deployments_unique_path_prefix_by_project' + end + + def down + # no op + end +end diff --git a/db/post_migrate/20230825085648_ensure_backfill_for_ci_stages_pipeline_id_is_finished.rb b/db/post_migrate/20230825085648_ensure_backfill_for_ci_stages_pipeline_id_is_finished.rb new file mode 100644 index 00000000000..3dabd352a1b --- /dev/null +++ b/db/post_migrate/20230825085648_ensure_backfill_for_ci_stages_pipeline_id_is_finished.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class EnsureBackfillForCiStagesPipelineIdIsFinished < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_ci + disable_ddl_transaction! + + TABLE_NAME = :ci_stages + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: TABLE_NAME, + column_name: 'id', + job_arguments: [['pipeline_id'], ['pipeline_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230825085719_create_async_index_for_ci_stages_pipeline_id.rb b/db/post_migrate/20230825085719_create_async_index_for_ci_stages_pipeline_id.rb new file mode 100644 index 00000000000..a517d96815a --- /dev/null +++ b/db/post_migrate/20230825085719_create_async_index_for_ci_stages_pipeline_id.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class CreateAsyncIndexForCiStagesPipelineId < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_stages + INDEXES = { + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [ + [:pipeline_id_convert_to_bigint, :name], { unique: true } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint' => [ + [:pipeline_id_convert_to_bigint], {} + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [ + [:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [ + [:pipeline_id_convert_to_bigint, :position], {} + ] + } + + def up + INDEXES.each do |index_name, (columns, options)| + prepare_async_index TABLE_NAME, columns, name: index_name, **options + end + end + + def down + INDEXES.each do |index_name, (columns, options)| + unprepare_async_index TABLE_NAME, columns, name: index_name, **options + end + end +end diff --git a/db/post_migrate/20230829120720_index_finding_id_for_vulnerabilities.rb b/db/post_migrate/20230829120720_index_finding_id_for_vulnerabilities.rb new file mode 100644 index 00000000000..2556134658f --- /dev/null +++ b/db/post_migrate/20230829120720_index_finding_id_for_vulnerabilities.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class IndexFindingIdForVulnerabilities < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_vulnerabilities_on_finding_id' + + # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/423541 + def up + prepare_async_index :vulnerabilities, :finding_id, name: INDEX_NAME + end + + def down + unprepare_async_index :vulnerabilities, INDEX_NAME + end +end diff --git a/db/post_migrate/20230830121830_queue_update_users_set_external_if_service_account.rb b/db/post_migrate/20230830121830_queue_update_users_set_external_if_service_account.rb new file mode 100644 index 00000000000..cffc9bfba39 --- /dev/null +++ b/db/post_migrate/20230830121830_queue_update_users_set_external_if_service_account.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class QueueUpdateUsersSetExternalIfServiceAccount < Gitlab::Database::Migration[2.1] + MIGRATION = "UpdateUsersSetExternalIfServiceAccount" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 1000 + SUB_BATCH_SIZE = 100 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + queue_batched_background_migration( + MIGRATION, + :users, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :users, :id, []) + end +end diff --git a/db/post_migrate/20230831084632_queue_sync_scan_result_policies.rb b/db/post_migrate/20230831084632_queue_sync_scan_result_policies.rb new file mode 100644 index 00000000000..983c97d75f3 --- /dev/null +++ b/db/post_migrate/20230831084632_queue_sync_scan_result_policies.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class QueueSyncScanResultPolicies < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + MIGRATION = "SyncScanResultPolicies" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 1000 + SUB_BATCH_SIZE = 100 + + def up + queue_batched_background_migration( + MIGRATION, + :security_orchestration_policy_configurations, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :security_orchestration_policy_configurations, :id, []) + end +end diff --git a/db/post_migrate/20230831101144_index_org_id_and_id_on_organization_user.rb b/db/post_migrate/20230831101144_index_org_id_and_id_on_organization_user.rb new file mode 100644 index 00000000000..0f835e08a54 --- /dev/null +++ b/db/post_migrate/20230831101144_index_org_id_and_id_on_organization_user.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class IndexOrgIdAndIdOnOrganizationUser < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_organization_users_on_organization_id_and_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :organization_users, %i[organization_id id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :organization_users, INDEX_NAME + end +end diff --git a/db/post_migrate/20230901033401_ensure_backfill_for_ci_sources_pipelines_pipeline_id_is_finished.rb b/db/post_migrate/20230901033401_ensure_backfill_for_ci_sources_pipelines_pipeline_id_is_finished.rb new file mode 100644 index 00000000000..686dcdc3585 --- /dev/null +++ b/db/post_migrate/20230901033401_ensure_backfill_for_ci_sources_pipelines_pipeline_id_is_finished.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class EnsureBackfillForCiSourcesPipelinesPipelineIdIsFinished < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_ci + disable_ddl_transaction! + + TABLE_NAME = :ci_sources_pipelines + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: TABLE_NAME, + column_name: 'id', + job_arguments: [ + %w[pipeline_id source_pipeline_id], + %w[pipeline_id_convert_to_bigint source_pipeline_id_convert_to_bigint] + ] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230901044003_add_sync_foreign_key_for_ci_pipeline_variables_pipeline_id.rb b/db/post_migrate/20230901044003_add_sync_foreign_key_for_ci_pipeline_variables_pipeline_id.rb new file mode 100644 index 00000000000..d640b68c118 --- /dev/null +++ b/db/post_migrate/20230901044003_add_sync_foreign_key_for_ci_pipeline_variables_pipeline_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddSyncForeignKeyForCiPipelineVariablesPipelineId < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_pipeline_variables + COLUMN_NAME = :pipeline_id + FK_NAME = :temp_fk_rails_8d3b04e3e1 + + def up + validate_foreign_key TABLE_NAME, COLUMN_NAME, name: FK_NAME + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230901050458_ensure_backfill_for_ci_pipelines_auto_canceled_by_id_is_finished.rb b/db/post_migrate/20230901050458_ensure_backfill_for_ci_pipelines_auto_canceled_by_id_is_finished.rb new file mode 100644 index 00000000000..ce0da3707d0 --- /dev/null +++ b/db/post_migrate/20230901050458_ensure_backfill_for_ci_pipelines_auto_canceled_by_id_is_finished.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class EnsureBackfillForCiPipelinesAutoCanceledByIdIsFinished < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_ci + disable_ddl_transaction! + + TABLE_NAME = :ci_pipelines + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: TABLE_NAME, + column_name: 'id', + job_arguments: [ + %w[auto_canceled_by_id], + %w[auto_canceled_by_id_convert_to_bigint] + ] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230901054536_ensure_backfill_for_ci_pipeline_chat_data_pipeline_id_is_finished.rb b/db/post_migrate/20230901054536_ensure_backfill_for_ci_pipeline_chat_data_pipeline_id_is_finished.rb new file mode 100644 index 00000000000..e600456662e --- /dev/null +++ b/db/post_migrate/20230901054536_ensure_backfill_for_ci_pipeline_chat_data_pipeline_id_is_finished.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class EnsureBackfillForCiPipelineChatDataPipelineIdIsFinished < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_ci + disable_ddl_transaction! + + TABLE_NAME = :ci_pipeline_chat_data + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: TABLE_NAME, + column_name: 'id', + job_arguments: [['pipeline_id'], ['pipeline_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230901064536_add_concurrent_index_for_ci_pipeline_chat_data_pipeline_id_convert_to_bigint.rb b/db/post_migrate/20230901064536_add_concurrent_index_for_ci_pipeline_chat_data_pipeline_id_convert_to_bigint.rb new file mode 100644 index 00000000000..35b5fca789b --- /dev/null +++ b/db/post_migrate/20230901064536_add_concurrent_index_for_ci_pipeline_chat_data_pipeline_id_convert_to_bigint.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddConcurrentIndexForCiPipelineChatDataPipelineIdConvertToBigint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = "index_ci_pipeline_chat_data_on_pipeline_id_convert_to_bigint" + TABLE_NAME = :ci_pipeline_chat_data + COLUMN_NAME = :pipeline_id_convert_to_bigint + + def up + add_concurrent_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME, unique: true + end + + def down + remove_concurrent_index_by_name TABLE_NAME, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230901064537_remove_namespace_details_dashboard_fields.rb b/db/post_migrate/20230901064537_remove_namespace_details_dashboard_fields.rb new file mode 100644 index 00000000000..9dca08c90ef --- /dev/null +++ b/db/post_migrate/20230901064537_remove_namespace_details_dashboard_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class RemoveNamespaceDetailsDashboardFields < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + remove_column :namespace_details, :dashboard_notification_at, :datetime_with_timezone + remove_column :namespace_details, :dashboard_enforcement_at, :datetime_with_timezone + end +end diff --git a/db/post_migrate/20230902033401_create_async_index_for_ci_sources_pipelines_pipeline_id.rb b/db/post_migrate/20230902033401_create_async_index_for_ci_sources_pipelines_pipeline_id.rb new file mode 100644 index 00000000000..60d26bf1962 --- /dev/null +++ b/db/post_migrate/20230902033401_create_async_index_for_ci_sources_pipelines_pipeline_id.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class CreateAsyncIndexForCiSourcesPipelinesPipelineId < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_sources_pipelines + INDEXES = { + 'index_ci_sources_pipelines_on_pipeline_id_bigint' => [ + [:pipeline_id_convert_to_bigint], {} + ], + 'index_ci_sources_pipelines_on_source_pipeline_id_bigint' => [ + [:source_pipeline_id_convert_to_bigint], {} + ] + } + + def up + INDEXES.each do |index_name, (columns, options)| + prepare_async_index TABLE_NAME, columns, name: index_name, **options + end + end + + def down + INDEXES.each do |index_name, (columns, options)| + unprepare_async_index TABLE_NAME, columns, name: index_name, **options + end + end +end diff --git a/db/post_migrate/20230902050458_create_async_index_for_ci_pipelines_auto_canceled_by_id.rb b/db/post_migrate/20230902050458_create_async_index_for_ci_pipelines_auto_canceled_by_id.rb new file mode 100644 index 00000000000..4eb8ea918b8 --- /dev/null +++ b/db/post_migrate/20230902050458_create_async_index_for_ci_pipelines_auto_canceled_by_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CreateAsyncIndexForCiPipelinesAutoCanceledById < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_pipelines + INDEX_NAME = 'index_ci_pipelines_on_auto_canceled_by_id_bigint' + COLUMN_NAME = :auto_canceled_by_id_convert_to_bigint + + def up + prepare_async_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME + end + + def down + unprepare_async_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230902054536_ensure_backfill_for_ci_pipeline_messages_pipeline_id_is_finished.rb b/db/post_migrate/20230902054536_ensure_backfill_for_ci_pipeline_messages_pipeline_id_is_finished.rb new file mode 100644 index 00000000000..41806f14c3d --- /dev/null +++ b/db/post_migrate/20230902054536_ensure_backfill_for_ci_pipeline_messages_pipeline_id_is_finished.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class EnsureBackfillForCiPipelineMessagesPipelineIdIsFinished < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_ci + disable_ddl_transaction! + + TABLE_NAME = :ci_pipeline_messages + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: TABLE_NAME, + column_name: 'id', + job_arguments: [['pipeline_id'], ['pipeline_id_convert_to_bigint']] + ) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230903064536_concurrent_index_for_ci_pipeline_messages_pipeline_id_convert_to_bigint.rb b/db/post_migrate/20230903064536_concurrent_index_for_ci_pipeline_messages_pipeline_id_convert_to_bigint.rb new file mode 100644 index 00000000000..0444239d934 --- /dev/null +++ b/db/post_migrate/20230903064536_concurrent_index_for_ci_pipeline_messages_pipeline_id_convert_to_bigint.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class ConcurrentIndexForCiPipelineMessagesPipelineIdConvertToBigint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = "index_ci_pipeline_messages_on_pipeline_id_convert_to_bigint" + TABLE_NAME = :ci_pipeline_messages + COLUMN_NAME = :pipeline_id_convert_to_bigint + + def up + add_concurrent_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end +end diff --git a/db/post_migrate/20230903064537_add_ci_job_artifacts_file_final_path_index.rb b/db/post_migrate/20230903064537_add_ci_job_artifacts_file_final_path_index.rb new file mode 100644 index 00000000000..e1e5694f4d4 --- /dev/null +++ b/db/post_migrate/20230903064537_add_ci_job_artifacts_file_final_path_index.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddCiJobArtifactsFileFinalPathIndex < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_ci_job_artifacts_on_file_final_path' + WHERE_CLAUSE = 'file_final_path IS NOT NULL' + + # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/423990 + def up + prepare_async_index :ci_job_artifacts, :file_final_path, name: INDEX_NAME, where: WHERE_CLAUSE + end + + def down + unprepare_async_index :ci_job_artifacts, :file_final_path, name: INDEX_NAME, where: WHERE_CLAUSE + end +end diff --git a/db/post_migrate/20230904100544_drop_index_deployments_on_id_where_cluster_id_present.rb b/db/post_migrate/20230904100544_drop_index_deployments_on_id_where_cluster_id_present.rb new file mode 100644 index 00000000000..888fb7da9c3 --- /dev/null +++ b/db/post_migrate/20230904100544_drop_index_deployments_on_id_where_cluster_id_present.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexDeploymentsOnIdWhereClusterIdPresent < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_deployments_on_id_where_cluster_id_present' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :deployments, name: INDEX_NAME + end + + def down + # This is based on the following `CREATE INDEX` command in db/init_structure.sql: + # CREATE INDEX index_deployments_on_id_where_cluster_id_present ON deployments + # USING btree (id) WHERE (cluster_id IS NOT NULL); + add_concurrent_index :deployments, :id, name: INDEX_NAME, where: 'cluster_id IS NOT NULL' + end +end diff --git a/db/post_migrate/20230904103804_drop_index_successful_deployments_on_cluster_id_and_environment_id.rb b/db/post_migrate/20230904103804_drop_index_successful_deployments_on_cluster_id_and_environment_id.rb new file mode 100644 index 00000000000..e8f0a7b30b5 --- /dev/null +++ b/db/post_migrate/20230904103804_drop_index_successful_deployments_on_cluster_id_and_environment_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexSuccessfulDeploymentsOnClusterIdAndEnvironmentId < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_successful_deployments_on_cluster_id_and_environment_id' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :deployments, name: INDEX_NAME + end + + def down + # This is based on the following `CREATE INDEX` command in db/init_structure.sql: + # CREATE INDEX index_successful_deployments_on_cluster_id_and_environment_id ON deployments + # USING btree (cluster_id, environment_id) WHERE (status = 2); + add_concurrent_index :deployments, %i[cluster_id environment_id], name: INDEX_NAME, where: 'status = 2' + end +end diff --git a/db/post_migrate/20230905071915_prepare_async_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb b/db/post_migrate/20230905071915_prepare_async_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb new file mode 100644 index 00000000000..ce576704d4c --- /dev/null +++ b/db/post_migrate/20230905071915_prepare_async_foreign_key_for_ci_pipeline_messages_pipeline_id_bigint.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class PrepareAsyncForeignKeyForCiPipelineMessagesPipelineIdBigint < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_pipeline_messages + COLUMN_NAME = :pipeline_id_convert_to_bigint + FK_NAME = :fk_0946fea681 + + def up + prepare_async_foreign_key_validation TABLE_NAME, COLUMN_NAME, name: FK_NAME + end + + def down + unprepare_async_foreign_key_validation TABLE_NAME, COLUMN_NAME, name: FK_NAME + end +end diff --git a/db/post_migrate/20230905091059_sync_index_for_ci_stages_pipeline_id_bigint.rb b/db/post_migrate/20230905091059_sync_index_for_ci_stages_pipeline_id_bigint.rb new file mode 100644 index 00000000000..2c42782c576 --- /dev/null +++ b/db/post_migrate/20230905091059_sync_index_for_ci_stages_pipeline_id_bigint.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class SyncIndexForCiStagesPipelineIdBigint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE_NAME = :ci_stages + INDEXES = { + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [ + [:pipeline_id_convert_to_bigint, :name], { unique: true } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint' => [ + [:pipeline_id_convert_to_bigint], {} + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [ + [:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [ + [:pipeline_id_convert_to_bigint, :position], {} + ] + } + + def up + INDEXES.each do |index_name, (columns, options)| + add_concurrent_index TABLE_NAME, columns, name: index_name, **options + end + end + + def down + INDEXES.each do |index_name, (_columns, _options)| + remove_concurrent_index_by_name TABLE_NAME, index_name + end + end +end diff --git a/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb b/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb new file mode 100644 index 00000000000..13c76a3c2de --- /dev/null +++ b/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddIndexToViolationsOnTargetProjId < Gitlab::Database::Migration[2.1] + TABLE_NAME = 'merge_requests_compliance_violations' + # Use funciton based naming as suggested in docs: + # https://docs.gitlab.com/ee/development/migration_style_guide.html#truncate-long-index-names + INDEX_NAME = 'i_compliance_violations_for_export' + + def up + prepare_async_index TABLE_NAME, [:target_project_id, :id], name: INDEX_NAME + end + + def down + unprepare_async_index TABLE_NAME, INDEX_NAME + end +end diff --git a/db/post_migrate/20230907155247_queue_backfill_has_merge_request_of_vulnerability_reads.rb b/db/post_migrate/20230907155247_queue_backfill_has_merge_request_of_vulnerability_reads.rb new file mode 100644 index 00000000000..fe939b4aaa0 --- /dev/null +++ b/db/post_migrate/20230907155247_queue_backfill_has_merge_request_of_vulnerability_reads.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class QueueBackfillHasMergeRequestOfVulnerabilityReads < Gitlab::Database::Migration[2.1] + MIGRATION_NAME = 'BackfillHasMergeRequestOfVulnerabilityReads' + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10_000 + SUB_BATCH_SIZE = 200 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + queue_batched_background_migration( + MIGRATION_NAME, + :vulnerability_reads, + :vulnerability_id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION_NAME, :vulnerability_reads, :vulnerability_id, []) + end +end diff --git a/db/post_migrate/20230907204731_add_index_to_sbom_occurrences_licenses.rb b/db/post_migrate/20230907204731_add_index_to_sbom_occurrences_licenses.rb new file mode 100644 index 00000000000..9ed60941c96 --- /dev/null +++ b/db/post_migrate/20230907204731_add_index_to_sbom_occurrences_licenses.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddIndexToSbomOccurrencesLicenses < Gitlab::Database::Migration[2.1] + INDEX_NAME = "index_sbom_occurrences_on_licenses_spdx_identifier" + + disable_ddl_transaction! + + def up + return if index_exists_by_name?(:sbom_occurrences, INDEX_NAME) + + disable_statement_timeout do + execute <<~SQL + CREATE INDEX CONCURRENTLY #{INDEX_NAME} + ON sbom_occurrences + USING BTREE (project_id, (licenses#>'{0,spdx_identifier}'), (licenses#>'{1,spdx_identifier}')) + SQL + end + end + + def down + remove_concurrent_index_by_name :sbom_occurrences, INDEX_NAME + end +end diff --git a/db/post_migrate/20230908072558_analyze_p_ci_runner_machine_builds.rb b/db/post_migrate/20230908072558_analyze_p_ci_runner_machine_builds.rb new file mode 100644 index 00000000000..5fb99640764 --- /dev/null +++ b/db/post_migrate/20230908072558_analyze_p_ci_runner_machine_builds.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AnalyzePCiRunnerMachineBuilds < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + disable_statement_timeout do + execute('ANALYZE VERBOSE p_ci_runner_machine_builds;') + end + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230908072612_analyze_p_ci_job_annotations.rb b/db/post_migrate/20230908072612_analyze_p_ci_job_annotations.rb new file mode 100644 index 00000000000..7bdc1dcb58d --- /dev/null +++ b/db/post_migrate/20230908072612_analyze_p_ci_job_annotations.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AnalyzePCiJobAnnotations < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + disable_statement_timeout do + execute('ANALYZE VERBOSE p_ci_job_annotations;') + end + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230908072626_analyze_p_ci_builds_metadata.rb b/db/post_migrate/20230908072626_analyze_p_ci_builds_metadata.rb new file mode 100644 index 00000000000..4ba75d9e6bd --- /dev/null +++ b/db/post_migrate/20230908072626_analyze_p_ci_builds_metadata.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AnalyzePCiBuildsMetadata < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + disable_statement_timeout do + execute('ANALYZE VERBOSE p_ci_builds_metadata;') + end + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230908072639_analyze_p_ci_builds.rb b/db/post_migrate/20230908072639_analyze_p_ci_builds.rb new file mode 100644 index 00000000000..f1c68b657b9 --- /dev/null +++ b/db/post_migrate/20230908072639_analyze_p_ci_builds.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AnalyzePCiBuilds < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + disable_statement_timeout do + execute('ANALYZE VERBOSE p_ci_builds;') + end + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230909120000_queue_backfill_workspace_personal_access_token.rb b/db/post_migrate/20230909120000_queue_backfill_workspace_personal_access_token.rb new file mode 100644 index 00000000000..5a746d97493 --- /dev/null +++ b/db/post_migrate/20230909120000_queue_backfill_workspace_personal_access_token.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class QueueBackfillWorkspacePersonalAccessToken < Gitlab::Database::Migration[2.1] + MIGRATION = "BackfillWorkspacePersonalAccessToken" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 100 + SUB_BATCH_SIZE = 10 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + queue_batched_background_migration( + MIGRATION, + :workspaces, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :workspaces, :id, []) + end +end diff --git a/db/post_migrate/20230913100953_create_supporting_index_for_uuid_type_casting.rb b/db/post_migrate/20230913100953_create_supporting_index_for_uuid_type_casting.rb new file mode 100644 index 00000000000..232aca06bb2 --- /dev/null +++ b/db/post_migrate/20230913100953_create_supporting_index_for_uuid_type_casting.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class CreateSupportingIndexForUuidTypeCasting < Gitlab::Database::Migration[2.1] + TABLE_NAME = :vulnerability_occurrences + INDEX_NAME = "tmp_index_vulnerability_occurrences_uuid_cast" + + def up + index_sql = <<~SQL + CREATE INDEX CONCURRENTLY #{INDEX_NAME} + ON #{TABLE_NAME}((uuid::uuid)) + SQL + + # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/425037 + prepare_async_index_from_sql(index_sql) + end + + def down + unprepare_async_index_by_name( + TABLE_NAME, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20230913115113_add_prepared_at_created_at_index_async.rb b/db/post_migrate/20230913115113_add_prepared_at_created_at_index_async.rb new file mode 100644 index 00000000000..2e751463f8b --- /dev/null +++ b/db/post_migrate/20230913115113_add_prepared_at_created_at_index_async.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddPreparedAtCreatedAtIndexAsync < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_merge_requests_id_created_at_prepared_at' + + def up + add_concurrent_index :merge_requests, [:created_at, :id], name: INDEX_NAME, where: "prepared_at IS NULL" + end + + def down + remove_concurrent_index_by_name :merge_requests, INDEX_NAME + end +end diff --git a/db/post_migrate/20230913120111_remove_prepared_at_created_at_index_async.rb b/db/post_migrate/20230913120111_remove_prepared_at_created_at_index_async.rb new file mode 100644 index 00000000000..8507ebfe1ec --- /dev/null +++ b/db/post_migrate/20230913120111_remove_prepared_at_created_at_index_async.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemovePreparedAtCreatedAtIndexAsync < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_merge_requests_on_id_and_prepared_at' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :merge_requests, name: INDEX_NAME + end + + def down + add_concurrent_index :merge_requests, :id, name: INDEX_NAME, where: "prepared_at IS NULL" + end +end diff --git a/db/post_migrate/20230913130629_index_org_id_on_projects.rb b/db/post_migrate/20230913130629_index_org_id_on_projects.rb new file mode 100644 index 00000000000..45186b900c6 --- /dev/null +++ b/db/post_migrate/20230913130629_index_org_id_on_projects.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class IndexOrgIdOnProjects < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_projects_on_organization_id' + + def up + add_concurrent_index :projects, :organization_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :projects, INDEX_NAME + end +end diff --git a/db/post_migrate/20230913175529_add_index_on_merge_requests_target_project_id_and_merged_commit_sha.rb b/db/post_migrate/20230913175529_add_index_on_merge_requests_target_project_id_and_merged_commit_sha.rb new file mode 100644 index 00000000000..33fe6538f9b --- /dev/null +++ b/db/post_migrate/20230913175529_add_index_on_merge_requests_target_project_id_and_merged_commit_sha.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddIndexOnMergeRequestsTargetProjectIdAndMergedCommitSha < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_merge_requests_on_target_project_id_and_merged_commit_sha' + INDEX_COLUMNS = %i[target_project_id merged_commit_sha] + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, INDEX_COLUMNS, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :merge_requests, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20230914054914_index_finding_id_for_vulnerabilities_sync.rb b/db/post_migrate/20230914054914_index_finding_id_for_vulnerabilities_sync.rb new file mode 100644 index 00000000000..37cd13a4dfa --- /dev/null +++ b/db/post_migrate/20230914054914_index_finding_id_for_vulnerabilities_sync.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class IndexFindingIdForVulnerabilitiesSync < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_vulnerabilities_on_finding_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :vulnerabilities, :finding_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME + end +end diff --git a/db/schema_migrations/20230728020644 b/db/schema_migrations/20230728020644 new file mode 100644 index 00000000000..6e3ee922f7e --- /dev/null +++ b/db/schema_migrations/20230728020644 @@ -0,0 +1 @@ +95970e866bfd4815f156b9392f8e975152f531edb91407e2b09eb817dcebd294
\ No newline at end of file diff --git a/db/schema_migrations/20230802205051 b/db/schema_migrations/20230802205051 new file mode 100644 index 00000000000..3f09a569f68 --- /dev/null +++ b/db/schema_migrations/20230802205051 @@ -0,0 +1 @@ +f682f6c1dd19fa508282bfcd30e61197652bf14b4f0717ef2313a920f0eb3516
\ No newline at end of file diff --git a/db/schema_migrations/20230802212443 b/db/schema_migrations/20230802212443 new file mode 100644 index 00000000000..2d3b2e3b504 --- /dev/null +++ b/db/schema_migrations/20230802212443 @@ -0,0 +1 @@ +ab5b2cd527a1eb799f7f1c3d2f48c850853e498e50693dbe8148c08d52465da8
\ No newline at end of file diff --git a/db/schema_migrations/20230804055559 b/db/schema_migrations/20230804055559 new file mode 100644 index 00000000000..b6bdc60228b --- /dev/null +++ b/db/schema_migrations/20230804055559 @@ -0,0 +1 @@ +f450a78fe52af85d9e91c26b1e23d825e2a78f251173c801dcc6e9ebcc79437f
\ No newline at end of file diff --git a/db/schema_migrations/20230804122825 b/db/schema_migrations/20230804122825 new file mode 100644 index 00000000000..ec59e1dbb30 --- /dev/null +++ b/db/schema_migrations/20230804122825 @@ -0,0 +1 @@ +9db599bb939f27e81035c8aa22ae7fbb4d1376f5a9075b684b109d15da312faf
\ No newline at end of file diff --git a/db/schema_migrations/20230804123252 b/db/schema_migrations/20230804123252 new file mode 100644 index 00000000000..5e1e5cf0c9d --- /dev/null +++ b/db/schema_migrations/20230804123252 @@ -0,0 +1 @@ +a0c3883429cee1f9a3f170d3a563f9390937dba5cab2b661dc583aa7ffe1479f
\ No newline at end of file diff --git a/db/schema_migrations/20230807035953 b/db/schema_migrations/20230807035953 new file mode 100644 index 00000000000..562bb05a5eb --- /dev/null +++ b/db/schema_migrations/20230807035953 @@ -0,0 +1 @@ +998695a3c22394e5e08ac61841ac2255e717b0cc5a50baeabb682d91b3f42f28
\ No newline at end of file diff --git a/db/schema_migrations/20230808200355 b/db/schema_migrations/20230808200355 new file mode 100644 index 00000000000..7b8744f5de7 --- /dev/null +++ b/db/schema_migrations/20230808200355 @@ -0,0 +1 @@ +00235898dc10fe690e99e6ab6b1b6da61806158ad0be2d4b714a8f8076f71cba
\ No newline at end of file diff --git a/db/schema_migrations/20230809170822 b/db/schema_migrations/20230809170822 new file mode 100644 index 00000000000..a9afcc9bc3e --- /dev/null +++ b/db/schema_migrations/20230809170822 @@ -0,0 +1 @@ +ef3db107d68a95cda1e0cd35e26b1fd8d60d7b514f178bc4220b31c33bd1d3ba
\ No newline at end of file diff --git a/db/schema_migrations/20230809174702 b/db/schema_migrations/20230809174702 new file mode 100644 index 00000000000..e9f189710b0 --- /dev/null +++ b/db/schema_migrations/20230809174702 @@ -0,0 +1 @@ +3c6ee8e7ccb543776a5081c9bc15e64a6c1b3b66c7bf019c7d91e25ec05156f9
\ No newline at end of file diff --git a/db/schema_migrations/20230809203254 b/db/schema_migrations/20230809203254 new file mode 100644 index 00000000000..3f290c4f595 --- /dev/null +++ b/db/schema_migrations/20230809203254 @@ -0,0 +1 @@ +19058c7442d020d7db5f0a8ec386adc27ce157254a9e00b42b1fa49551c2e585
\ No newline at end of file diff --git a/db/schema_migrations/20230809210550 b/db/schema_migrations/20230809210550 new file mode 100644 index 00000000000..2a946c5a417 --- /dev/null +++ b/db/schema_migrations/20230809210550 @@ -0,0 +1 @@ +b9a09d4b6cdfe5ac7e380af43b9e9ee508f90aecdaf03dbfbc348a966a4332fc
\ No newline at end of file diff --git a/db/schema_migrations/20230810112715 b/db/schema_migrations/20230810112715 new file mode 100644 index 00000000000..db0284c512a --- /dev/null +++ b/db/schema_migrations/20230810112715 @@ -0,0 +1 @@ +2176e2862d6445962f34c537dd00025fb5efbb6a55af90ca54f41dd7de18b897
\ No newline at end of file diff --git a/db/schema_migrations/20230810113227 b/db/schema_migrations/20230810113227 new file mode 100644 index 00000000000..4175be45260 --- /dev/null +++ b/db/schema_migrations/20230810113227 @@ -0,0 +1 @@ +e18df398f3e6146fd59bde7070d9b082be66ea315976e85817dc7ef63b8ab3bd
\ No newline at end of file diff --git a/db/schema_migrations/20230810124545 b/db/schema_migrations/20230810124545 new file mode 100644 index 00000000000..d06862bc14d --- /dev/null +++ b/db/schema_migrations/20230810124545 @@ -0,0 +1 @@ +a625f5fcd0e2b98b2e239f3ca6cb98255385e0c0a7413c62fef647baf0ff16e5
\ No newline at end of file diff --git a/db/schema_migrations/20230811103457 b/db/schema_migrations/20230811103457 new file mode 100644 index 00000000000..731c2f7c296 --- /dev/null +++ b/db/schema_migrations/20230811103457 @@ -0,0 +1 @@ +6c252953fc80ec7618d2012c77064541ba522f77f7573130ca39ca7d915ae483
\ No newline at end of file diff --git a/db/schema_migrations/20230811144601 b/db/schema_migrations/20230811144601 new file mode 100644 index 00000000000..081cfc6300e --- /dev/null +++ b/db/schema_migrations/20230811144601 @@ -0,0 +1 @@ +ae7064351489b677c9b70f308f32e6e78473c4c5814901eea14c5669bb55194e
\ No newline at end of file diff --git a/db/schema_migrations/20230811185901 b/db/schema_migrations/20230811185901 new file mode 100644 index 00000000000..5d8880e6d12 --- /dev/null +++ b/db/schema_migrations/20230811185901 @@ -0,0 +1 @@ +7a773942b3b4364ff5148947795823ab0755339d23762e1002e8ab7887cacfb6
\ No newline at end of file diff --git a/db/schema_migrations/20230811211544 b/db/schema_migrations/20230811211544 new file mode 100644 index 00000000000..4fe3af17b1b --- /dev/null +++ b/db/schema_migrations/20230811211544 @@ -0,0 +1 @@ +367b6768d68246169cabe9b618b2792eded9d8abcd61fb8ac40748cd83c01f9d
\ No newline at end of file diff --git a/db/schema_migrations/20230814181359 b/db/schema_migrations/20230814181359 new file mode 100644 index 00000000000..17086601248 --- /dev/null +++ b/db/schema_migrations/20230814181359 @@ -0,0 +1 @@ +2765c209b9347c0c76257a1af473edd6aebdc3f8d6dce3eed4d089e700c36808
\ No newline at end of file diff --git a/db/schema_migrations/20230814203548 b/db/schema_migrations/20230814203548 new file mode 100644 index 00000000000..d89fd043347 --- /dev/null +++ b/db/schema_migrations/20230814203548 @@ -0,0 +1 @@ +0822d768380c459e390828924e6723a4a878cd217b1159f2d8ab12f78718fef7
\ No newline at end of file diff --git a/db/schema_migrations/20230815072912 b/db/schema_migrations/20230815072912 new file mode 100644 index 00000000000..f6aa821b887 --- /dev/null +++ b/db/schema_migrations/20230815072912 @@ -0,0 +1 @@ +7d72f7d7bc5e09cd47530f11b1f40046dd7285edc71739024633daf937731d7c
\ No newline at end of file diff --git a/db/schema_migrations/20230815140656 b/db/schema_migrations/20230815140656 new file mode 100644 index 00000000000..683b5ae1cf5 --- /dev/null +++ b/db/schema_migrations/20230815140656 @@ -0,0 +1 @@ +bd13139ed2eb68087515102fa647fe870e69f1ad91a0f4a2db57d59d6ce4e308
\ No newline at end of file diff --git a/db/schema_migrations/20230815160428 b/db/schema_migrations/20230815160428 new file mode 100644 index 00000000000..ebc6b6b181d --- /dev/null +++ b/db/schema_migrations/20230815160428 @@ -0,0 +1 @@ +df42fc7fca6b286929f74bec819d0a79df21c88a09b3e7b5c409666dacde7776
\ No newline at end of file diff --git a/db/schema_migrations/20230816111730 b/db/schema_migrations/20230816111730 new file mode 100644 index 00000000000..dbced9d469e --- /dev/null +++ b/db/schema_migrations/20230816111730 @@ -0,0 +1 @@ +a9bf0899e31d9652a2db14f33b17d120354662b44c21931bf9d04287baf82890
\ No newline at end of file diff --git a/db/schema_migrations/20230816152540 b/db/schema_migrations/20230816152540 new file mode 100644 index 00000000000..599d608ce7c --- /dev/null +++ b/db/schema_migrations/20230816152540 @@ -0,0 +1 @@ +29d6dd16a743370a09774a2ec1887ab1a82c69c3d8a41e1b4ad3f632c6d7c006
\ No newline at end of file diff --git a/db/schema_migrations/20230816152639 b/db/schema_migrations/20230816152639 new file mode 100644 index 00000000000..a0ee85c0e5c --- /dev/null +++ b/db/schema_migrations/20230816152639 @@ -0,0 +1 @@ +10e1a3a85c6ce4fa2fca10c1b95b8ba2775c1abe98360f27638878dda282d6d0
\ No newline at end of file diff --git a/db/schema_migrations/20230816210052 b/db/schema_migrations/20230816210052 new file mode 100644 index 00000000000..d9ea0cc5445 --- /dev/null +++ b/db/schema_migrations/20230816210052 @@ -0,0 +1 @@ +1d3d6acf9ec3bac7a4878570db79d1e0771760ff503acd9d333a04d4725c7e8a
\ No newline at end of file diff --git a/db/schema_migrations/20230816210503 b/db/schema_migrations/20230816210503 new file mode 100644 index 00000000000..de91e24153a --- /dev/null +++ b/db/schema_migrations/20230816210503 @@ -0,0 +1 @@ +2cdfb4fa3c4798123c14995f5dfdb1b55e163d290a566e6c6de922e22c84316a
\ No newline at end of file diff --git a/db/schema_migrations/20230816213228 b/db/schema_migrations/20230816213228 new file mode 100644 index 00000000000..9b41353e15d --- /dev/null +++ b/db/schema_migrations/20230816213228 @@ -0,0 +1 @@ +c0726a34eb21a269b85290b4aa56d05abb83d293ba7b8c9a97ea62ccba6e31c6
\ No newline at end of file diff --git a/db/schema_migrations/20230817040352 b/db/schema_migrations/20230817040352 new file mode 100644 index 00000000000..120154c123e --- /dev/null +++ b/db/schema_migrations/20230817040352 @@ -0,0 +1 @@ +0a51924454fb9fa8dbc4c7b757ef8f75afba9d45ade4b5a6afcc3885e95d3cdd
\ No newline at end of file diff --git a/db/schema_migrations/20230817050946 b/db/schema_migrations/20230817050946 new file mode 100644 index 00000000000..bfbc11fb3c5 --- /dev/null +++ b/db/schema_migrations/20230817050946 @@ -0,0 +1 @@ +9c51f4c28764dcb2e6ed5edcb485e9ff2c17973e6aad114cbf4ea816b7c6adb7
\ No newline at end of file diff --git a/db/schema_migrations/20230817111753 b/db/schema_migrations/20230817111753 new file mode 100644 index 00000000000..17457915ace --- /dev/null +++ b/db/schema_migrations/20230817111753 @@ -0,0 +1 @@ +707bddb67e80158cf8f6703a87b6b7a98a651db5df7c356142e8512b0e4d7cde
\ No newline at end of file diff --git a/db/schema_migrations/20230817111938 b/db/schema_migrations/20230817111938 new file mode 100644 index 00000000000..55498b7810e --- /dev/null +++ b/db/schema_migrations/20230817111938 @@ -0,0 +1 @@ +c59a6161044f4b75e031159e84028eb8c823dfc8f32b6b743fb7278820b41ed9
\ No newline at end of file diff --git a/db/schema_migrations/20230817143507 b/db/schema_migrations/20230817143507 new file mode 100644 index 00000000000..ec53ef74b86 --- /dev/null +++ b/db/schema_migrations/20230817143507 @@ -0,0 +1 @@ +318ae2c0b908b7d787d2df5908096d0f083091ef3d3b598ad3c84e66024b34cc
\ No newline at end of file diff --git a/db/schema_migrations/20230817143637 b/db/schema_migrations/20230817143637 new file mode 100644 index 00000000000..a9776491277 --- /dev/null +++ b/db/schema_migrations/20230817143637 @@ -0,0 +1 @@ +eb9ba746c27c748a2e17d5e99303c8fae208e7252b79eec57ef3dc4b79a7ccb9
\ No newline at end of file diff --git a/db/schema_migrations/20230818034041 b/db/schema_migrations/20230818034041 new file mode 100644 index 00000000000..440904ac7b5 --- /dev/null +++ b/db/schema_migrations/20230818034041 @@ -0,0 +1 @@ +4b27c841210115277f4d49efc56ac834a7ba8b2afb351e0df45443f14cc01484
\ No newline at end of file diff --git a/db/schema_migrations/20230818050946 b/db/schema_migrations/20230818050946 new file mode 100644 index 00000000000..bdcb018f789 --- /dev/null +++ b/db/schema_migrations/20230818050946 @@ -0,0 +1 @@ +ad22f41707b094bd7002ddcfa378437c4599a55bbfef12bb66f2775678c3c785
\ No newline at end of file diff --git a/db/schema_migrations/20230818055517 b/db/schema_migrations/20230818055517 new file mode 100644 index 00000000000..14c3821d426 --- /dev/null +++ b/db/schema_migrations/20230818055517 @@ -0,0 +1 @@ +0dd37cf1da3ff0f56f24a41dd76ef7cb789e0833a6ea73b773f56a8a3793c465
\ No newline at end of file diff --git a/db/schema_migrations/20230818083610 b/db/schema_migrations/20230818083610 new file mode 100644 index 00000000000..fb93a7be2a2 --- /dev/null +++ b/db/schema_migrations/20230818083610 @@ -0,0 +1 @@ +f780f4f4229f73adf3c71436b793a5b5b5c03d8cb16941e2e1f2bc5e68b67f65
\ No newline at end of file diff --git a/db/schema_migrations/20230818085219 b/db/schema_migrations/20230818085219 new file mode 100644 index 00000000000..f4e60ba7e60 --- /dev/null +++ b/db/schema_migrations/20230818085219 @@ -0,0 +1 @@ +c69e2ffe6f6bec22fb182a5fc26c02717a1546f31777cc8167103639c0e48c65
\ No newline at end of file diff --git a/db/schema_migrations/20230818142801 b/db/schema_migrations/20230818142801 new file mode 100644 index 00000000000..d79f1e996e5 --- /dev/null +++ b/db/schema_migrations/20230818142801 @@ -0,0 +1 @@ +6f2bb9c136104e86929921263bd01315bf8acaf19ae05bf28cce3e973dce0020
\ No newline at end of file diff --git a/db/schema_migrations/20230821000001 b/db/schema_migrations/20230821000001 new file mode 100644 index 00000000000..335a019ce21 --- /dev/null +++ b/db/schema_migrations/20230821000001 @@ -0,0 +1 @@ +30eb1215fb4411780a722c0d49b7e30316200459dd91f67525f4ae5894aa1acc
\ No newline at end of file diff --git a/db/schema_migrations/20230821000002 b/db/schema_migrations/20230821000002 new file mode 100644 index 00000000000..ed24b64020d --- /dev/null +++ b/db/schema_migrations/20230821000002 @@ -0,0 +1 @@ +ff4aafeb32b4e09ec8344afa8684fda2fd2131a8d4b8f82806a0ca5341beef59
\ No newline at end of file diff --git a/db/schema_migrations/20230821000003 b/db/schema_migrations/20230821000003 new file mode 100644 index 00000000000..395186ab4f1 --- /dev/null +++ b/db/schema_migrations/20230821000003 @@ -0,0 +1 @@ +5ece2c99a97204a2888f5951d4cd2b16a75e47e395c8a09fa16f151e7d28e16c
\ No newline at end of file diff --git a/db/schema_migrations/20230821081508 b/db/schema_migrations/20230821081508 new file mode 100644 index 00000000000..de0d669afa0 --- /dev/null +++ b/db/schema_migrations/20230821081508 @@ -0,0 +1 @@ +0ace0ef585fd504fb21c78eb991aacdd8594e241a88f19cf8ccf425543282291
\ No newline at end of file diff --git a/db/schema_migrations/20230821081603 b/db/schema_migrations/20230821081603 new file mode 100644 index 00000000000..7c28a92d407 --- /dev/null +++ b/db/schema_migrations/20230821081603 @@ -0,0 +1 @@ +b4d84617b843566df3e8470150affa3e3a5c0fdb5fa53fbdd8e86f4dbf25a128
\ No newline at end of file diff --git a/db/schema_migrations/20230821101010 b/db/schema_migrations/20230821101010 new file mode 100644 index 00000000000..32ce19db417 --- /dev/null +++ b/db/schema_migrations/20230821101010 @@ -0,0 +1 @@ +84586d94a586664bf049782d354b240998217fff131d3ab19b793da6333ee844
\ No newline at end of file diff --git a/db/schema_migrations/20230821133549 b/db/schema_migrations/20230821133549 new file mode 100644 index 00000000000..5025710f689 --- /dev/null +++ b/db/schema_migrations/20230821133549 @@ -0,0 +1 @@ +57f97aa12f9a41286512b32b1d038d246139cd7ae3852f1642960187643bffb3
\ No newline at end of file diff --git a/db/schema_migrations/20230822064649 b/db/schema_migrations/20230822064649 new file mode 100644 index 00000000000..449dd984431 --- /dev/null +++ b/db/schema_migrations/20230822064649 @@ -0,0 +1 @@ +b892940441125e854d08e24906e4b6287f8359b4ad374be5b141b43cfdcc1354
\ No newline at end of file diff --git a/db/schema_migrations/20230822064841 b/db/schema_migrations/20230822064841 new file mode 100644 index 00000000000..2922af9c573 --- /dev/null +++ b/db/schema_migrations/20230822064841 @@ -0,0 +1 @@ +e025eb64ab8b9ece1a18c845024db272a1859757734948609c134f6dfee93884
\ No newline at end of file diff --git a/db/schema_migrations/20230822104028 b/db/schema_migrations/20230822104028 new file mode 100644 index 00000000000..9bb861f45de --- /dev/null +++ b/db/schema_migrations/20230822104028 @@ -0,0 +1 @@ +d37694e80d032f8bdfe25838ad7815bdafb0d901592f5e9dceb57e1b9d823680
\ No newline at end of file diff --git a/db/schema_migrations/20230822125256 b/db/schema_migrations/20230822125256 new file mode 100644 index 00000000000..724b2e31bd4 --- /dev/null +++ b/db/schema_migrations/20230822125256 @@ -0,0 +1 @@ +a80bf5eeb8bbcee7d751eb4cd68c3a9abd2e5e356c0677f1ed5bbf679bd1656c
\ No newline at end of file diff --git a/db/schema_migrations/20230822151454 b/db/schema_migrations/20230822151454 new file mode 100644 index 00000000000..1559d514b40 --- /dev/null +++ b/db/schema_migrations/20230822151454 @@ -0,0 +1 @@ +8ff557100904684180b732d0ac50e1ac23029ef47d1ab8816cfc82108313ba37
\ No newline at end of file diff --git a/db/schema_migrations/20230822153124 b/db/schema_migrations/20230822153124 new file mode 100644 index 00000000000..92ba1bb950d --- /dev/null +++ b/db/schema_migrations/20230822153124 @@ -0,0 +1 @@ +d113cced39c0307a7648325bedc0f78ebaa775fcdc1a8ff4ee8caa4fbf1c9c57
\ No newline at end of file diff --git a/db/schema_migrations/20230822154640 b/db/schema_migrations/20230822154640 new file mode 100644 index 00000000000..c816a8c5633 --- /dev/null +++ b/db/schema_migrations/20230822154640 @@ -0,0 +1 @@ +9d9a99ad2fb472d71f625cb7cc668d096b88b12064a9a14ac556f490127b1806
\ No newline at end of file diff --git a/db/schema_migrations/20230822175304 b/db/schema_migrations/20230822175304 new file mode 100644 index 00000000000..f858b7074f3 --- /dev/null +++ b/db/schema_migrations/20230822175304 @@ -0,0 +1 @@ +4feff19bb2ff05dbf4bc673ced92d1d7b7c5d337cd8895ab490634ea42a6a349
\ No newline at end of file diff --git a/db/schema_migrations/20230822195852 b/db/schema_migrations/20230822195852 new file mode 100644 index 00000000000..2410010c76e --- /dev/null +++ b/db/schema_migrations/20230822195852 @@ -0,0 +1 @@ +a4550541c62863f6f0c90da330ec90f9a0b903dcc20ef697cc9f187124bdc9cc
\ No newline at end of file diff --git a/db/schema_migrations/20230823085627 b/db/schema_migrations/20230823085627 new file mode 100644 index 00000000000..484ba75de96 --- /dev/null +++ b/db/schema_migrations/20230823085627 @@ -0,0 +1 @@ +16179991d3c17f0d74c82002ded6046675b27f5d7bfc9ad91cf9bf065543b7c2
\ No newline at end of file diff --git a/db/schema_migrations/20230823090001 b/db/schema_migrations/20230823090001 new file mode 100644 index 00000000000..3c7a44ede56 --- /dev/null +++ b/db/schema_migrations/20230823090001 @@ -0,0 +1 @@ +5eea44d2b1a595dbee2d36a445950282e7f647bfdda3d2884bcac252e9f865ce
\ No newline at end of file diff --git a/db/schema_migrations/20230823132142 b/db/schema_migrations/20230823132142 new file mode 100644 index 00000000000..2ea42285c0e --- /dev/null +++ b/db/schema_migrations/20230823132142 @@ -0,0 +1 @@ +438ce9b705e575c139724a2ad81e799bdda63b9428b4cf3bd21b9e47df36ece7
\ No newline at end of file diff --git a/db/schema_migrations/20230823140934 b/db/schema_migrations/20230823140934 new file mode 100644 index 00000000000..2bc3734026b --- /dev/null +++ b/db/schema_migrations/20230823140934 @@ -0,0 +1 @@ +9dd2bca54c0f9560719887dae87b54edd10f01ea3a831141b80a3d2364a4eddf
\ No newline at end of file diff --git a/db/schema_migrations/20230823143519 b/db/schema_migrations/20230823143519 new file mode 100644 index 00000000000..9e6e12223cb --- /dev/null +++ b/db/schema_migrations/20230823143519 @@ -0,0 +1 @@ +91d69bff151e7bd0ea542199eaa3550b09c4ccbcff41714d31ceacc151c990ff
\ No newline at end of file diff --git a/db/schema_migrations/20230823144846 b/db/schema_migrations/20230823144846 new file mode 100644 index 00000000000..df570031dc0 --- /dev/null +++ b/db/schema_migrations/20230823144846 @@ -0,0 +1 @@ +eee2ddb8ebb459f2d7cb8144786f373604e33f4aa31b70f9709e2422bbf5c896
\ No newline at end of file diff --git a/db/schema_migrations/20230823145053 b/db/schema_migrations/20230823145053 new file mode 100644 index 00000000000..7f98e2ead36 --- /dev/null +++ b/db/schema_migrations/20230823145053 @@ -0,0 +1 @@ +e7850fcaf7a1e95025d065fcb85a02872970cdfd3ab9886cb5e8dccd002735f6
\ No newline at end of file diff --git a/db/schema_migrations/20230823145126 b/db/schema_migrations/20230823145126 new file mode 100644 index 00000000000..2809af86953 --- /dev/null +++ b/db/schema_migrations/20230823145126 @@ -0,0 +1 @@ +dd3edcfd1b5e5079e68ce95257de1b216e5f791bfb5aa7f089cd1ffee8fbc78d
\ No newline at end of file diff --git a/db/schema_migrations/20230823161514 b/db/schema_migrations/20230823161514 new file mode 100644 index 00000000000..4cade8b0361 --- /dev/null +++ b/db/schema_migrations/20230823161514 @@ -0,0 +1 @@ +606034ed6a64e2d2511e423a9311084ede66181cd1b47a4b3594229843c634e2
\ No newline at end of file diff --git a/db/schema_migrations/20230823174108 b/db/schema_migrations/20230823174108 new file mode 100644 index 00000000000..32d7292f449 --- /dev/null +++ b/db/schema_migrations/20230823174108 @@ -0,0 +1 @@ +ad75672df6de231df6d2702554e3416b0ba7c4c07cc4ace3d83595038f36b4e6
\ No newline at end of file diff --git a/db/schema_migrations/20230823194111 b/db/schema_migrations/20230823194111 new file mode 100644 index 00000000000..1f59bc1e52a --- /dev/null +++ b/db/schema_migrations/20230823194111 @@ -0,0 +1 @@ +ecc37b7f9517923afa19a5e965819f70e73908e24c2f1d8cd5875137e6199966
\ No newline at end of file diff --git a/db/schema_migrations/20230824015840 b/db/schema_migrations/20230824015840 new file mode 100644 index 00000000000..934f3dffb55 --- /dev/null +++ b/db/schema_migrations/20230824015840 @@ -0,0 +1 @@ +14fee417b4fe7767f84068b2772e7fb9dd43df816af258d6b6d7e83bc3a2c176
\ No newline at end of file diff --git a/db/schema_migrations/20230824022229 b/db/schema_migrations/20230824022229 new file mode 100644 index 00000000000..ba7506b7cb4 --- /dev/null +++ b/db/schema_migrations/20230824022229 @@ -0,0 +1 @@ +cb2f7d874c5564c2aab48785043293abbd49803e39c466b1e1c2d47a3bc5cbfb
\ No newline at end of file diff --git a/db/schema_migrations/20230825085648 b/db/schema_migrations/20230825085648 new file mode 100644 index 00000000000..a6b1d8e1be1 --- /dev/null +++ b/db/schema_migrations/20230825085648 @@ -0,0 +1 @@ +5e003d34a36320c53852ece7d0373ce99e7fc21b08f8edc5f5320256d4b3b3a2
\ No newline at end of file diff --git a/db/schema_migrations/20230825085719 b/db/schema_migrations/20230825085719 new file mode 100644 index 00000000000..cf785c0a170 --- /dev/null +++ b/db/schema_migrations/20230825085719 @@ -0,0 +1 @@ +4b7b8711a29a8a26ff9af42d73b95eb52b1791569771b1c34f6f51000059b10d
\ No newline at end of file diff --git a/db/schema_migrations/20230828153646 b/db/schema_migrations/20230828153646 new file mode 100644 index 00000000000..737645fba5d --- /dev/null +++ b/db/schema_migrations/20230828153646 @@ -0,0 +1 @@ +913b2384ea76d9169020253dacf14a51ccb7ebbaee9c9bc62b0e0473734ed981
\ No newline at end of file diff --git a/db/schema_migrations/20230829045459 b/db/schema_migrations/20230829045459 new file mode 100644 index 00000000000..031eb2ea78f --- /dev/null +++ b/db/schema_migrations/20230829045459 @@ -0,0 +1 @@ +800d27ba92b45c193bbc8d487bec380fd06ef8660c41b2bef04b52f574ded406
\ No newline at end of file diff --git a/db/schema_migrations/20230829120720 b/db/schema_migrations/20230829120720 new file mode 100644 index 00000000000..28155113a89 --- /dev/null +++ b/db/schema_migrations/20230829120720 @@ -0,0 +1 @@ +2d40c98a720cb5bd9518b7c9ede223e23178199733352301a8400d1d387230fe
\ No newline at end of file diff --git a/db/schema_migrations/20230830084959 b/db/schema_migrations/20230830084959 new file mode 100644 index 00000000000..12a8dea429c --- /dev/null +++ b/db/schema_migrations/20230830084959 @@ -0,0 +1 @@ +3469c47c0cd4c86c7d1c9da450493a882d3a5f371fb7b78f49af64a837f989fb
\ No newline at end of file diff --git a/db/schema_migrations/20230830085501 b/db/schema_migrations/20230830085501 new file mode 100644 index 00000000000..92c45a647fc --- /dev/null +++ b/db/schema_migrations/20230830085501 @@ -0,0 +1 @@ +5756f155e295263ea8376b9161c523f9ee39628be289d1939c220852abd4d098
\ No newline at end of file diff --git a/db/schema_migrations/20230830121830 b/db/schema_migrations/20230830121830 new file mode 100644 index 00000000000..55bfb10b349 --- /dev/null +++ b/db/schema_migrations/20230830121830 @@ -0,0 +1 @@ +5ff2944a3e5100101b13f0aa4d69dc4ed6a4897cc28a90b45693ae3e3971a607
\ No newline at end of file diff --git a/db/schema_migrations/20230831084632 b/db/schema_migrations/20230831084632 new file mode 100644 index 00000000000..2859ceb1691 --- /dev/null +++ b/db/schema_migrations/20230831084632 @@ -0,0 +1 @@ +f523e00eeac359503976360c824582e8c9bd0e82cbf28ca02df17d0adacc90d8
\ No newline at end of file diff --git a/db/schema_migrations/20230831101144 b/db/schema_migrations/20230831101144 new file mode 100644 index 00000000000..c2355043d68 --- /dev/null +++ b/db/schema_migrations/20230831101144 @@ -0,0 +1 @@ +3e834879b1d896c1d4a9b8ee302f463f3cbcc8c79a8e93da31d6622f69b84b8d
\ No newline at end of file diff --git a/db/schema_migrations/20230831111051 b/db/schema_migrations/20230831111051 new file mode 100644 index 00000000000..36217b23759 --- /dev/null +++ b/db/schema_migrations/20230831111051 @@ -0,0 +1 @@ +2058852d302266208a39c718d91a1d537c84330a7cee369d75d1a4e6420300b5
\ No newline at end of file diff --git a/db/schema_migrations/20230901033401 b/db/schema_migrations/20230901033401 new file mode 100644 index 00000000000..e3ebeeb56ec --- /dev/null +++ b/db/schema_migrations/20230901033401 @@ -0,0 +1 @@ +8c19687f793a005ff83dfc1231c7ea0f44d6ad5ed363737615fc4e5c1074b5bd
\ No newline at end of file diff --git a/db/schema_migrations/20230901044003 b/db/schema_migrations/20230901044003 new file mode 100644 index 00000000000..a7d4f75a881 --- /dev/null +++ b/db/schema_migrations/20230901044003 @@ -0,0 +1 @@ +2556dcb03527331710d4bf71c16983d04651c4bdf504b65e519ced213515555e
\ No newline at end of file diff --git a/db/schema_migrations/20230901050458 b/db/schema_migrations/20230901050458 new file mode 100644 index 00000000000..575e6a14be3 --- /dev/null +++ b/db/schema_migrations/20230901050458 @@ -0,0 +1 @@ +747c396f78f3e34ee9c3cb9802e2cf8638f374f4fe2383fd7064fb378c1720d6
\ No newline at end of file diff --git a/db/schema_migrations/20230901054536 b/db/schema_migrations/20230901054536 new file mode 100644 index 00000000000..2cc0bc00b20 --- /dev/null +++ b/db/schema_migrations/20230901054536 @@ -0,0 +1 @@ +789900a0db2f180bdeebc5fcd7fcb446f23e2ea77bd7f62e682779e75c981290
\ No newline at end of file diff --git a/db/schema_migrations/20230901064536 b/db/schema_migrations/20230901064536 new file mode 100644 index 00000000000..838df4adafc --- /dev/null +++ b/db/schema_migrations/20230901064536 @@ -0,0 +1 @@ +0097ccb7ec94655f8f455ae52f2a20089833a584f9f307ba554cd2c91f41e677
\ No newline at end of file diff --git a/db/schema_migrations/20230901064537 b/db/schema_migrations/20230901064537 new file mode 100644 index 00000000000..e2c20f4889d --- /dev/null +++ b/db/schema_migrations/20230901064537 @@ -0,0 +1 @@ +a4aec1b330059217fc5f93be7c3e4a6369b402b4919a10a26de4ba8352dee9a7
\ No newline at end of file diff --git a/db/schema_migrations/20230901170145 b/db/schema_migrations/20230901170145 new file mode 100644 index 00000000000..ae389df1a50 --- /dev/null +++ b/db/schema_migrations/20230901170145 @@ -0,0 +1 @@ +86b17eb7dd562a935cea98c9a1e0815110dea9c6994f0c2fa9db5b37d5a3af27
\ No newline at end of file diff --git a/db/schema_migrations/20230902033401 b/db/schema_migrations/20230902033401 new file mode 100644 index 00000000000..bc99e982a11 --- /dev/null +++ b/db/schema_migrations/20230902033401 @@ -0,0 +1 @@ +11326885cf13eafa8c5042fac4749af0e2d6834608e03ad56a5587066100aea4
\ No newline at end of file diff --git a/db/schema_migrations/20230902050458 b/db/schema_migrations/20230902050458 new file mode 100644 index 00000000000..ec40c06fbfd --- /dev/null +++ b/db/schema_migrations/20230902050458 @@ -0,0 +1 @@ +a036f2fa3148a3f5f64aefc420b04f8fb06530dfeac1df6fa70f42c6ba3e2ebf
\ No newline at end of file diff --git a/db/schema_migrations/20230902054536 b/db/schema_migrations/20230902054536 new file mode 100644 index 00000000000..1de79bf7c59 --- /dev/null +++ b/db/schema_migrations/20230902054536 @@ -0,0 +1 @@ +037ff2b8993402c8aca75de43c92871a8248d79c11a57a312d028aeb6ac2d5bf
\ No newline at end of file diff --git a/db/schema_migrations/20230903064536 b/db/schema_migrations/20230903064536 new file mode 100644 index 00000000000..503c2335e13 --- /dev/null +++ b/db/schema_migrations/20230903064536 @@ -0,0 +1 @@ +64257bd027fccbaff2cd0a785af54173fecfcb21bd05edb8a26fc32095a9fe98
\ No newline at end of file diff --git a/db/schema_migrations/20230903064537 b/db/schema_migrations/20230903064537 new file mode 100644 index 00000000000..763aa7ff01c --- /dev/null +++ b/db/schema_migrations/20230903064537 @@ -0,0 +1 @@ +6eda15f0921c135f38f3d35edcdb8deefd8e1735abf537c94dd8c6475600060b
\ No newline at end of file diff --git a/db/schema_migrations/20230903170000 b/db/schema_migrations/20230903170000 new file mode 100644 index 00000000000..5189c60657a --- /dev/null +++ b/db/schema_migrations/20230903170000 @@ -0,0 +1 @@ +07fdd8579009aa1d68106cc9919d82cfca5702373d8b69c54ea7fa552209d540
\ No newline at end of file diff --git a/db/schema_migrations/20230904100544 b/db/schema_migrations/20230904100544 new file mode 100644 index 00000000000..357a51ffee1 --- /dev/null +++ b/db/schema_migrations/20230904100544 @@ -0,0 +1 @@ +773a845ec5b33a41cec6498e0fe5c4c033f2a011d0dcbe9feb9bed9779b3134d
\ No newline at end of file diff --git a/db/schema_migrations/20230904103804 b/db/schema_migrations/20230904103804 new file mode 100644 index 00000000000..30e0c5b280f --- /dev/null +++ b/db/schema_migrations/20230904103804 @@ -0,0 +1 @@ +daa7361dae1258a9fae12e7d0cc86e2484dd945f9cef26430817a761d198b34d
\ No newline at end of file diff --git a/db/schema_migrations/20230905040539 b/db/schema_migrations/20230905040539 new file mode 100644 index 00000000000..d707703c773 --- /dev/null +++ b/db/schema_migrations/20230905040539 @@ -0,0 +1 @@ +f9bebf09d3265a506ab0f783cfd2a77415b05be27684c30998bd702a67ffc6b1
\ No newline at end of file diff --git a/db/schema_migrations/20230905061815 b/db/schema_migrations/20230905061815 new file mode 100644 index 00000000000..12ea99e3e4a --- /dev/null +++ b/db/schema_migrations/20230905061815 @@ -0,0 +1 @@ +c32510034870dea5f26ab8fd64b034919355038a2e24f38bdd7c9051059346ec
\ No newline at end of file diff --git a/db/schema_migrations/20230905071915 b/db/schema_migrations/20230905071915 new file mode 100644 index 00000000000..8b4985f2141 --- /dev/null +++ b/db/schema_migrations/20230905071915 @@ -0,0 +1 @@ +c3be3211b1b7a08cb93ca79b569a4ee4412fe42066573c938fd920d9aee9163a
\ No newline at end of file diff --git a/db/schema_migrations/20230905091059 b/db/schema_migrations/20230905091059 new file mode 100644 index 00000000000..a74c840b1c4 --- /dev/null +++ b/db/schema_migrations/20230905091059 @@ -0,0 +1 @@ +c06fc36180c1b495eb800ba1c25bbe441f6973b0979d7fbc114ca7f128bd7c99
\ No newline at end of file diff --git a/db/schema_migrations/20230905234948 b/db/schema_migrations/20230905234948 new file mode 100644 index 00000000000..0bbc72be5e5 --- /dev/null +++ b/db/schema_migrations/20230905234948 @@ -0,0 +1 @@ +fb00789c87c9e9f2e794d9a7a8d15fd26cb66a3ca8d5a7ffc5ee42d99f961459
\ No newline at end of file diff --git a/db/schema_migrations/20230905234949 b/db/schema_migrations/20230905234949 new file mode 100644 index 00000000000..5bde35409ed --- /dev/null +++ b/db/schema_migrations/20230905234949 @@ -0,0 +1 @@ +74ba712ab6dc155f7c0cf49e1c089e18033996553ff2d9c83b29bea19875ddfa
\ No newline at end of file diff --git a/db/schema_migrations/20230906072349 b/db/schema_migrations/20230906072349 new file mode 100644 index 00000000000..7aa3dccd8b4 --- /dev/null +++ b/db/schema_migrations/20230906072349 @@ -0,0 +1 @@ +7b86070aa95bc9ad1671109d68abd2c8cb3d39134628f2acf7c85ce1685ea852
\ No newline at end of file diff --git a/db/schema_migrations/20230906100001 b/db/schema_migrations/20230906100001 new file mode 100644 index 00000000000..fc8bd1af1ef --- /dev/null +++ b/db/schema_migrations/20230906100001 @@ -0,0 +1 @@ +ecd5d2beec391c9e9b0c396b3e8e7425ff250c417d2510d7d4a2d01266f12c5f
\ No newline at end of file diff --git a/db/schema_migrations/20230906105445 b/db/schema_migrations/20230906105445 new file mode 100644 index 00000000000..0c75909f0e7 --- /dev/null +++ b/db/schema_migrations/20230906105445 @@ -0,0 +1 @@ +f378e1234e1ec61eabf1e183acfcefc53f3dec8ad12d1089a974e8b36724acdf
\ No newline at end of file diff --git a/db/schema_migrations/20230906175220 b/db/schema_migrations/20230906175220 new file mode 100644 index 00000000000..d063f2fb57f --- /dev/null +++ b/db/schema_migrations/20230906175220 @@ -0,0 +1 @@ +70e07f9790b7a9011fce37cc1376d61d84c98ef677fcce534dd97a78f892af86
\ No newline at end of file diff --git a/db/schema_migrations/20230906181457 b/db/schema_migrations/20230906181457 new file mode 100644 index 00000000000..65e99ba4f0f --- /dev/null +++ b/db/schema_migrations/20230906181457 @@ -0,0 +1 @@ +183a4dd3ea67df81f38744550919d10d76b0a9e44eaf1cb949211d938b8c8f56
\ No newline at end of file diff --git a/db/schema_migrations/20230906185552 b/db/schema_migrations/20230906185552 new file mode 100644 index 00000000000..a2c58d5f740 --- /dev/null +++ b/db/schema_migrations/20230906185552 @@ -0,0 +1 @@ +114a9f959d66c7a5b0e31b3ab07bd08eb0ebcca7952359368facf35a5890eb3f
\ No newline at end of file diff --git a/db/schema_migrations/20230906204934 b/db/schema_migrations/20230906204934 new file mode 100644 index 00000000000..d15bd01b46f --- /dev/null +++ b/db/schema_migrations/20230906204934 @@ -0,0 +1 @@ +63b9153f085cb11279e84cb0e67a12987eaa6e20825e81d30d88054105b29825
\ No newline at end of file diff --git a/db/schema_migrations/20230906204935 b/db/schema_migrations/20230906204935 new file mode 100644 index 00000000000..fa8c281171b --- /dev/null +++ b/db/schema_migrations/20230906204935 @@ -0,0 +1 @@ +9d1531d614e9a156f0d2aa9334aeab436ada293f37ef48223de76a360e85ed53
\ No newline at end of file diff --git a/db/schema_migrations/20230907155247 b/db/schema_migrations/20230907155247 new file mode 100644 index 00000000000..6d709e8c35c --- /dev/null +++ b/db/schema_migrations/20230907155247 @@ -0,0 +1 @@ +969028a44aa3e656595c2af113fab7a82f8f28514337b97bfb467a5c5550dfc3
\ No newline at end of file diff --git a/db/schema_migrations/20230907162613 b/db/schema_migrations/20230907162613 new file mode 100644 index 00000000000..f3442502b6e --- /dev/null +++ b/db/schema_migrations/20230907162613 @@ -0,0 +1 @@ +bad1a624184b8f0bfe57dbc36b4ec8478edeaa2dc6366eb5e5d31cdc7c0c8595
\ No newline at end of file diff --git a/db/schema_migrations/20230907204731 b/db/schema_migrations/20230907204731 new file mode 100644 index 00000000000..9b10980eae0 --- /dev/null +++ b/db/schema_migrations/20230907204731 @@ -0,0 +1 @@ +e5448d02414f99074a52337c271310277a1d76b386a9e2e1bd3c1b806a70c462
\ No newline at end of file diff --git a/db/schema_migrations/20230908072558 b/db/schema_migrations/20230908072558 new file mode 100644 index 00000000000..887dcb04645 --- /dev/null +++ b/db/schema_migrations/20230908072558 @@ -0,0 +1 @@ +bfde9336483cdfd75b4becdedcbaf8dd6aeb3edb87dde626204fff86085e94a0
\ No newline at end of file diff --git a/db/schema_migrations/20230908072612 b/db/schema_migrations/20230908072612 new file mode 100644 index 00000000000..b1eef367968 --- /dev/null +++ b/db/schema_migrations/20230908072612 @@ -0,0 +1 @@ +ee187bb2012e0af062610ad4b1026e5e12112d2964744922fb7087c14e7729a0
\ No newline at end of file diff --git a/db/schema_migrations/20230908072626 b/db/schema_migrations/20230908072626 new file mode 100644 index 00000000000..923c8ea6fe4 --- /dev/null +++ b/db/schema_migrations/20230908072626 @@ -0,0 +1 @@ +0fd8f7f580d9b7a5910f2aa838adf8d2f0a6fda7f112ac5cca6c50907590e610
\ No newline at end of file diff --git a/db/schema_migrations/20230908072639 b/db/schema_migrations/20230908072639 new file mode 100644 index 00000000000..85baf65d9f4 --- /dev/null +++ b/db/schema_migrations/20230908072639 @@ -0,0 +1 @@ +a8389b576d5abe741e9e1a9689f1c3c272a98a1aaec6173583b9ef41432b2540
\ No newline at end of file diff --git a/db/schema_migrations/20230908155831 b/db/schema_migrations/20230908155831 new file mode 100644 index 00000000000..3264d9de079 --- /dev/null +++ b/db/schema_migrations/20230908155831 @@ -0,0 +1 @@ +141c46587be646cb85c13ecfcae6c3123aa397e57f468f547ff43f93a35d8b37
\ No newline at end of file diff --git a/db/schema_migrations/20230909120000 b/db/schema_migrations/20230909120000 new file mode 100644 index 00000000000..414065b3693 --- /dev/null +++ b/db/schema_migrations/20230909120000 @@ -0,0 +1 @@ +75402594bdc333a34f7b49db4d5008fddad10f346dd15d65e4552cac20b442fb
\ No newline at end of file diff --git a/db/schema_migrations/20230911095016 b/db/schema_migrations/20230911095016 new file mode 100644 index 00000000000..02c9103db6c --- /dev/null +++ b/db/schema_migrations/20230911095016 @@ -0,0 +1 @@ +013462219a77c1ffcae41d657e00e70c9e79034f983b3857c312baf1cb454a2d
\ No newline at end of file diff --git a/db/schema_migrations/20230913100953 b/db/schema_migrations/20230913100953 new file mode 100644 index 00000000000..7bae2afbd02 --- /dev/null +++ b/db/schema_migrations/20230913100953 @@ -0,0 +1 @@ +287ac58f06c12770a55e4965aab839ae2bae1eda34292234bda47c7ad90ce3cc
\ No newline at end of file diff --git a/db/schema_migrations/20230913115113 b/db/schema_migrations/20230913115113 new file mode 100644 index 00000000000..dc74f4f6ecd --- /dev/null +++ b/db/schema_migrations/20230913115113 @@ -0,0 +1 @@ +096cee5bd1d85a084e48f3868972cf727f44db85c000640ff840b48b4e9cf6ff
\ No newline at end of file diff --git a/db/schema_migrations/20230913120111 b/db/schema_migrations/20230913120111 new file mode 100644 index 00000000000..52162d8724f --- /dev/null +++ b/db/schema_migrations/20230913120111 @@ -0,0 +1 @@ +bddeb8b01a1228559237bc437810570041ea28f128b34d5f4130655eb01d7860
\ No newline at end of file diff --git a/db/schema_migrations/20230913130629 b/db/schema_migrations/20230913130629 new file mode 100644 index 00000000000..26759217857 --- /dev/null +++ b/db/schema_migrations/20230913130629 @@ -0,0 +1 @@ +4d5c78a1ebe2699831e1490c4df8ccbfbd1528af711ad67fc03232f34499e89e
\ No newline at end of file diff --git a/db/schema_migrations/20230913171402 b/db/schema_migrations/20230913171402 new file mode 100644 index 00000000000..686a7c6f570 --- /dev/null +++ b/db/schema_migrations/20230913171402 @@ -0,0 +1 @@ +af511c9616f7f44474a8b4cd04f05c36f387a7b94badc4a5b1325a1e7425de46
\ No newline at end of file diff --git a/db/schema_migrations/20230913171403 b/db/schema_migrations/20230913171403 new file mode 100644 index 00000000000..d0982b705eb --- /dev/null +++ b/db/schema_migrations/20230913171403 @@ -0,0 +1 @@ +91ac60df233911ad7d770eaeb4736b35dab7ba335eba11824cb114a1cfa97826
\ No newline at end of file diff --git a/db/schema_migrations/20230913175529 b/db/schema_migrations/20230913175529 new file mode 100644 index 00000000000..f68678def20 --- /dev/null +++ b/db/schema_migrations/20230913175529 @@ -0,0 +1 @@ +af8c6b5578c04d184f7f3768c5b06b3a252c10d8f158667ceab57eca74fb4341
\ No newline at end of file diff --git a/db/schema_migrations/20230913235822 b/db/schema_migrations/20230913235822 new file mode 100644 index 00000000000..1dbfe5722cb --- /dev/null +++ b/db/schema_migrations/20230913235822 @@ -0,0 +1 @@ +2c5c8471a8c411a17fc7b4c7e5ab2f8e041e5edf3fb1428a3e146a80b836beaa
\ No newline at end of file diff --git a/db/schema_migrations/20230914001329 b/db/schema_migrations/20230914001329 new file mode 100644 index 00000000000..a8a05e4727f --- /dev/null +++ b/db/schema_migrations/20230914001329 @@ -0,0 +1 @@ +c21bcdb9bff2956c995fec964b9eefb16ec6e2fc819155df13103bb0202e46bd
\ No newline at end of file diff --git a/db/schema_migrations/20230914054914 b/db/schema_migrations/20230914054914 new file mode 100644 index 00000000000..c5cc5595ce6 --- /dev/null +++ b/db/schema_migrations/20230914054914 @@ -0,0 +1 @@ +9702393eb6db18d5d3d106c0a77c21419af828fe5a422dd5c06a2621ef10cf03
\ No newline at end of file diff --git a/db/schema_migrations/20230914185814 b/db/schema_migrations/20230914185814 new file mode 100644 index 00000000000..4a2f98bdd89 --- /dev/null +++ b/db/schema_migrations/20230914185814 @@ -0,0 +1 @@ +11eea8818e233b09048e89bb4b56beceab4f8f9c5702bb4c167a5d7ac8d99ccc
\ No newline at end of file diff --git a/db/schema_migrations/20230918194153 b/db/schema_migrations/20230918194153 new file mode 100644 index 00000000000..2fd045aa9ed --- /dev/null +++ b/db/schema_migrations/20230918194153 @@ -0,0 +1 @@ +1ec3edbe609cd0142790b28c3b55e50ae36be4119f741ce970b36fd8a788a2ce
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 89917d13133..9283a0c4800 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -82,6 +82,7 @@ DECLARE 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; @@ -118,8 +119,13 @@ BEGIN 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) + 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 @@ -147,6 +153,7 @@ DECLARE 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 @@ -164,8 +171,13 @@ BEGIN 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) + 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 @@ -341,6 +353,15 @@ BEGIN END; $$; +CREATE FUNCTION trigger_bbb95b2d6929() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + NEW."shared_runners_duration_convert_to_bigint" := NEW."shared_runners_duration"; + RETURN NEW; +END; +$$; + CREATE FUNCTION trigger_bfad0e2b9c86() RETURNS trigger LANGUAGE plpgsql AS $$ @@ -350,6 +371,15 @@ BEGIN END; $$; +CREATE FUNCTION trigger_c0353bbb6145() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + NEW."shared_runners_duration_convert_to_bigint" := NEW."shared_runners_duration"; + RETURN NEW; +END; +$$; + CREATE FUNCTION unset_has_issues_on_vulnerability_reads() RETURNS trigger LANGUAGE plpgsql AS $$ @@ -563,6 +593,14 @@ CREATE TABLE p_ci_runner_machine_builds ( ) PARTITION BY LIST (partition_id); +CREATE TABLE groups_visits ( + id bigint NOT NULL, + entity_id bigint NOT NULL, + user_id bigint NOT NULL, + visited_at timestamp with time zone NOT NULL +) +PARTITION BY RANGE (visited_at); + CREATE TABLE incident_management_pending_alert_escalations ( id bigint NOT NULL, rule_id bigint NOT NULL, @@ -608,6 +646,14 @@ CREATE TABLE p_batched_git_ref_updates_deletions ( ) PARTITION BY LIST (partition_id); +CREATE TABLE projects_visits ( + id bigint NOT NULL, + entity_id bigint NOT NULL, + user_id bigint NOT NULL, + visited_at timestamp with time zone NOT NULL +) +PARTITION BY RANGE (visited_at); + CREATE TABLE security_findings ( id bigint NOT NULL, scan_id bigint NOT NULL, @@ -11849,9 +11895,6 @@ CREATE TABLE application_settings ( encrypted_jitsu_administrator_password_iv bytea, dashboard_limit_enabled boolean DEFAULT false NOT NULL, dashboard_limit integer DEFAULT 0 NOT NULL, - dashboard_notification_limit integer DEFAULT 0 NOT NULL, - dashboard_enforcement_limit integer DEFAULT 0 NOT NULL, - dashboard_limit_new_namespace_creation_enforcement_date date, can_create_group boolean DEFAULT true NOT NULL, lock_maven_package_requests_forwarding boolean DEFAULT false NOT NULL, lock_pypi_package_requests_forwarding boolean DEFAULT false NOT NULL, @@ -11927,11 +11970,14 @@ CREATE TABLE application_settings ( package_registry_allow_anyone_to_pull_option boolean DEFAULT true NOT NULL, bulk_import_max_download_file_size bigint DEFAULT 5120 NOT NULL, max_import_remote_file_size bigint DEFAULT 10240 NOT NULL, - sentry_clientside_traces_sample_rate double precision DEFAULT 0.0 NOT NULL, protected_paths_for_get_request text[] DEFAULT '{}'::text[] NOT NULL, max_decompressed_archive_size integer DEFAULT 25600 NOT NULL, - ci_max_total_yaml_size_bytes integer DEFAULT 157286400 NOT NULL, + sentry_clientside_traces_sample_rate double precision DEFAULT 0.0 NOT NULL, prometheus_alert_db_indicators_settings jsonb, + ci_max_total_yaml_size_bytes integer DEFAULT 157286400 NOT NULL, + decompress_archive_file_timeout integer DEFAULT 210 NOT NULL, + search_rate_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL, + snowplow_database_collector_hostname text, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), @@ -11956,6 +12002,7 @@ CREATE TABLE application_settings ( CONSTRAINT check_32710817e9 CHECK ((char_length(static_objects_external_storage_auth_token_encrypted) <= 255)), CONSTRAINT check_3455368420 CHECK ((char_length(database_grafana_api_url) <= 255)), CONSTRAINT check_3559645ae5 CHECK ((char_length(container_registry_import_target_plan) <= 255)), + CONSTRAINT check_3b22213b72 CHECK ((char_length(snowplow_database_collector_hostname) <= 255)), CONSTRAINT check_3def0f1829 CHECK ((char_length(sentry_clientside_dsn) <= 255)), CONSTRAINT check_4847426287 CHECK ((char_length(jira_connect_proxy_url) <= 255)), CONSTRAINT check_492cc1354d CHECK ((char_length(error_tracking_api_url) <= 255)), @@ -12202,7 +12249,8 @@ CREATE TABLE approvals ( merge_request_id integer NOT NULL, user_id integer NOT NULL, created_at timestamp without time zone, - updated_at timestamp without time zone + updated_at timestamp without time zone, + patch_id_sha bytea ); CREATE SEQUENCE approvals_id_seq @@ -12283,6 +12331,32 @@ CREATE SEQUENCE atlassian_identities_user_id_seq ALTER SEQUENCE atlassian_identities_user_id_seq OWNED BY atlassian_identities.user_id; +CREATE TABLE audit_events_amazon_s3_configurations ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + namespace_id bigint NOT NULL, + access_key_xid text NOT NULL, + name text NOT NULL, + bucket_name text NOT NULL, + aws_region text NOT NULL, + encrypted_secret_access_key bytea NOT NULL, + encrypted_secret_access_key_iv bytea NOT NULL, + CONSTRAINT check_3a41f4ea06 CHECK ((char_length(bucket_name) <= 63)), + CONSTRAINT check_72b5aaa71b CHECK ((char_length(aws_region) <= 50)), + CONSTRAINT check_90505816db CHECK ((char_length(name) <= 72)), + CONSTRAINT check_ec46f06e01 CHECK ((char_length(access_key_xid) <= 128)) +); + +CREATE SEQUENCE audit_events_amazon_s3_configurations_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE audit_events_amazon_s3_configurations_id_seq OWNED BY audit_events_amazon_s3_configurations.id; + CREATE TABLE audit_events_external_audit_event_destinations ( id bigint NOT NULL, namespace_id bigint NOT NULL, @@ -12361,6 +12435,31 @@ CREATE SEQUENCE audit_events_instance_external_audit_event_destinations_id_seq ALTER SEQUENCE audit_events_instance_external_audit_event_destinations_id_seq OWNED BY audit_events_instance_external_audit_event_destinations.id; +CREATE TABLE audit_events_instance_google_cloud_logging_configurations ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + google_project_id_name text NOT NULL, + client_email text NOT NULL, + log_id_name text DEFAULT 'audit_events'::text, + name text NOT NULL, + encrypted_private_key bytea NOT NULL, + encrypted_private_key_iv bytea NOT NULL, + CONSTRAINT check_0da5c76c49 CHECK ((char_length(client_email) <= 254)), + CONSTRAINT check_74fd943192 CHECK ((char_length(log_id_name) <= 511)), + CONSTRAINT check_ab65f57721 CHECK ((char_length(google_project_id_name) <= 30)), + CONSTRAINT check_ac42ad3ca2 CHECK ((char_length(name) <= 72)) +); + +CREATE SEQUENCE audit_events_instance_google_cloud_logging_configuration_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE audit_events_instance_google_cloud_logging_configuration_id_seq OWNED BY audit_events_instance_google_cloud_logging_configurations.id; + CREATE TABLE audit_events_streaming_event_type_filters ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, @@ -13709,6 +13808,7 @@ CREATE TABLE ci_namespace_monthly_usages ( shared_runners_duration integer DEFAULT 0 NOT NULL, created_at timestamp with time zone, amount_used numeric(18,4) DEFAULT 0.0 NOT NULL, + shared_runners_duration_convert_to_bigint bigint DEFAULT 0 NOT NULL, CONSTRAINT ci_namespace_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone))) ); @@ -13995,6 +14095,7 @@ CREATE TABLE ci_project_monthly_usages ( shared_runners_duration integer DEFAULT 0 NOT NULL, created_at timestamp with time zone, amount_used numeric(18,4) DEFAULT 0.0 NOT NULL, + shared_runners_duration_convert_to_bigint bigint DEFAULT 0 NOT NULL, CONSTRAINT ci_project_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone))) ); @@ -16416,9 +16517,7 @@ CREATE TABLE geo_node_statuses ( lfs_objects_count integer, lfs_objects_synced_count integer, lfs_objects_failed_count integer, - last_event_id integer, last_event_date timestamp without time zone, - cursor_last_event_id integer, cursor_last_event_date timestamp without time zone, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, @@ -16458,7 +16557,9 @@ CREATE TABLE geo_node_statuses ( design_repositories_synced_count integer, design_repositories_failed_count integer, design_repositories_registry_count integer, - status jsonb DEFAULT '{}'::jsonb NOT NULL + status jsonb DEFAULT '{}'::jsonb NOT NULL, + last_event_id bigint, + cursor_last_event_id bigint ); CREATE SEQUENCE geo_node_statuses_id_seq @@ -16920,7 +17021,8 @@ CREATE TABLE group_merge_request_approval_settings ( allow_committer_approval boolean DEFAULT false NOT NULL, allow_overrides_to_approver_list_per_merge_request boolean DEFAULT false NOT NULL, retain_approvals_on_push boolean DEFAULT false NOT NULL, - require_password_to_approve boolean DEFAULT false NOT NULL + require_password_to_approve boolean DEFAULT false NOT NULL, + require_saml_auth_to_approve boolean DEFAULT false NOT NULL ); CREATE TABLE group_repository_storage_moves ( @@ -16993,6 +17095,15 @@ CREATE SEQUENCE group_wiki_repository_states_id_seq ALTER SEQUENCE group_wiki_repository_states_id_seq OWNED BY group_wiki_repository_states.id; +CREATE SEQUENCE groups_visits_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE groups_visits_id_seq OWNED BY groups_visits.id; + CREATE TABLE historical_data ( id integer NOT NULL, date date, @@ -18145,6 +18256,7 @@ CREATE TABLE member_roles ( read_dependency boolean DEFAULT false NOT NULL, name text DEFAULT 'Custom'::text NOT NULL, description text, + admin_merge_request boolean DEFAULT false NOT NULL, CONSTRAINT check_4364846f58 CHECK ((char_length(description) <= 255)), CONSTRAINT check_9907916995 CHECK ((char_length(name) <= 255)) ); @@ -18501,6 +18613,8 @@ CREATE TABLE merge_request_review_llm_summaries ( updated_at timestamp with time zone NOT NULL, provider smallint NOT NULL, content text NOT NULL, + cached_markdown_version integer, + content_html text, CONSTRAINT check_72802358e9 CHECK ((char_length(content) <= 2056)) ); @@ -18592,6 +18706,7 @@ CREATE TABLE merge_requests ( merge_ref_sha bytea, draft boolean DEFAULT false NOT NULL, prepared_at timestamp with time zone, + merged_commit_sha bytea, CONSTRAINT check_970d272570 CHECK ((lock_version IS NOT NULL)) ); @@ -18974,11 +19089,7 @@ CREATE TABLE namespace_details ( updated_at timestamp with time zone, cached_markdown_version integer, description text, - description_html text, - free_user_cap_over_limit_notified_at timestamp with time zone, - dashboard_notification_at timestamp with time zone, - dashboard_enforcement_at timestamp with time zone, - next_over_limit_check_at timestamp with time zone + description_html text ); CREATE TABLE namespace_ldap_settings ( @@ -20117,6 +20228,32 @@ CREATE TABLE packages_nuget_metadata ( CONSTRAINT packages_nuget_metadata_project_url_constraint CHECK ((char_length(project_url) <= 255)) ); +CREATE TABLE packages_nuget_symbols ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + package_id bigint, + size integer NOT NULL, + file_store smallint DEFAULT 1, + file text NOT NULL, + file_path text NOT NULL, + signature text NOT NULL, + object_storage_key text NOT NULL, + CONSTRAINT check_0e93ca58b7 CHECK ((char_length(file) <= 255)), + CONSTRAINT check_28b82b08fa CHECK ((char_length(object_storage_key) <= 255)), + CONSTRAINT check_30b0ef2ca2 CHECK ((char_length(file_path) <= 255)), + CONSTRAINT check_8dc7152679 CHECK ((char_length(signature) <= 255)) +); + +CREATE SEQUENCE packages_nuget_symbols_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE packages_nuget_symbols_id_seq OWNED BY packages_nuget_symbols.id; + CREATE TABLE packages_package_file_build_infos ( id bigint NOT NULL, package_file_id bigint NOT NULL, @@ -20187,11 +20324,43 @@ CREATE SEQUENCE packages_packages_id_seq ALTER SEQUENCE packages_packages_id_seq OWNED BY packages_packages.id; +CREATE TABLE packages_protection_rules ( + id bigint NOT NULL, + project_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + push_protected_up_to_access_level integer NOT NULL, + package_type smallint NOT NULL, + package_name_pattern text NOT NULL, + CONSTRAINT check_d2d75d206d CHECK ((char_length(package_name_pattern) <= 255)) +); + +CREATE SEQUENCE packages_protection_rules_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE packages_protection_rules_id_seq OWNED BY packages_protection_rules.id; + CREATE TABLE packages_pypi_metadata ( package_id bigint NOT NULL, required_python text DEFAULT ''::text, + metadata_version text, + summary text, + keywords text, + author_email text, + description text, + description_content_type text, + CONSTRAINT check_02be2c39af CHECK ((char_length(keywords) <= 255)), CONSTRAINT check_0d9aed55b2 CHECK ((required_python IS NOT NULL)), - CONSTRAINT check_379019d5da CHECK ((char_length(required_python) <= 255)) + CONSTRAINT check_2d3ed32225 CHECK ((char_length(metadata_version) <= 16)), + CONSTRAINT check_379019d5da CHECK ((char_length(required_python) <= 255)), + CONSTRAINT check_65d8dbbd9f CHECK ((char_length(author_email) <= 2048)), + CONSTRAINT check_76afb6d4f3 CHECK ((char_length(summary) <= 255)), + CONSTRAINT check_80308aa9bd CHECK ((char_length(description) <= 4000)), + CONSTRAINT check_b1f32be96c CHECK ((char_length(description_content_type) <= 128)) ); CREATE TABLE packages_rpm_metadata ( @@ -20341,6 +20510,7 @@ CREATE TABLE pages_deployments ( root_directory text DEFAULT 'public'::text, path_prefix text, build_ref text, + deleted_at timestamp with time zone, CONSTRAINT check_4d04b8dc9a CHECK ((char_length(path_prefix) <= 128)), CONSTRAINT check_5f9132a958 CHECK ((size IS NOT NULL)), CONSTRAINT check_7e938c810a CHECK ((char_length(root_directory) <= 255)), @@ -20545,7 +20715,8 @@ CREATE TABLE plan_limits ( ci_max_artifact_size_annotations integer DEFAULT 0 NOT NULL, ci_job_annotations_size integer DEFAULT 81920 NOT NULL, ci_job_annotations_num integer DEFAULT 20 NOT NULL, - file_size_limit_mb double precision DEFAULT 100.0 NOT NULL + file_size_limit_mb double precision DEFAULT 100.0 NOT NULL, + audit_events_amazon_s3_configurations integer DEFAULT 5 NOT NULL ); CREATE SEQUENCE plan_limits_id_seq @@ -21177,7 +21348,8 @@ CREATE TABLE project_ci_cd_settings ( separated_caches boolean DEFAULT true NOT NULL, allow_fork_pipelines_to_run_in_parent_project boolean DEFAULT true NOT NULL, inbound_job_token_scope_enabled boolean DEFAULT true NOT NULL, - forward_deployment_rollback_allowed boolean DEFAULT true NOT NULL + forward_deployment_rollback_allowed boolean DEFAULT true NOT NULL, + merge_trains_skip_train_allowed boolean DEFAULT false NOT NULL ); CREATE SEQUENCE project_ci_cd_settings_id_seq @@ -21595,7 +21767,8 @@ CREATE TABLE project_security_settings ( auto_fix_container_scanning boolean DEFAULT true NOT NULL, auto_fix_dast boolean DEFAULT true NOT NULL, auto_fix_dependency_scanning boolean DEFAULT true NOT NULL, - auto_fix_sast boolean DEFAULT true NOT NULL + auto_fix_sast boolean DEFAULT true NOT NULL, + continuous_vulnerability_scans_enabled boolean DEFAULT false NOT NULL ); CREATE SEQUENCE project_security_settings_project_id_seq @@ -21654,6 +21827,7 @@ CREATE TABLE project_settings ( encrypted_cube_api_key_iv bytea, encrypted_product_analytics_configurator_connection_string bytea, encrypted_product_analytics_configurator_connection_string_iv bytea, + pages_multiple_versions_enabled boolean DEFAULT false NOT NULL, CONSTRAINT check_1a30456322 CHECK ((char_length(pages_unique_domain) <= 63)), CONSTRAINT check_2981f15877 CHECK ((char_length(jitsu_key) <= 100)), CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)), @@ -21710,7 +21884,8 @@ CREATE TABLE project_statistics ( uploads_size bigint DEFAULT 0 NOT NULL, container_registry_size bigint DEFAULT 0 NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + root_namespace_id bigint ); CREATE SEQUENCE project_statistics_id_seq @@ -21837,7 +22012,8 @@ CREATE TABLE projects ( autoclose_referenced_issues boolean, suggestion_commit_message character varying(255), project_namespace_id bigint, - hidden boolean DEFAULT false NOT NULL + hidden boolean DEFAULT false NOT NULL, + organization_id bigint DEFAULT 1 ); CREATE SEQUENCE projects_id_seq @@ -21863,6 +22039,15 @@ CREATE SEQUENCE projects_sync_events_id_seq ALTER SEQUENCE projects_sync_events_id_seq OWNED BY projects_sync_events.id; +CREATE SEQUENCE projects_visits_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE projects_visits_id_seq OWNED BY projects_visits.id; + CREATE TABLE prometheus_alert_events ( id bigint NOT NULL, project_id integer NOT NULL, @@ -22142,7 +22327,14 @@ CREATE TABLE push_rules ( regexp_uses_re2 boolean DEFAULT true, commit_message_negative_regex character varying, reject_non_dco_commits boolean, - commit_committer_name_check boolean DEFAULT false NOT NULL + commit_committer_name_check boolean DEFAULT false NOT NULL, + CONSTRAINT author_email_regex_size_constraint CHECK ((char_length((author_email_regex)::text) <= 511)), + CONSTRAINT branch_name_regex_size_constraint CHECK ((char_length((branch_name_regex)::text) <= 511)), + CONSTRAINT commit_message_negative_regex_size_constraint CHECK ((char_length((commit_message_negative_regex)::text) <= 2047)), + CONSTRAINT commit_message_regex_size_constraint CHECK ((char_length((commit_message_regex)::text) <= 511)), + CONSTRAINT delete_branch_regex_size_constraint CHECK ((char_length((delete_branch_regex)::text) <= 511)), + CONSTRAINT file_name_regex_size_constraint CHECK ((char_length((file_name_regex)::text) <= 511)), + CONSTRAINT force_push_regex_size_constraint CHECK ((char_length((force_push_regex)::text) <= 511)) ); CREATE SEQUENCE push_rules_id_seq @@ -22649,6 +22841,7 @@ CREATE TABLE sbom_occurrences ( package_manager text, component_name text, input_file_path text, + licenses jsonb DEFAULT '[]'::jsonb, CONSTRAINT check_3f2d2c7ffc CHECK ((char_length(package_manager) <= 255)), CONSTRAINT check_9b29021fa8 CHECK ((char_length(component_name) <= 255)), CONSTRAINT check_bd1367d4c1 CHECK ((char_length(input_file_path) <= 255)) @@ -22695,6 +22888,8 @@ CREATE TABLE scan_result_policies ( vulnerability_attributes jsonb DEFAULT '{}'::jsonb, project_id bigint, rule_idx smallint, + project_approval_settings jsonb DEFAULT '{}'::jsonb NOT NULL, + commits smallint, CONSTRAINT age_value_null_or_positive CHECK (((age_value IS NULL) OR (age_value >= 0))), CONSTRAINT check_scan_result_policies_rule_idx_positive CHECK (((rule_idx IS NULL) OR (rule_idx >= 0))) ); @@ -23935,9 +24130,17 @@ CREATE TABLE user_credit_card_validations ( last_digits smallint, holder_name text, network text, + last_digits_hash text, + holder_name_hash text, + expiration_date_hash text, + network_hash text, CONSTRAINT check_1765e2b30f CHECK ((char_length(network) <= 32)), CONSTRAINT check_3eea080c91 CHECK (((last_digits >= 0) AND (last_digits <= 9999))), - CONSTRAINT check_cc0c8dc0fe CHECK ((char_length(holder_name) <= 50)) + CONSTRAINT check_7721e1961a CHECK ((char_length(network_hash) <= 44)), + CONSTRAINT check_83f1e2ace3 CHECK ((char_length(expiration_date_hash) <= 44)), + CONSTRAINT check_aca7c2607c CHECK ((char_length(holder_name_hash) <= 44)), + CONSTRAINT check_cc0c8dc0fe CHECK ((char_length(holder_name) <= 50)), + CONSTRAINT check_f5c35b1a6e CHECK ((char_length(last_digits_hash) <= 44)) ); CREATE TABLE user_custom_attributes ( @@ -24131,6 +24334,7 @@ CREATE TABLE user_preferences ( visibility_pipeline_id_type smallint DEFAULT 0 NOT NULL, project_shortcut_buttons boolean DEFAULT true NOT NULL, enabled_zoekt boolean DEFAULT true NOT NULL, + keyboard_shortcuts_enabled boolean DEFAULT true NOT NULL, CONSTRAINT check_89bf269f41 CHECK ((char_length(diffs_deletion_color) <= 7)), CONSTRAINT check_d07ccd35f7 CHECK ((char_length(diffs_addition_color) <= 7)) ); @@ -24404,7 +24608,8 @@ CREATE TABLE vulnerabilities ( dismissed_by_id bigint, resolved_on_default_branch boolean DEFAULT false NOT NULL, present_on_default_branch boolean DEFAULT true NOT NULL, - detected_at timestamp with time zone DEFAULT now() + detected_at timestamp with time zone DEFAULT now(), + finding_id bigint ); CREATE SEQUENCE vulnerabilities_id_seq @@ -25055,7 +25260,9 @@ CREATE TABLE work_item_progresses ( progress smallint DEFAULT 0 NOT NULL, start_value double precision DEFAULT 0.0 NOT NULL, end_value double precision DEFAULT 100.0 NOT NULL, - current_value double precision DEFAULT 0.0 NOT NULL + current_value double precision DEFAULT 0.0 NOT NULL, + rollup_progress boolean DEFAULT true NOT NULL, + reminder_frequency smallint DEFAULT 0 NOT NULL ); CREATE TABLE work_item_types ( @@ -25101,6 +25308,27 @@ CREATE SEQUENCE work_item_widget_definitions_id_seq ALTER SEQUENCE work_item_widget_definitions_id_seq OWNED BY work_item_widget_definitions.id; +CREATE TABLE workspace_variables ( + id bigint NOT NULL, + workspace_id bigint NOT NULL, + variable_type smallint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + key text NOT NULL, + encrypted_value bytea NOT NULL, + encrypted_value_iv bytea NOT NULL, + CONSTRAINT check_5545042100 CHECK ((char_length(key) <= 255)) +); + +CREATE SEQUENCE workspace_variables_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE workspace_variables_id_seq OWNED BY workspace_variables.id; + CREATE TABLE workspaces ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, @@ -25122,6 +25350,9 @@ CREATE TABLE workspaces ( processed_devfile text, url text NOT NULL, deployment_resource_version text, + personal_access_token_id bigint, + config_version integer DEFAULT 1 NOT NULL, + force_full_reconciliation boolean DEFAULT false NOT NULL, CONSTRAINT check_15543fb0fa CHECK ((char_length(name) <= 64)), CONSTRAINT check_157d5f955c CHECK ((char_length(namespace) <= 64)), CONSTRAINT check_2b401b0034 CHECK ((char_length(deployment_resource_version) <= 64)), @@ -25149,7 +25380,7 @@ CREATE TABLE x509_certificates ( created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, subject_key_identifier character varying(255) NOT NULL, - subject character varying(512) NOT NULL, + subject character varying(512), email character varying(255) NOT NULL, serial_number bytea NOT NULL, certificate_status smallint DEFAULT 0 NOT NULL, @@ -25190,8 +25421,8 @@ CREATE TABLE x509_issuers ( created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, subject_key_identifier character varying(255) NOT NULL, - subject character varying(255) NOT NULL, - crl_url character varying(255) NOT NULL + subject character varying(255), + crl_url character varying(255) ); CREATE SEQUENCE x509_issuers_id_seq @@ -25361,12 +25592,16 @@ ALTER TABLE ONLY atlassian_identities ALTER COLUMN user_id SET DEFAULT nextval(' ALTER TABLE ONLY audit_events ALTER COLUMN id SET DEFAULT nextval('audit_events_id_seq'::regclass); +ALTER TABLE ONLY audit_events_amazon_s3_configurations ALTER COLUMN id SET DEFAULT nextval('audit_events_amazon_s3_configurations_id_seq'::regclass); + ALTER TABLE ONLY audit_events_external_audit_event_destinations ALTER COLUMN id SET DEFAULT nextval('audit_events_external_audit_event_destinations_id_seq'::regclass); ALTER TABLE ONLY audit_events_google_cloud_logging_configurations ALTER COLUMN id SET DEFAULT nextval('audit_events_google_cloud_logging_configurations_id_seq'::regclass); ALTER TABLE ONLY audit_events_instance_external_audit_event_destinations ALTER COLUMN id SET DEFAULT nextval('audit_events_instance_external_audit_event_destinations_id_seq'::regclass); +ALTER TABLE ONLY audit_events_instance_google_cloud_logging_configurations ALTER COLUMN id SET DEFAULT nextval('audit_events_instance_google_cloud_logging_configuration_id_seq'::regclass); + ALTER TABLE ONLY audit_events_streaming_event_type_filters ALTER COLUMN id SET DEFAULT nextval('audit_events_streaming_event_type_filters_id_seq'::regclass); ALTER TABLE ONLY audit_events_streaming_headers ALTER COLUMN id SET DEFAULT nextval('audit_events_streaming_headers_id_seq'::regclass); @@ -25755,6 +25990,8 @@ ALTER TABLE ONLY group_ssh_certificates ALTER COLUMN id SET DEFAULT nextval('gro ALTER TABLE ONLY group_wiki_repository_states ALTER COLUMN id SET DEFAULT nextval('group_wiki_repository_states_id_seq'::regclass); +ALTER TABLE ONLY groups_visits ALTER COLUMN id SET DEFAULT nextval('groups_visits_id_seq'::regclass); + ALTER TABLE ONLY historical_data ALTER COLUMN id SET DEFAULT nextval('historical_data_id_seq'::regclass); ALTER TABLE ONLY identities ALTER COLUMN id SET DEFAULT nextval('identities_id_seq'::regclass); @@ -26023,12 +26260,16 @@ ALTER TABLE ONLY packages_maven_metadata ALTER COLUMN id SET DEFAULT nextval('pa ALTER TABLE ONLY packages_npm_metadata_caches ALTER COLUMN id SET DEFAULT nextval('packages_npm_metadata_caches_id_seq'::regclass); +ALTER TABLE ONLY packages_nuget_symbols ALTER COLUMN id SET DEFAULT nextval('packages_nuget_symbols_id_seq'::regclass); + ALTER TABLE ONLY packages_package_file_build_infos ALTER COLUMN id SET DEFAULT nextval('packages_package_file_build_infos_id_seq'::regclass); ALTER TABLE ONLY packages_package_files ALTER COLUMN id SET DEFAULT nextval('packages_package_files_id_seq'::regclass); ALTER TABLE ONLY packages_packages ALTER COLUMN id SET DEFAULT nextval('packages_packages_id_seq'::regclass); +ALTER TABLE ONLY packages_protection_rules ALTER COLUMN id SET DEFAULT nextval('packages_protection_rules_id_seq'::regclass); + ALTER TABLE ONLY packages_rpm_repository_files ALTER COLUMN id SET DEFAULT nextval('packages_rpm_repository_files_id_seq'::regclass); ALTER TABLE ONLY packages_tags ALTER COLUMN id SET DEFAULT nextval('packages_tags_id_seq'::regclass); @@ -26135,6 +26376,8 @@ ALTER TABLE ONLY projects ALTER COLUMN id SET DEFAULT nextval('projects_id_seq': ALTER TABLE ONLY projects_sync_events ALTER COLUMN id SET DEFAULT nextval('projects_sync_events_id_seq'::regclass); +ALTER TABLE ONLY projects_visits ALTER COLUMN id SET DEFAULT nextval('projects_visits_id_seq'::regclass); + ALTER TABLE ONLY prometheus_alert_events ALTER COLUMN id SET DEFAULT nextval('prometheus_alert_events_id_seq'::regclass); ALTER TABLE ONLY prometheus_alerts ALTER COLUMN id SET DEFAULT nextval('prometheus_alerts_id_seq'::regclass); @@ -26419,6 +26662,8 @@ ALTER TABLE ONLY work_item_types ALTER COLUMN id SET DEFAULT nextval('work_item_ ALTER TABLE ONLY work_item_widget_definitions ALTER COLUMN id SET DEFAULT nextval('work_item_widget_definitions_id_seq'::regclass); +ALTER TABLE ONLY workspace_variables ALTER COLUMN id SET DEFAULT nextval('workspace_variables_id_seq'::regclass); + ALTER TABLE ONLY workspaces ALTER COLUMN id SET DEFAULT nextval('workspaces_id_seq'::regclass); ALTER TABLE ONLY x509_certificates ALTER COLUMN id SET DEFAULT nextval('x509_certificates_id_seq'::regclass); @@ -27149,6 +27394,9 @@ ALTER TABLE ONLY ar_internal_metadata ALTER TABLE ONLY atlassian_identities ADD CONSTRAINT atlassian_identities_pkey PRIMARY KEY (user_id); +ALTER TABLE ONLY audit_events_amazon_s3_configurations + ADD CONSTRAINT audit_events_amazon_s3_configurations_pkey PRIMARY KEY (id); + ALTER TABLE ONLY audit_events_external_audit_event_destinations ADD CONSTRAINT audit_events_external_audit_event_destinations_pkey PRIMARY KEY (id); @@ -27158,6 +27406,9 @@ ALTER TABLE ONLY audit_events_google_cloud_logging_configurations ALTER TABLE ONLY audit_events_instance_external_audit_event_destinations ADD CONSTRAINT audit_events_instance_external_audit_event_destinations_pkey PRIMARY KEY (id); +ALTER TABLE ONLY audit_events_instance_google_cloud_logging_configurations + ADD CONSTRAINT audit_events_instance_google_cloud_logging_configurations_pkey PRIMARY KEY (id); + ALTER TABLE ONLY audit_events ADD CONSTRAINT audit_events_pkey PRIMARY KEY (id, created_at); @@ -27878,6 +28129,9 @@ ALTER TABLE ONLY group_wiki_repositories ALTER TABLE ONLY group_wiki_repository_states ADD CONSTRAINT group_wiki_repository_states_pkey PRIMARY KEY (id); +ALTER TABLE ONLY groups_visits + ADD CONSTRAINT groups_visits_pkey PRIMARY KEY (id, visited_at); + ALTER TABLE ONLY historical_data ADD CONSTRAINT historical_data_pkey PRIMARY KEY (id); @@ -28355,6 +28609,9 @@ ALTER TABLE ONLY packages_nuget_dependency_link_metadata ALTER TABLE ONLY packages_nuget_metadata ADD CONSTRAINT packages_nuget_metadata_pkey PRIMARY KEY (package_id); +ALTER TABLE ONLY packages_nuget_symbols + ADD CONSTRAINT packages_nuget_symbols_pkey PRIMARY KEY (id); + ALTER TABLE ONLY packages_package_file_build_infos ADD CONSTRAINT packages_package_file_build_infos_pkey PRIMARY KEY (id); @@ -28364,6 +28621,9 @@ ALTER TABLE ONLY packages_package_files ALTER TABLE ONLY packages_packages ADD CONSTRAINT packages_packages_pkey PRIMARY KEY (id); +ALTER TABLE ONLY packages_protection_rules + ADD CONSTRAINT packages_protection_rules_pkey PRIMARY KEY (id); + ALTER TABLE ONLY packages_pypi_metadata ADD CONSTRAINT packages_pypi_metadata_pkey PRIMARY KEY (package_id); @@ -28553,6 +28813,9 @@ ALTER TABLE ONLY projects ALTER TABLE ONLY projects_sync_events ADD CONSTRAINT projects_sync_events_pkey PRIMARY KEY (id); +ALTER TABLE ONLY projects_visits + ADD CONSTRAINT projects_visits_pkey PRIMARY KEY (id, visited_at); + ALTER TABLE ONLY prometheus_alert_events ADD CONSTRAINT prometheus_alert_events_pkey PRIMARY KEY (id); @@ -29036,6 +29299,9 @@ ALTER TABLE ONLY work_item_types ALTER TABLE ONLY work_item_widget_definitions ADD CONSTRAINT work_item_widget_definitions_pkey PRIMARY KEY (id); +ALTER TABLE ONLY workspace_variables + ADD CONSTRAINT workspace_variables_pkey PRIMARY KEY (id); + ALTER TABLE ONLY workspaces ADD CONSTRAINT workspaces_pkey PRIMARY KEY (id); @@ -30324,6 +30590,8 @@ CREATE INDEX i_dast_profiles_tags_on_scanner_profiles_id ON dast_profiles_tags U CREATE INDEX i_dast_scanner_profiles_tags_on_scanner_profiles_id ON dast_scanner_profiles_tags USING btree (dast_scanner_profile_id); +CREATE UNIQUE INDEX i_packages_unique_project_id_package_type_package_name_pattern ON packages_protection_rules USING btree (project_id, package_type, package_name_pattern); + CREATE INDEX i_pkgs_deb_file_meta_on_updated_at_package_file_id_when_unknown ON packages_debian_file_metadata USING btree (updated_at, package_file_id) WHERE (file_type = 1); CREATE UNIQUE INDEX i_pm_licenses_on_spdx_identifier ON pm_licenses USING btree (spdx_identifier); @@ -30334,6 +30602,8 @@ CREATE UNIQUE INDEX i_pm_package_versions_on_package_id_and_version ON pm_packag CREATE UNIQUE INDEX i_pm_packages_purl_type_and_name ON pm_packages USING btree (purl_type, name); +CREATE INDEX idx_abuse_reports_user_id_status_and_category ON abuse_reports USING btree (user_id, status, category); + CREATE INDEX idx_alert_management_alerts_on_created_at_project_id_with_issue ON alert_management_alerts USING btree (created_at, project_id) WHERE (issue_id IS NOT NULL); CREATE INDEX idx_analytics_devops_adoption_segments_on_namespace_id ON analytics_devops_adoption_segments USING btree (namespace_id); @@ -31084,8 +31354,12 @@ CREATE INDEX index_ci_pipeline_chat_data_on_chat_name_id ON ci_pipeline_chat_dat CREATE UNIQUE INDEX index_ci_pipeline_chat_data_on_pipeline_id ON ci_pipeline_chat_data USING btree (pipeline_id); +CREATE UNIQUE INDEX index_ci_pipeline_chat_data_on_pipeline_id_convert_to_bigint ON ci_pipeline_chat_data USING btree (pipeline_id_convert_to_bigint); + CREATE INDEX index_ci_pipeline_messages_on_pipeline_id ON ci_pipeline_messages USING btree (pipeline_id); +CREATE INDEX index_ci_pipeline_messages_on_pipeline_id_convert_to_bigint ON ci_pipeline_messages USING btree (pipeline_id_convert_to_bigint); + CREATE INDEX index_ci_pipeline_metadata_on_project_id ON ci_pipeline_metadata USING btree (project_id); CREATE UNIQUE INDEX index_ci_pipeline_schedule_variables_on_schedule_id_and_key ON ci_pipeline_schedule_variables USING btree (pipeline_schedule_id, key); @@ -31254,6 +31528,14 @@ CREATE UNIQUE INDEX index_ci_stages_on_pipeline_id_and_name ON ci_stages USING b CREATE INDEX index_ci_stages_on_pipeline_id_and_position ON ci_stages USING btree (pipeline_id, "position"); +CREATE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint ON ci_stages USING btree (pipeline_id_convert_to_bigint); + +CREATE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint_and_id ON ci_stages USING btree (pipeline_id_convert_to_bigint, id) WHERE (status = ANY (ARRAY[0, 1, 2, 8, 9, 10])); + +CREATE UNIQUE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint_and_name ON ci_stages USING btree (pipeline_id_convert_to_bigint, name); + +CREATE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint_and_position ON ci_stages USING btree (pipeline_id_convert_to_bigint, "position"); + CREATE INDEX index_ci_stages_on_project_id ON ci_stages USING btree (project_id); CREATE INDEX index_ci_subscriptions_projects_author_id ON ci_subscriptions_projects USING btree (author_id); @@ -31510,8 +31792,6 @@ CREATE INDEX index_deployments_on_environment_status_sha ON deployments USING bt CREATE INDEX index_deployments_on_id_and_status_and_created_at ON deployments USING btree (id, status, created_at); -CREATE INDEX index_deployments_on_id_where_cluster_id_present ON deployments USING btree (id) WHERE (cluster_id IS NOT NULL); - CREATE INDEX index_deployments_on_project_and_environment_and_updated_at_id ON deployments USING btree (project_id, environment_id, updated_at, id); CREATE INDEX index_deployments_on_project_and_finished ON deployments USING btree (project_id, finished_at) WHERE (status = 2); @@ -31746,8 +32026,6 @@ CREATE UNIQUE INDEX index_fork_network_members_on_project_id ON fork_network_mem CREATE UNIQUE INDEX index_fork_networks_on_root_project_id ON fork_networks USING btree (root_project_id); -CREATE INDEX index_fuc_over_limit_notified_at ON namespace_details USING btree (free_user_cap_over_limit_notified_at); - CREATE INDEX index_geo_event_log_on_cache_invalidation_event_id ON geo_event_log USING btree (cache_invalidation_event_id) WHERE (cache_invalidation_event_id IS NOT NULL); CREATE INDEX index_geo_event_log_on_geo_event_id ON geo_event_log USING btree (geo_event_id) WHERE (geo_event_id IS NOT NULL); @@ -31912,6 +32190,10 @@ CREATE INDEX index_groups_on_parent_id_id ON namespaces USING btree (parent_id, CREATE INDEX index_groups_on_path_and_id ON namespaces USING btree (path, id) WHERE ((type)::text = 'Group'::text); +CREATE INDEX index_groups_visits_on_entity_id ON ONLY groups_visits USING btree (entity_id); + +CREATE INDEX index_groups_visits_on_user_id_and_entity_id_and_visited_at ON ONLY groups_visits USING btree (user_id, entity_id, visited_at); + CREATE INDEX index_historical_data_on_recorded_at ON historical_data USING btree (recorded_at); CREATE UNIQUE INDEX index_http_integrations_on_project_and_endpoint ON alert_management_http_integrations USING btree (project_id, endpoint_identifier); @@ -32342,6 +32624,8 @@ CREATE INDEX index_merge_requests_compliance_violations_on_violating_user_id ON CREATE UNIQUE INDEX index_merge_requests_compliance_violations_unique_columns ON merge_requests_compliance_violations USING btree (merge_request_id, violating_user_id, reason); +CREATE INDEX index_merge_requests_id_created_at_prepared_at ON merge_requests USING btree (created_at, id) WHERE (prepared_at IS NULL); + CREATE INDEX index_merge_requests_on_assignee_id ON merge_requests USING btree (assignee_id); CREATE INDEX index_merge_requests_on_author_id ON merge_requests USING btree (author_id); @@ -32358,8 +32642,6 @@ CREATE INDEX index_merge_requests_on_description_trigram ON merge_requests USING CREATE INDEX index_merge_requests_on_head_pipeline_id ON merge_requests USING btree (head_pipeline_id); -CREATE INDEX index_merge_requests_on_id_and_prepared_at ON merge_requests USING btree (id) WHERE (prepared_at IS NULL); - CREATE INDEX index_merge_requests_on_latest_merge_request_diff_id ON merge_requests USING btree (latest_merge_request_diff_id); CREATE INDEX index_merge_requests_on_merge_user_id ON merge_requests USING btree (merge_user_id) WHERE (merge_user_id IS NOT NULL); @@ -32380,6 +32662,8 @@ CREATE UNIQUE INDEX index_merge_requests_on_target_project_id_and_iid ON merge_r CREATE INDEX index_merge_requests_on_target_project_id_and_iid_and_state_id ON merge_requests USING btree (target_project_id, iid, state_id); +CREATE INDEX index_merge_requests_on_target_project_id_and_merged_commit_sha ON merge_requests USING btree (target_project_id, merged_commit_sha); + CREATE INDEX index_merge_requests_on_target_project_id_and_source_branch ON merge_requests USING btree (target_project_id, source_branch); CREATE INDEX index_merge_requests_on_target_project_id_and_squash_commit_sha ON merge_requests USING btree (target_project_id, squash_commit_sha); @@ -32550,8 +32834,6 @@ CREATE INDEX index_namespaces_public_groups_name_id ON namespaces USING btree (n CREATE INDEX index_namespaces_sync_events_on_namespace_id ON namespaces_sync_events USING btree (namespace_id); -CREATE INDEX index_next_over_limit_check_at_asc_order ON namespace_details USING btree (next_over_limit_check_at NULLS FIRST); - CREATE INDEX index_non_requested_project_members_on_source_id_and_type ON members USING btree (source_id, source_type) WHERE ((requested_at IS NULL) AND ((type)::text = 'ProjectMember'::text)); CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON note_diff_files USING btree (diff_note_id); @@ -32700,6 +32982,8 @@ CREATE UNIQUE INDEX index_ops_feature_flags_issues_on_feature_flag_id_and_issue_ CREATE UNIQUE INDEX index_ops_strategies_user_lists_on_strategy_id_and_user_list_id ON operations_strategies_user_lists USING btree (strategy_id, user_list_id); +CREATE INDEX index_organization_users_on_organization_id_and_id ON organization_users USING btree (organization_id, id); + CREATE UNIQUE INDEX index_organization_users_on_organization_id_and_user_id ON organization_users USING btree (organization_id, user_id); CREATE INDEX index_organization_users_on_user_id ON organization_users USING btree (user_id); @@ -32758,6 +33042,12 @@ CREATE INDEX index_packages_npm_metadata_caches_on_project_id ON packages_npm_me CREATE INDEX index_packages_nuget_dl_metadata_on_dependency_link_id ON packages_nuget_dependency_link_metadata USING btree (dependency_link_id); +CREATE UNIQUE INDEX index_packages_nuget_symbols_on_object_storage_key ON packages_nuget_symbols USING btree (object_storage_key); + +CREATE INDEX index_packages_nuget_symbols_on_package_id ON packages_nuget_symbols USING btree (package_id); + +CREATE UNIQUE INDEX index_packages_nuget_symbols_on_signature_and_file_path ON packages_nuget_symbols USING btree (signature, file_path); + CREATE INDEX index_packages_on_available_pypi_packages ON packages_packages USING btree (project_id, id) WHERE ((status = ANY (ARRAY[0, 1])) AND (package_type = 5) AND (version IS NOT NULL)); CREATE INDEX index_packages_package_file_build_infos_on_package_file_id ON packages_package_file_build_infos USING btree (package_file_id); @@ -32826,8 +33116,6 @@ CREATE INDEX index_pages_deployments_on_file_store_and_id ON pages_deployments U CREATE INDEX index_pages_deployments_on_project_id ON pages_deployments USING btree (project_id); -CREATE UNIQUE INDEX index_pages_deployments_unique_path_prefix_by_project ON pages_deployments USING btree (project_id, path_prefix); - CREATE INDEX index_pages_domain_acme_orders_on_challenge_token ON pages_domain_acme_orders USING btree (challenge_token); CREATE INDEX index_pages_domain_acme_orders_on_pages_domain_id ON pages_domain_acme_orders USING btree (pages_domain_id); @@ -33026,6 +33314,8 @@ CREATE UNIQUE INDEX index_project_statistics_on_project_id ON project_statistics CREATE INDEX index_project_statistics_on_repository_size_and_project_id ON project_statistics USING btree (repository_size, project_id); +CREATE INDEX index_project_statistics_on_root_namespace_id ON project_statistics USING btree (root_namespace_id); + CREATE INDEX index_project_statistics_on_storage_size_and_project_id ON project_statistics USING btree (storage_size, project_id); CREATE INDEX index_project_statistics_on_wiki_size_and_project_id ON project_statistics USING btree (wiki_size, project_id); @@ -33110,6 +33400,8 @@ CREATE INDEX index_projects_on_namespace_id_and_id ON projects USING btree (name CREATE INDEX index_projects_on_namespace_id_and_repository_size_limit ON projects USING btree (namespace_id, repository_size_limit); +CREATE INDEX index_projects_on_organization_id ON projects USING btree (organization_id); + CREATE INDEX index_projects_on_path_and_id ON projects USING btree (path, id); CREATE INDEX index_projects_on_path_trigram ON projects USING gin (path gin_trgm_ops); @@ -33128,6 +33420,10 @@ CREATE INDEX index_projects_on_updated_at_and_id ON projects USING btree (update CREATE INDEX index_projects_sync_events_on_project_id ON projects_sync_events USING btree (project_id); +CREATE INDEX index_projects_visits_on_entity_id ON ONLY projects_visits USING btree (entity_id); + +CREATE INDEX index_projects_visits_on_user_id_and_entity_id_and_visited_at ON ONLY projects_visits USING btree (user_id, entity_id, visited_at); + CREATE UNIQUE INDEX index_prometheus_alert_event_scoped_payload_key ON prometheus_alert_events USING btree (prometheus_alert_id, payload_key); CREATE INDEX index_prometheus_alert_events_on_project_id_and_status ON prometheus_alert_events USING btree (project_id, status); @@ -33352,10 +33648,12 @@ CREATE UNIQUE INDEX index_sbom_components_on_component_type_name_and_purl_type O CREATE INDEX index_sbom_occurrences_for_input_file_path_search ON sbom_occurrences USING btree (project_id, component_id, input_file_path); -CREATE INDEX index_sbom_occurrences_on_component_id ON sbom_occurrences USING btree (component_id); +CREATE INDEX index_sbom_occurrences_on_component_id_and_id ON sbom_occurrences USING btree (component_id, id); CREATE INDEX index_sbom_occurrences_on_component_version_id ON sbom_occurrences USING btree (component_version_id); +CREATE INDEX index_sbom_occurrences_on_licenses_spdx_identifier ON sbom_occurrences USING btree (project_id, ((licenses #> '{0,spdx_identifier}'::text[])), ((licenses #> '{1,spdx_identifier}'::text[]))); + CREATE INDEX index_sbom_occurrences_on_pipeline_id ON sbom_occurrences USING btree (pipeline_id); CREATE INDEX index_sbom_occurrences_on_project_id ON sbom_occurrences USING btree (project_id); @@ -33568,8 +33866,6 @@ CREATE UNIQUE INDEX index_subscriptions_on_subscribable_and_user_id_and_project_ CREATE INDEX index_successful_authentication_events_for_metrics ON authentication_events USING btree (user_id, provider, created_at) WHERE (result = 1); -CREATE INDEX index_successful_deployments_on_cluster_id_and_environment_id ON deployments USING btree (cluster_id, environment_id) WHERE (status = 2); - CREATE UNIQUE INDEX index_suggestions_on_note_id_and_relative_order ON suggestions USING btree (note_id, relative_order); CREATE UNIQUE INDEX index_system_access_microsoft_applications_on_namespace_id ON system_access_microsoft_applications USING btree (namespace_id); @@ -33844,6 +34140,8 @@ COMMENT ON INDEX index_verification_codes_on_phone_and_visitor_id_code IS 'JiHu- CREATE UNIQUE INDEX index_vuln_findings_on_uuid_including_vuln_id ON vulnerability_occurrences USING btree (uuid) INCLUDE (vulnerability_id); +CREATE UNIQUE INDEX index_vuln_findings_on_uuid_including_vuln_id_1 ON vulnerability_occurrences USING btree (uuid_convert_string_to_uuid) INCLUDE (vulnerability_id); + CREATE UNIQUE INDEX index_vuln_historical_statistics_on_project_id_and_date ON vulnerability_historical_statistics USING btree (project_id, date); CREATE INDEX index_vuln_reads_common_query_on_resolved_on_default_branch ON vulnerability_reads USING btree (project_id, state, report_type, vulnerability_id DESC) WHERE (resolved_on_default_branch IS TRUE); @@ -33868,6 +34166,8 @@ CREATE INDEX index_vulnerabilities_on_due_date_sourcing_milestone_id ON vulnerab CREATE INDEX index_vulnerabilities_on_epic_id ON vulnerabilities USING btree (epic_id); +CREATE INDEX index_vulnerabilities_on_finding_id ON vulnerabilities USING btree (finding_id); + CREATE INDEX index_vulnerabilities_on_last_edited_by_id ON vulnerabilities USING btree (last_edited_by_id); CREATE INDEX index_vulnerabilities_on_milestone_id ON vulnerabilities USING btree (milestone_id); @@ -33962,6 +34262,8 @@ CREATE INDEX index_vulnerability_occurrences_on_scanner_id ON vulnerability_occu CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid ON vulnerability_occurrences USING btree (uuid); +CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid_1 ON vulnerability_occurrences USING btree (uuid_convert_string_to_uuid); + CREATE INDEX index_vulnerability_occurrences_on_vulnerability_id ON vulnerability_occurrences USING btree (vulnerability_id); CREATE INDEX index_vulnerability_reads_common_finder_query_2 ON vulnerability_reads USING btree (project_id, state, report_type, severity, vulnerability_id DESC, dismissal_reason); @@ -34064,10 +34366,14 @@ CREATE UNIQUE INDEX index_work_item_widget_definitions_on_namespace_type_and_nam CREATE INDEX index_work_item_widget_definitions_on_work_item_type_id ON work_item_widget_definitions USING btree (work_item_type_id); +CREATE INDEX index_workspace_variables_on_workspace_id ON workspace_variables USING btree (workspace_id); + CREATE INDEX index_workspaces_on_cluster_agent_id ON workspaces USING btree (cluster_agent_id); CREATE UNIQUE INDEX index_workspaces_on_name ON workspaces USING btree (name); +CREATE INDEX index_workspaces_on_personal_access_token_id ON workspaces USING btree (personal_access_token_id); + CREATE INDEX index_workspaces_on_project_id ON workspaces USING btree (project_id); CREATE INDEX index_workspaces_on_user_id ON workspaces USING btree (user_id); @@ -34132,6 +34438,8 @@ CREATE INDEX packages_packages_needs_verification ON packages_package_files USIN CREATE INDEX packages_packages_pending_verification ON packages_package_files USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0); +CREATE INDEX pages_deployments_deleted_at_index ON pages_deployments USING btree (id, project_id, path_prefix) WHERE (deleted_at IS NULL); + CREATE UNIQUE INDEX partial_index_bulk_import_exports_on_group_id_and_relation ON bulk_import_exports USING btree (group_id, relation) WHERE (group_id IS NOT NULL); CREATE UNIQUE INDEX partial_index_bulk_import_exports_on_project_id_and_relation ON bulk_import_exports USING btree (project_id, relation) WHERE (project_id IS NOT NULL); @@ -34192,8 +34500,6 @@ CREATE INDEX tmp_idx_orphaned_approval_project_rules ON approval_project_rules U CREATE INDEX tmp_idx_packages_on_project_id_when_npm_not_pending_destruction ON packages_packages USING btree (project_id) WHERE ((package_type = 2) AND (status <> 4)); -CREATE INDEX tmp_idx_vuln_reads_where_dismissal_reason_null ON vulnerability_reads USING btree (id) WHERE ((state = 2) AND (dismissal_reason IS NULL)); - CREATE INDEX tmp_idx_vulns_on_converted_uuid ON vulnerability_occurrences USING btree (id, uuid_convert_string_to_uuid) WHERE (uuid_convert_string_to_uuid = '00000000-0000-0000-0000-000000000000'::uuid); CREATE INDEX tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown ON ci_job_artifacts USING btree (expire_at, job_id) WHERE ((locked = 2) AND (expire_at IS NOT NULL)); @@ -34212,6 +34518,8 @@ CREATE INDEX tmp_index_project_statistics_cont_registry_size ON project_statisti CREATE INDEX tmp_index_project_statistics_pipeline_artifacts_size ON project_statistics USING btree (project_id) WHERE (pipeline_artifacts_size <> 0); +CREATE INDEX tmp_index_project_statistics_updated_at ON project_statistics USING btree (project_id, updated_at) WHERE (repository_size > 0); + CREATE INDEX tmp_index_vulnerability_dismissal_info ON vulnerabilities USING btree (id) WHERE ((state = 2) AND ((dismissed_at IS NULL) OR (dismissed_by_id IS NULL))); CREATE INDEX tmp_index_vulnerability_overlong_title_html ON vulnerabilities USING btree (id) WHERE (length(title_html) > 800); @@ -34240,6 +34548,10 @@ CREATE UNIQUE INDEX uniq_pkgs_debian_project_distributions_project_id_and_codena CREATE UNIQUE INDEX uniq_pkgs_debian_project_distributions_project_id_and_suite ON packages_debian_project_distributions USING btree (project_id, suite); +CREATE UNIQUE INDEX unique_amazon_s3_configurations_namespace_id_and_bucket_name ON audit_events_amazon_s3_configurations USING btree (namespace_id, bucket_name); + +CREATE UNIQUE INDEX unique_amazon_s3_configurations_namespace_id_and_name ON audit_events_amazon_s3_configurations USING btree (namespace_id, name); + CREATE UNIQUE INDEX unique_ci_builds_token_encrypted_and_partition_id ON ci_builds USING btree (token_encrypted, partition_id) WHERE (token_encrypted IS NOT NULL); CREATE UNIQUE INDEX unique_external_audit_event_destination_namespace_id_and_name ON audit_events_external_audit_event_destinations USING btree (namespace_id, name); @@ -34258,6 +34570,10 @@ CREATE UNIQUE INDEX unique_index_sysaccess_ms_access_tokens_on_sysaccess_ms_app_ CREATE UNIQUE INDEX unique_instance_audit_event_destination_name ON audit_events_instance_external_audit_event_destinations USING btree (name); +CREATE UNIQUE INDEX unique_instance_google_cloud_logging_configurations ON audit_events_instance_google_cloud_logging_configurations USING btree (google_project_id_name, log_id_name); + +CREATE UNIQUE INDEX unique_instance_google_cloud_logging_configurations_name ON audit_events_instance_google_cloud_logging_configurations USING btree (name); + CREATE UNIQUE INDEX unique_merge_request_diff_llm_summaries_on_mr_diff_id ON merge_request_diff_llm_summaries USING btree (merge_request_diff_id); CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_request_metrics USING btree (merge_request_id); @@ -35930,8 +36246,12 @@ CREATE TRIGGER trigger_7f3d66a7d7f5 BEFORE INSERT OR UPDATE ON ci_pipeline_varia CREATE TRIGGER trigger_b2d852e1e2cb BEFORE INSERT OR UPDATE ON ci_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_b2d852e1e2cb(); +CREATE TRIGGER trigger_bbb95b2d6929 BEFORE INSERT OR UPDATE ON ci_project_monthly_usages FOR EACH ROW EXECUTE FUNCTION trigger_bbb95b2d6929(); + CREATE TRIGGER trigger_bfad0e2b9c86 BEFORE INSERT OR UPDATE ON ci_pipeline_messages FOR EACH ROW EXECUTE FUNCTION trigger_bfad0e2b9c86(); +CREATE TRIGGER trigger_c0353bbb6145 BEFORE INSERT OR UPDATE ON ci_namespace_monthly_usages FOR EACH ROW EXECUTE FUNCTION trigger_c0353bbb6145(); + CREATE TRIGGER trigger_delete_project_namespace_on_project_delete AFTER DELETE ON projects FOR EACH ROW WHEN ((old.project_namespace_id IS NOT NULL)) EXECUTE FUNCTION delete_associated_project_namespace(); CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON integrations FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_issue_tracker(); @@ -36022,6 +36342,9 @@ ALTER TABLE ONLY user_interacted_projects ALTER TABLE ONLY merge_request_assignment_events ADD CONSTRAINT fk_08f7602bfd FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; +ALTER TABLE ONLY ci_pipeline_messages + ADD CONSTRAINT fk_0946fea681 FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY remote_development_agent_configs ADD CONSTRAINT fk_0a3c0ada56 FOREIGN KEY (cluster_agent_id) REFERENCES cluster_agents(id) ON DELETE CASCADE; @@ -36037,9 +36360,6 @@ ALTER TABLE ONLY ssh_signatures ALTER TABLE ONLY web_hooks ADD CONSTRAINT fk_0c8ca6d9d1 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY notification_settings - ADD CONSTRAINT fk_0c95e91db7 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; - ALTER TABLE ONLY lists ADD CONSTRAINT fk_0d3f677137 FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE; @@ -36094,6 +36414,9 @@ ALTER TABLE ONLY ci_pipelines ALTER TABLE ONLY analytics_devops_adoption_segments ADD CONSTRAINT fk_190a24754d FOREIGN KEY (display_namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; +ALTER TABLE ONLY project_statistics + ADD CONSTRAINT fk_198ad46fdc FOREIGN KEY (root_namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL; + ALTER TABLE ONLY agent_project_authorizations ADD CONSTRAINT fk_1d30bb4987 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -36172,9 +36495,6 @@ ALTER TABLE ONLY deployment_approvals ALTER TABLE ONLY notes ADD CONSTRAINT fk_2e82291620 FOREIGN KEY (review_id) REFERENCES reviews(id) ON DELETE SET NULL; -ALTER TABLE ONLY members - ADD CONSTRAINT fk_2e88fb7ce9 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; - ALTER TABLE ONLY lfs_objects_projects ADD CONSTRAINT fk_2eb33f7a78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE NOT VALID; @@ -36298,6 +36618,9 @@ ALTER TABLE ONLY sbom_occurrences ALTER TABLE ONLY namespace_commit_emails ADD CONSTRAINT fk_4d6ba63ba5 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; +ALTER TABLE ONLY vulnerabilities + ADD CONSTRAINT fk_4e64972902 FOREIGN KEY (finding_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY ml_model_versions ADD CONSTRAINT fk_4e8b59e7a8 FOREIGN KEY (model_id) REFERENCES ml_models(id) ON DELETE CASCADE; @@ -36343,6 +36666,9 @@ ALTER TABLE ONLY approval_merge_request_rules ALTER TABLE ONLY deploy_keys_projects ADD CONSTRAINT fk_58a901ca7e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY ci_pipeline_chat_data + ADD CONSTRAINT fk_5b21bde562 FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE; + ALTER TABLE ONLY dependency_list_exports ADD CONSTRAINT fk_5b3d11e1ef FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL; @@ -36748,9 +37074,6 @@ ALTER TABLE ONLY deployments ALTER TABLE ONLY project_compliance_standards_adherence ADD CONSTRAINT fk_baf6f6f878 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY routes - ADD CONSTRAINT fk_bb2e5b8968 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE p_ci_runner_machine_builds ADD CONSTRAINT fk_bb490f12fe_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE; @@ -36979,6 +37302,9 @@ ALTER TABLE ONLY pages_domains ALTER TABLE ONLY catalog_resource_components ADD CONSTRAINT fk_ec417536da FOREIGN KEY (catalog_resource_id) REFERENCES catalog_resources(id) ON DELETE CASCADE; +ALTER TABLE ONLY workspaces + ADD CONSTRAINT fk_ec70695b2c FOREIGN KEY (personal_access_token_id) REFERENCES personal_access_tokens(id) ON DELETE RESTRICT; + ALTER TABLE ONLY merge_requests_compliance_violations ADD CONSTRAINT fk_ec881c1c6f FOREIGN KEY (violating_user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -37645,6 +37971,9 @@ ALTER TABLE ONLY elastic_group_index_statuses ALTER TABLE ONLY bulk_import_configurations ADD CONSTRAINT fk_rails_536b96bff1 FOREIGN KEY (bulk_import_id) REFERENCES bulk_imports(id) ON DELETE CASCADE; +ALTER TABLE ONLY workspace_variables + ADD CONSTRAINT fk_rails_539844891e FOREIGN KEY (workspace_id) REFERENCES workspaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY x509_commit_signatures ADD CONSTRAINT fk_rails_53fe41188f FOREIGN KEY (x509_certificate_id) REFERENCES x509_certificates(id) ON DELETE CASCADE; @@ -37717,6 +38046,9 @@ ALTER TABLE ONLY ci_running_builds ALTER TABLE ONLY epic_issues ADD CONSTRAINT fk_rails_5d942936b4 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE CASCADE; +ALTER TABLE ONLY packages_nuget_symbols + ADD CONSTRAINT fk_rails_5df972da14 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE SET NULL; + ALTER TABLE ONLY resource_weight_events ADD CONSTRAINT fk_rails_5eb5cb92a1 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; @@ -37975,6 +38307,9 @@ ALTER TABLE ONLY security_trainings ALTER TABLE ONLY zentao_tracker_data ADD CONSTRAINT fk_rails_84efda7be0 FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE; +ALTER TABLE ONLY audit_events_amazon_s3_configurations + ADD CONSTRAINT fk_rails_84f4b10a16 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY boards_epic_user_preferences ADD CONSTRAINT fk_rails_851fe1510a FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -38638,6 +38973,9 @@ ALTER TABLE ONLY clusters_integration_prometheus ALTER TABLE ONLY vulnerability_occurrence_identifiers ADD CONSTRAINT fk_rails_e4ef6d027c FOREIGN KEY (occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE; +ALTER TABLE ONLY packages_protection_rules + ADD CONSTRAINT fk_rails_e52adb5267 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; + ALTER TABLE ONLY vulnerability_flags ADD CONSTRAINT fk_rails_e59393b48b FOREIGN KEY (vulnerability_occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE; @@ -38855,7 +39193,7 @@ ALTER TABLE product_analytics_events_experimental ADD CONSTRAINT product_analytics_events_experimental_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ALTER TABLE ONLY ci_pipeline_variables - ADD CONSTRAINT temp_fk_rails_8d3b04e3e1 FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE NOT VALID; + ADD CONSTRAINT temp_fk_rails_8d3b04e3e1 FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE; ALTER TABLE ONLY user_follow_users ADD CONSTRAINT user_follow_users_followee_id_fkey FOREIGN KEY (followee_id) REFERENCES users(id) ON DELETE CASCADE; |