From ee664acb356f8123f4f6b00b73c1e1cf0866c7fb Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 20 Oct 2022 09:40:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-5-stable-ee --- ...1624_add_scan_file_path_to_dast_site_profile.rb | 14 ++++++ ..._user_preference_to_turn_off_automatic_lists.rb | 13 +++++ ...220802200719_add_user_details_profile_fields.rb | 17 +++++++ ...20220802202505_add_user_details_field_limits.rb | 25 ++++++++++ ...unique_index_on_sbom_component_type_and_name.rb | 15 ++++++ ...mponent_versions_on_component_id_and_version.rb | 15 ++++++ ...ex_to_sbom_sources_on_source_type_and_source.rb | 15 ++++++ ...tsu_tracking_columns_to_application_settings.rb | 15 ++++++ ..._columns_to_application_settings_text_limits.rb | 19 +++++++ ..._to_sbom_occurrences_on_ingestion_attributes.rb | 22 ++++++++ ..._add_dashboard_limit_to_application_settings.rb | 11 ++++ ...add_can_create_group_to_application_settings.rb | 7 +++ ..._update_can_create_group_application_setting.rb | 26 ++++++++++ ...only_allow_merge_if_all_status_checks_passed.rb | 7 +++ ...curity_orchestration_policy_configuration_id.rb | 58 ++++++++++++++++++++++ ...12153839_create_packages_rpm_repository_file.rb | 25 ++++++++++ ...3043728_create_user_phone_number_validations.rb | 29 +++++++++++ ...082824_finalize_invalid_group_member_cleanup.rb | 19 +++++++ ...084123_add_timestamp_to_ml_candidate_metrics.rb | 7 +++ ...0927_finalize_invalid_project_member_cleanup.rb | 19 +++++++ ...candidate_id_and_name_on_ml_candidate_params.rb | 15 ++++++ ...457_add_reject_non_dco_commits_to_push_rules.rb | 7 +++ .../20220914130800_add_jitsu_key_to_projects.rb | 20 ++++++++ ...4131449_add_text_limit_to_projects_jitsu_key.rb | 13 +++++ ...null_constraint_from_sbom_source_fingerprint.rb | 9 ++++ ...094641_add_source_id_to_bulk_import_entities.rb | 7 +++ ...x_on_jira_connect_installations_instance_url.rb | 15 ++++++ ...gested_reviewers_enabled_to_project_settings.rb | 9 ++++ ..._on_project_id_and_lower_version_to_packages.rb | 21 ++++++++ ..._remove_temp_index_null_project_namespace_id.rb | 15 ++++++ .../20220921174815_add_secure_files_metadata.rb | 8 +++ ...sts_forwarding_to_namespace_package_settings.rb | 28 +++++++++++ ...add_inbound_ci_job_token_project_scope_links.rb | 13 +++++ ...0220923103006_add_ci_pipeline_metadata_title.rb | 27 ++++++++++ ...und_job_token_scope_enabled_to_ci_cd_setting.rb | 13 +++++ ...201920_create_project_wiki_repository_states.rb | 44 ++++++++++++++++ ...sts_forwarding_to_namespace_package_settings.rb | 28 +++++++++++ ...sts_forwarding_to_namespace_package_settings.rb | 28 +++++++++++ ...o_state_transition_to_vulnerability_feedback.rb | 7 +++ ...eate_incident_management_timeline_event_tags.rb | 19 +++++++ ...incident_management_timeline_event_tag_links.rb | 33 ++++++++++++ ...ct_id_on_scan_finding_approval_project_rules.rb | 22 ++++++++ ..._over_limit_notified_at_to_namespace_details.rb | 20 ++++++++ ...1145_add_targets_to_elastic_reindexing_tasks.rb | 7 +++ ...1008032350_add_password_expiration_migration.rb | 12 +++++ ..._add_mr_checks_columns_to_namespace_settings.rb | 10 ++++ ...agement_settings_on_project_id_and_sla_timer.rb | 17 +++++++ ...5_add_use_legacy_web_ide_to_user_preferences.rb | 9 ++++ ...add_password_last_changed_at_to_user_details.rb | 9 ++++ ...d_scan_file_path_limit_for_dast_site_profile.rb | 13 +++++ ...es_where_releases_access_level_gt_repository.rb | 19 +++++++ ...pulate_releases_access_level_from_repository.rb | 21 ++++++++ ...20221014190040_drop_notes_note_trigram_index.rb | 17 +++++++ ...move_member_namespace_id_not_null_constraint.rb | 15 ++++++ 54 files changed, 948 insertions(+) create mode 100644 db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb create mode 100644 db/migrate/20220615172230_add_user_preference_to_turn_off_automatic_lists.rb create mode 100644 db/migrate/20220802200719_add_user_details_profile_fields.rb create mode 100644 db/migrate/20220802202505_add_user_details_field_limits.rb create mode 100644 db/migrate/20220805180311_add_unique_index_on_sbom_component_type_and_name.rb create mode 100644 db/migrate/20220805183952_add_unique_index_to_sbom_component_versions_on_component_id_and_version.rb create mode 100644 db/migrate/20220805193117_add_unique_index_to_sbom_sources_on_source_type_and_source.rb create mode 100644 db/migrate/20220818125332_add_jitsu_tracking_columns_to_application_settings.rb create mode 100644 db/migrate/20220818125703_add_jitsu_tracking_columns_to_application_settings_text_limits.rb create mode 100644 db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb create mode 100644 db/migrate/20220819184945_add_dashboard_limit_to_application_settings.rb create mode 100644 db/migrate/20220901090004_add_can_create_group_to_application_settings.rb create mode 100644 db/migrate/20220901092853_update_can_create_group_application_setting.rb create mode 100644 db/migrate/20220901114501_only_allow_merge_if_all_status_checks_passed.rb create mode 100644 db/migrate/20220907115806_add_security_orchestration_policy_configuration_id.rb create mode 100644 db/migrate/20220912153839_create_packages_rpm_repository_file.rb create mode 100644 db/migrate/20220913043728_create_user_phone_number_validations.rb create mode 100644 db/migrate/20220913082824_finalize_invalid_group_member_cleanup.rb create mode 100644 db/migrate/20220913084123_add_timestamp_to_ml_candidate_metrics.rb create mode 100644 db/migrate/20220914070927_finalize_invalid_project_member_cleanup.rb create mode 100644 db/migrate/20220914080716_add_index_to_candidate_id_and_name_on_ml_candidate_params.rb create mode 100644 db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb create mode 100644 db/migrate/20220914130800_add_jitsu_key_to_projects.rb create mode 100644 db/migrate/20220914131449_add_text_limit_to_projects_jitsu_key.rb create mode 100644 db/migrate/20220914174705_remove_not_null_constraint_from_sbom_source_fingerprint.rb create mode 100644 db/migrate/20220916094641_add_source_id_to_bulk_import_entities.rb create mode 100644 db/migrate/20220916103311_add_index_on_jira_connect_installations_instance_url.rb create mode 100644 db/migrate/20220918124223_add_suggested_reviewers_enabled_to_project_settings.rb create mode 100644 db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb create mode 100644 db/migrate/20220920022404_remove_temp_index_null_project_namespace_id.rb create mode 100644 db/migrate/20220921174815_add_secure_files_metadata.rb create mode 100644 db/migrate/20220921201347_add_maven_package_requests_forwarding_to_namespace_package_settings.rb create mode 100644 db/migrate/20220922143612_add_inbound_ci_job_token_project_scope_links.rb create mode 100644 db/migrate/20220923103006_add_ci_pipeline_metadata_title.rb create mode 100644 db/migrate/20220927155407_add_column_inbound_job_token_scope_enabled_to_ci_cd_setting.rb create mode 100644 db/migrate/20220928201920_create_project_wiki_repository_states.rb create mode 100644 db/migrate/20220929171925_add_pypi_package_requests_forwarding_to_namespace_package_settings.rb create mode 100644 db/migrate/20220929172356_add_npm_package_requests_forwarding_to_namespace_package_settings.rb create mode 100644 db/migrate/20220930125609_add_migrated_to_state_transition_to_vulnerability_feedback.rb create mode 100644 db/migrate/20221005072353_create_incident_management_timeline_event_tags.rb create mode 100644 db/migrate/20221005094926_create_incident_management_timeline_event_tag_links.rb create mode 100644 db/migrate/20221005103010_add_index_project_id_on_scan_finding_approval_project_rules.rb create mode 100644 db/migrate/20221006131506_add_free_user_cap_over_limit_notified_at_to_namespace_details.rb create mode 100644 db/migrate/20221006141145_add_targets_to_elastic_reindexing_tasks.rb create mode 100644 db/migrate/20221008032350_add_password_expiration_migration.rb create mode 100644 db/migrate/20221009085130_add_mr_checks_columns_to_namespace_settings.rb create mode 100644 db/migrate/20221011162637_add_partial_index_project_incident_management_settings_on_project_id_and_sla_timer.rb create mode 100644 db/migrate/20221011210455_add_use_legacy_web_ide_to_user_preferences.rb create mode 100644 db/migrate/20221012033107_add_password_last_changed_at_to_user_details.rb create mode 100644 db/migrate/20221012135524_add_scan_file_path_limit_for_dast_site_profile.rb create mode 100644 db/migrate/20221014031033_add_temp_index_to_project_features_where_releases_access_level_gt_repository.rb create mode 100644 db/migrate/20221014034338_populate_releases_access_level_from_repository.rb create mode 100644 db/migrate/20221014190040_drop_notes_note_trigram_index.rb create mode 100644 db/migrate/20221018081416_members_remove_member_namespace_id_not_null_constraint.rb (limited to 'db/migrate') diff --git a/db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb b/db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb new file mode 100644 index 00000000000..eab02663e26 --- /dev/null +++ b/db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class AddScanFilePathToDastSiteProfile < Gitlab::Database::Migration[2.0] + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20221012135524_add_scan_file_path_limit_for_dast_site_profile + def up + add_column :dast_site_profiles, :scan_file_path, :text + end + # rubocop:enable Migration/AddLimitToTextColumns + + def down + remove_column :dast_site_profiles, :scan_file_path, :text + end +end diff --git a/db/migrate/20220615172230_add_user_preference_to_turn_off_automatic_lists.rb b/db/migrate/20220615172230_add_user_preference_to_turn_off_automatic_lists.rb new file mode 100644 index 00000000000..4a0255aad06 --- /dev/null +++ b/db/migrate/20220615172230_add_user_preference_to_turn_off_automatic_lists.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddUserPreferenceToTurnOffAutomaticLists < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + add_column :user_preferences, :markdown_automatic_lists, :boolean, default: true, null: false + end + + def down + remove_column :user_preferences, :markdown_automatic_lists, :boolean + end +end diff --git a/db/migrate/20220802200719_add_user_details_profile_fields.rb b/db/migrate/20220802200719_add_user_details_profile_fields.rb new file mode 100644 index 00000000000..952b0bc1d9a --- /dev/null +++ b/db/migrate/20220802200719_add_user_details_profile_fields.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddUserDetailsProfileFields < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + # rubocop:disable Migration/AddLimitToTextColumns + # limits are added in 20220802202505_add_user_details_field_limits + def change + add_column :user_details, :linkedin, :text, null: false, default: '' + add_column :user_details, :twitter, :text, null: false, default: '' + add_column :user_details, :skype, :text, null: false, default: '' + add_column :user_details, :website_url, :text, null: false, default: '' + add_column :user_details, :location, :text, null: false, default: '' + add_column :user_details, :organization, :text, null: false, default: '' + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20220802202505_add_user_details_field_limits.rb b/db/migrate/20220802202505_add_user_details_field_limits.rb new file mode 100644 index 00000000000..83b6a4528d3 --- /dev/null +++ b/db/migrate/20220802202505_add_user_details_field_limits.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddUserDetailsFieldLimits < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + USER_DETAILS_FIELD_LIMIT = 500 + + def up + add_text_limit :user_details, :linkedin, USER_DETAILS_FIELD_LIMIT + add_text_limit :user_details, :twitter, USER_DETAILS_FIELD_LIMIT + add_text_limit :user_details, :skype, USER_DETAILS_FIELD_LIMIT + add_text_limit :user_details, :website_url, USER_DETAILS_FIELD_LIMIT + add_text_limit :user_details, :location, USER_DETAILS_FIELD_LIMIT + add_text_limit :user_details, :organization, USER_DETAILS_FIELD_LIMIT + end + + def down + remove_text_limit :user_details, :linkedin + remove_text_limit :user_details, :twitter + remove_text_limit :user_details, :skype + remove_text_limit :user_details, :website_url + remove_text_limit :user_details, :location + remove_text_limit :user_details, :organization + end +end diff --git a/db/migrate/20220805180311_add_unique_index_on_sbom_component_type_and_name.rb b/db/migrate/20220805180311_add_unique_index_on_sbom_component_type_and_name.rb new file mode 100644 index 00000000000..852b1283e92 --- /dev/null +++ b/db/migrate/20220805180311_add_unique_index_on_sbom_component_type_and_name.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddUniqueIndexOnSbomComponentTypeAndName < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_sbom_components_on_component_type_and_name' + + disable_ddl_transaction! + + def up + add_concurrent_index :sbom_components, [:component_type, :name], unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :sbom_components, name: INDEX_NAME + end +end diff --git a/db/migrate/20220805183952_add_unique_index_to_sbom_component_versions_on_component_id_and_version.rb b/db/migrate/20220805183952_add_unique_index_to_sbom_component_versions_on_component_id_and_version.rb new file mode 100644 index 00000000000..03023bc6f2c --- /dev/null +++ b/db/migrate/20220805183952_add_unique_index_to_sbom_component_versions_on_component_id_and_version.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddUniqueIndexToSbomComponentVersionsOnComponentIdAndVersion < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_sbom_component_versions_on_component_id_and_version' + + disable_ddl_transaction! + + def up + add_concurrent_index :sbom_component_versions, [:component_id, :version], unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :sbom_component_versions, name: INDEX_NAME + end +end diff --git a/db/migrate/20220805193117_add_unique_index_to_sbom_sources_on_source_type_and_source.rb b/db/migrate/20220805193117_add_unique_index_to_sbom_sources_on_source_type_and_source.rb new file mode 100644 index 00000000000..973cacaec5b --- /dev/null +++ b/db/migrate/20220805193117_add_unique_index_to_sbom_sources_on_source_type_and_source.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddUniqueIndexToSbomSourcesOnSourceTypeAndSource < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_sbom_sources_on_source_type_and_source' + + disable_ddl_transaction! + + def up + add_concurrent_index :sbom_sources, [:source_type, :source], unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :sbom_sources, name: INDEX_NAME + end +end diff --git a/db/migrate/20220818125332_add_jitsu_tracking_columns_to_application_settings.rb b/db/migrate/20220818125332_add_jitsu_tracking_columns_to_application_settings.rb new file mode 100644 index 00000000000..9013168c2c5 --- /dev/null +++ b/db/migrate/20220818125332_add_jitsu_tracking_columns_to_application_settings.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddJitsuTrackingColumnsToApplicationSettings < Gitlab::Database::Migration[2.0] + def change + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20220818125703_add_jitsu_tracking_columns_to_application_settings_text_limits.rb + add_column :application_settings, :jitsu_host, :text + add_column :application_settings, :jitsu_project_xid, :text + add_column :application_settings, :clickhouse_connection_string, :text + add_column :application_settings, :jitsu_administrator_email, :text + add_column :application_settings, :encrypted_jitsu_administrator_password, :binary + add_column :application_settings, :encrypted_jitsu_administrator_password_iv, :binary + # rubocop:enable Migration/AddLimitToTextColumns + end +end diff --git a/db/migrate/20220818125703_add_jitsu_tracking_columns_to_application_settings_text_limits.rb b/db/migrate/20220818125703_add_jitsu_tracking_columns_to_application_settings_text_limits.rb new file mode 100644 index 00000000000..41de6e34724 --- /dev/null +++ b/db/migrate/20220818125703_add_jitsu_tracking_columns_to_application_settings_text_limits.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddJitsuTrackingColumnsToApplicationSettingsTextLimits < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_text_limit :application_settings, :jitsu_host, 255 + add_text_limit :application_settings, :jitsu_project_xid, 255 + add_text_limit :application_settings, :clickhouse_connection_string, 1024 + add_text_limit :application_settings, :jitsu_administrator_email, 255 + end + + def down + remove_text_limit :application_settings, :jitsu_host + remove_text_limit :application_settings, :jitsu_project_xid + remove_text_limit :application_settings, :clickhouse_connection_string + remove_text_limit :application_settings, :jitsu_administrator_email + end +end diff --git a/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb b/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb new file mode 100644 index 00000000000..2538017e287 --- /dev/null +++ b/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddUniqueIndexToSbomOccurrencesOnIngestionAttributes < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_sbom_occurrences_on_ingestion_attributes' + ATTRIBUTES = %i[ + project_id + component_id + component_version_id + source_id + commit_sha + ].freeze + + disable_ddl_transaction! + + def up + add_concurrent_index :sbom_occurrences, ATTRIBUTES, unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :sbom_occurrences, name: INDEX_NAME + end +end diff --git a/db/migrate/20220819184945_add_dashboard_limit_to_application_settings.rb b/db/migrate/20220819184945_add_dashboard_limit_to_application_settings.rb new file mode 100644 index 00000000000..f2ab4a043ea --- /dev/null +++ b/db/migrate/20220819184945_add_dashboard_limit_to_application_settings.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddDashboardLimitToApplicationSettings < Gitlab::Database::Migration[2.0] + def change + add_column :application_settings, :dashboard_limit_enabled, :boolean, default: false, null: false + add_column :application_settings, :dashboard_limit, :integer, default: 0, null: false + add_column :application_settings, :dashboard_notification_limit, :integer, default: 0, null: false + add_column :application_settings, :dashboard_enforcement_limit, :integer, default: 0, null: false + add_column :application_settings, :dashboard_limit_new_namespace_creation_enforcement_date, :date + end +end diff --git a/db/migrate/20220901090004_add_can_create_group_to_application_settings.rb b/db/migrate/20220901090004_add_can_create_group_to_application_settings.rb new file mode 100644 index 00000000000..a61f7c9a080 --- /dev/null +++ b/db/migrate/20220901090004_add_can_create_group_to_application_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddCanCreateGroupToApplicationSettings < Gitlab::Database::Migration[2.0] + def change + add_column(:application_settings, :can_create_group, :boolean, default: true, null: false) + end +end diff --git a/db/migrate/20220901092853_update_can_create_group_application_setting.rb b/db/migrate/20220901092853_update_can_create_group_application_setting.rb new file mode 100644 index 00000000000..42508184d62 --- /dev/null +++ b/db/migrate/20220901092853_update_can_create_group_application_setting.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class UpdateCanCreateGroupApplicationSetting < Gitlab::Database::Migration[2.0] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + value = gitlab_config.respond_to?(:default_can_create_group) ? gitlab_config.default_can_create_group : true + value = Gitlab::Utils.to_boolean(value, default: true) + + execute_update(value: value) + end + + def down + execute_update(value: true) + end + + private + + def execute_update(value:) + execute "UPDATE application_settings SET can_create_group = #{value}" + end + + def gitlab_config + Gitlab.config.gitlab + end +end diff --git a/db/migrate/20220901114501_only_allow_merge_if_all_status_checks_passed.rb b/db/migrate/20220901114501_only_allow_merge_if_all_status_checks_passed.rb new file mode 100644 index 00000000000..059ed657264 --- /dev/null +++ b/db/migrate/20220901114501_only_allow_merge_if_all_status_checks_passed.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class OnlyAllowMergeIfAllStatusChecksPassed < Gitlab::Database::Migration[2.0] + def change + add_column :project_settings, :only_allow_merge_if_all_status_checks_passed, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20220907115806_add_security_orchestration_policy_configuration_id.rb b/db/migrate/20220907115806_add_security_orchestration_policy_configuration_id.rb new file mode 100644 index 00000000000..de83288a0ca --- /dev/null +++ b/db/migrate/20220907115806_add_security_orchestration_policy_configuration_id.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +class AddSecurityOrchestrationPolicyConfigurationId < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + PROJECT_INDEX_NAME = 'idx_approval_project_rules_on_sec_orchestration_config_id' + MERGE_REQUEST_INDEX_NAME = 'idx_approval_merge_request_rules_on_sec_orchestration_config_id' + + def up + with_lock_retries do + unless column_exists?(:approval_project_rules, :security_orchestration_policy_configuration_id) + add_column :approval_project_rules, :security_orchestration_policy_configuration_id, :bigint + end + end + + with_lock_retries do + unless column_exists?(:approval_merge_request_rules, :security_orchestration_policy_configuration_id) + add_column :approval_merge_request_rules, :security_orchestration_policy_configuration_id, :bigint + end + end + + add_concurrent_index :approval_project_rules, + :security_orchestration_policy_configuration_id, + name: PROJECT_INDEX_NAME + add_concurrent_index :approval_merge_request_rules, + :security_orchestration_policy_configuration_id, + name: MERGE_REQUEST_INDEX_NAME + + add_concurrent_foreign_key :approval_project_rules, + :security_orchestration_policy_configurations, + column: :security_orchestration_policy_configuration_id, + on_delete: :cascade + add_concurrent_foreign_key :approval_merge_request_rules, + :security_orchestration_policy_configurations, + column: :security_orchestration_policy_configuration_id, + on_delete: :cascade + end + + def down + with_lock_retries do + if column_exists?(:approval_project_rules, :security_orchestration_policy_configuration_id) + remove_column :approval_project_rules, :security_orchestration_policy_configuration_id + end + end + + with_lock_retries do + if column_exists?(:approval_merge_request_rules, :security_orchestration_policy_configuration_id) + remove_column :approval_merge_request_rules, :security_orchestration_policy_configuration_id + end + end + + remove_foreign_key_if_exists :approval_project_rules, column: :security_orchestration_policy_configuration_id + remove_foreign_key_if_exists :approval_merge_request_rules, column: :security_orchestration_policy_configuration_id + + remove_concurrent_index_by_name :approval_project_rules, name: PROJECT_INDEX_NAME + remove_concurrent_index_by_name :approval_merge_request_rules, name: MERGE_REQUEST_INDEX_NAME + end +end diff --git a/db/migrate/20220912153839_create_packages_rpm_repository_file.rb b/db/migrate/20220912153839_create_packages_rpm_repository_file.rb new file mode 100644 index 00000000000..889720df233 --- /dev/null +++ b/db/migrate/20220912153839_create_packages_rpm_repository_file.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class CreatePackagesRpmRepositoryFile < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + create_table :packages_rpm_repository_files do |t| + t.timestamps_with_timezone + + t.references :project, index: true, null: false, foreign_key: { on_delete: :cascade }, type: :bigint + t.integer :file_store, default: 1 + t.integer :status, default: 0, null: false, limit: 2 + t.integer :size + t.binary :file_md5 + t.binary :file_sha1 + t.binary :file_sha256 + t.text :file, null: false, limit: 255 + t.text :file_name, null: false, limit: 255 + end + end + + def down + drop_table :packages_rpm_repository_files + end +end diff --git a/db/migrate/20220913043728_create_user_phone_number_validations.rb b/db/migrate/20220913043728_create_user_phone_number_validations.rb new file mode 100644 index 00000000000..21a5b4d5519 --- /dev/null +++ b/db/migrate/20220913043728_create_user_phone_number_validations.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CreateUserPhoneNumberValidations < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + create_table :user_phone_number_validations, id: false do |t| + t.references :user, primary_key: true, default: nil, type: :bigint, index: false, + foreign_key: { on_delete: :cascade } + + t.datetime_with_timezone :validated_at + t.timestamps_with_timezone null: false + + t.integer :international_dial_code, null: false, limit: 1 + t.integer :verification_attempts, null: false, default: 0, limit: 1 + t.integer :risk_score, null: false, default: 0, limit: 1 + + t.text :country, null: false, limit: 3 + t.text :phone_number, null: false, limit: 12 + t.text :telesign_reference_xid, limit: 255 + + t.index [:international_dial_code, :phone_number], name: :index_user_phone_validations_on_dial_code_phone_number + end + end + + def down + drop_table :user_phone_number_validations + end +end diff --git a/db/migrate/20220913082824_finalize_invalid_group_member_cleanup.rb b/db/migrate/20220913082824_finalize_invalid_group_member_cleanup.rb new file mode 100644 index 00000000000..d5fb04f3fa3 --- /dev/null +++ b/db/migrate/20220913082824_finalize_invalid_group_member_cleanup.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class FinalizeInvalidGroupMemberCleanup < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + # noop: this fails because the cleanup invalid members migration(ScheduleDestroyInvalidGroupMembers) + # cannot succeed, so we need to cleanup that first. + # + # issue with some details: https://gitlab.com/gitlab-org/gitlab/-/issues/365028#note_1107166816 + # # incident: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7779 + end + + def down + # noop + end +end diff --git a/db/migrate/20220913084123_add_timestamp_to_ml_candidate_metrics.rb b/db/migrate/20220913084123_add_timestamp_to_ml_candidate_metrics.rb new file mode 100644 index 00000000000..293bca2d6d7 --- /dev/null +++ b/db/migrate/20220913084123_add_timestamp_to_ml_candidate_metrics.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddTimestampToMlCandidateMetrics < Gitlab::Database::Migration[2.0] + def change + add_column :ml_candidate_metrics, :tracked_at, :bigint + end +end diff --git a/db/migrate/20220914070927_finalize_invalid_project_member_cleanup.rb b/db/migrate/20220914070927_finalize_invalid_project_member_cleanup.rb new file mode 100644 index 00000000000..30f6519ed0f --- /dev/null +++ b/db/migrate/20220914070927_finalize_invalid_project_member_cleanup.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class FinalizeInvalidProjectMemberCleanup < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + # noop: this fails because the cleanup invalid members migration(ScheduleDestroyInvalidProjectMembers) + # cannot succeed, so we need to cleanup that first. + # + # issue with some details: https://gitlab.com/gitlab-org/gitlab/-/issues/365028#note_1107166816 + # # incident: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7779 + end + + def down + # noop + end +end diff --git a/db/migrate/20220914080716_add_index_to_candidate_id_and_name_on_ml_candidate_params.rb b/db/migrate/20220914080716_add_index_to_candidate_id_and_name_on_ml_candidate_params.rb new file mode 100644 index 00000000000..caf30961ace --- /dev/null +++ b/db/migrate/20220914080716_add_index_to_candidate_id_and_name_on_ml_candidate_params.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddIndexToCandidateIdAndNameOnMlCandidateParams < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_ml_candidate_params_on_candidate_id_on_name' + + def up + add_concurrent_index :ml_candidate_params, [:candidate_id, :name], unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name(:ml_candidate_params, INDEX_NAME) + end +end diff --git a/db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb b/db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb new file mode 100644 index 00000000000..57b3c209660 --- /dev/null +++ b/db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddRejectNonDcoCommitsToPushRules < Gitlab::Database::Migration[2.0] + def change + add_column :push_rules, :reject_non_dco_commits, :boolean + end +end diff --git a/db/migrate/20220914130800_add_jitsu_key_to_projects.rb b/db/migrate/20220914130800_add_jitsu_key_to_projects.rb new file mode 100644 index 00000000000..91c0695c4a6 --- /dev/null +++ b/db/migrate/20220914130800_add_jitsu_key_to_projects.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# rubocop:disable Migration/AddLimitToTextColumns +# limit is added in 20220914131449_add_text_limit_to_projects_jitsu_key.rb +class AddJitsuKeyToProjects < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :project_settings, :jitsu_key, :text + end + end + + def down + with_lock_retries do + remove_column :project_settings, :jitsu_key + end + end +end +# rubocop:enable Migration/AddLimitToTextColumns diff --git a/db/migrate/20220914131449_add_text_limit_to_projects_jitsu_key.rb b/db/migrate/20220914131449_add_text_limit_to_projects_jitsu_key.rb new file mode 100644 index 00000000000..93aa27ffaa2 --- /dev/null +++ b/db/migrate/20220914131449_add_text_limit_to_projects_jitsu_key.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToProjectsJitsuKey < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_text_limit :project_settings, :jitsu_key, 100 + end + + def down + remove_text_limit :project_settings, :jitsu_key + end +end diff --git a/db/migrate/20220914174705_remove_not_null_constraint_from_sbom_source_fingerprint.rb b/db/migrate/20220914174705_remove_not_null_constraint_from_sbom_source_fingerprint.rb new file mode 100644 index 00000000000..6e819b1cdef --- /dev/null +++ b/db/migrate/20220914174705_remove_not_null_constraint_from_sbom_source_fingerprint.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveNotNullConstraintFromSbomSourceFingerprint < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + change_column_null :sbom_sources, :fingerprint, true + end +end diff --git a/db/migrate/20220916094641_add_source_id_to_bulk_import_entities.rb b/db/migrate/20220916094641_add_source_id_to_bulk_import_entities.rb new file mode 100644 index 00000000000..b077fee9045 --- /dev/null +++ b/db/migrate/20220916094641_add_source_id_to_bulk_import_entities.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSourceIdToBulkImportEntities < Gitlab::Database::Migration[2.0] + def change + add_column :bulk_import_entities, :source_xid, :integer + end +end diff --git a/db/migrate/20220916103311_add_index_on_jira_connect_installations_instance_url.rb b/db/migrate/20220916103311_add_index_on_jira_connect_installations_instance_url.rb new file mode 100644 index 00000000000..806c7d65f16 --- /dev/null +++ b/db/migrate/20220916103311_add_index_on_jira_connect_installations_instance_url.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddIndexOnJiraConnectInstallationsInstanceUrl < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_jira_connect_installations_on_instance_url' + + def up + add_concurrent_index :jira_connect_installations, :instance_url, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :jira_connect_installations, name: INDEX_NAME + end +end diff --git a/db/migrate/20220918124223_add_suggested_reviewers_enabled_to_project_settings.rb b/db/migrate/20220918124223_add_suggested_reviewers_enabled_to_project_settings.rb new file mode 100644 index 00000000000..1a762d68bdc --- /dev/null +++ b/db/migrate/20220918124223_add_suggested_reviewers_enabled_to_project_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddSuggestedReviewersEnabledToProjectSettings < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + add_column :project_settings, :suggested_reviewers_enabled, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb b/db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb new file mode 100644 index 00000000000..23b58522639 --- /dev/null +++ b/db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexPackagesPackagesOnProjectIdAndLowerVersionToPackages < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_packages_packages_on_project_id_and_lower_version' + NUGET_PACKAGE_TYPE = 4 + + def up + add_concurrent_index( + :packages_packages, + 'project_id, LOWER(version)', + name: INDEX_NAME, + where: "package_type = #{NUGET_PACKAGE_TYPE}" + ) + end + + def down + remove_concurrent_index_by_name(:packages_packages, INDEX_NAME) + end +end diff --git a/db/migrate/20220920022404_remove_temp_index_null_project_namespace_id.rb b/db/migrate/20220920022404_remove_temp_index_null_project_namespace_id.rb new file mode 100644 index 00000000000..5541afcee40 --- /dev/null +++ b/db/migrate/20220920022404_remove_temp_index_null_project_namespace_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveTempIndexNullProjectNamespaceId < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'tmp_index_for_null_project_namespace_id' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :projects, INDEX_NAME + end + + def down + add_concurrent_index :projects, :id, name: INDEX_NAME, where: 'project_namespace_id IS NULL' + end +end diff --git a/db/migrate/20220921174815_add_secure_files_metadata.rb b/db/migrate/20220921174815_add_secure_files_metadata.rb new file mode 100644 index 00000000000..74cc1d95867 --- /dev/null +++ b/db/migrate/20220921174815_add_secure_files_metadata.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddSecureFilesMetadata < Gitlab::Database::Migration[2.0] + def change + add_column :ci_secure_files, :metadata, :jsonb + add_column :ci_secure_files, :expires_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20220921201347_add_maven_package_requests_forwarding_to_namespace_package_settings.rb b/db/migrate/20220921201347_add_maven_package_requests_forwarding_to_namespace_package_settings.rb new file mode 100644 index 00000000000..8f858eb7960 --- /dev/null +++ b/db/migrate/20220921201347_add_maven_package_requests_forwarding_to_namespace_package_settings.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class AddMavenPackageRequestsForwardingToNamespacePackageSettings < Gitlab::Database::Migration[2.0] + def change + # adds columns to match the format used in + # Gitlab::Database::MigrationHelpers::CascadingNamespaceSettings#add_cascading_namespace_setting + add_column(:namespace_package_settings, + :maven_package_requests_forwarding, + :boolean, + null: true, + default: nil + ) + + add_column(:namespace_package_settings, + :lock_maven_package_requests_forwarding, + :boolean, + default: false, + null: false + ) + + add_column(:application_settings, + :lock_maven_package_requests_forwarding, + :boolean, + default: false, + null: false + ) + end +end diff --git a/db/migrate/20220922143612_add_inbound_ci_job_token_project_scope_links.rb b/db/migrate/20220922143612_add_inbound_ci_job_token_project_scope_links.rb new file mode 100644 index 00000000000..50b43ee4db8 --- /dev/null +++ b/db/migrate/20220922143612_add_inbound_ci_job_token_project_scope_links.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddInboundCiJobTokenProjectScopeLinks < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + add_column :ci_job_token_project_scope_links, :direction, :integer, limit: 2, default: 0, null: false + end + + def down + remove_column :ci_job_token_project_scope_links, :direction + end +end diff --git a/db/migrate/20220923103006_add_ci_pipeline_metadata_title.rb b/db/migrate/20220923103006_add_ci_pipeline_metadata_title.rb new file mode 100644 index 00000000000..3b2f02924a1 --- /dev/null +++ b/db/migrate/20220923103006_add_ci_pipeline_metadata_title.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AddCiPipelineMetadataTitle < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + create_table :ci_pipeline_metadata, id: false do |t| + t.bigint :project_id, null: false + + t.references :pipeline, + null: false, + primary_key: true, + default: nil, + index: false, + foreign_key: { to_table: :ci_pipelines, on_delete: :cascade } + + t.text :title, null: false, limit: 255 + + t.index [:pipeline_id, :title], name: 'index_ci_pipeline_metadata_on_pipeline_id_title' + t.index [:project_id], name: 'index_ci_pipeline_metadata_on_project_id' + end + end + + def down + drop_table :ci_pipeline_metadata + end +end diff --git a/db/migrate/20220927155407_add_column_inbound_job_token_scope_enabled_to_ci_cd_setting.rb b/db/migrate/20220927155407_add_column_inbound_job_token_scope_enabled_to_ci_cd_setting.rb new file mode 100644 index 00000000000..811138cd2f2 --- /dev/null +++ b/db/migrate/20220927155407_add_column_inbound_job_token_scope_enabled_to_ci_cd_setting.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddColumnInboundJobTokenScopeEnabledToCiCdSetting < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + add_column :project_ci_cd_settings, :inbound_job_token_scope_enabled, :boolean, default: false, null: false + end + + def down + remove_column :project_ci_cd_settings, :inbound_job_token_scope_enabled + end +end diff --git a/db/migrate/20220928201920_create_project_wiki_repository_states.rb b/db/migrate/20220928201920_create_project_wiki_repository_states.rb new file mode 100644 index 00000000000..17ad5cf6b7a --- /dev/null +++ b/db/migrate/20220928201920_create_project_wiki_repository_states.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +class CreateProjectWikiRepositoryStates < Gitlab::Database::Migration[2.0] + VERIFICATION_STATE_INDEX_NAME = "index_project_wiki_repository_states_on_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_project_wiki_repository_states_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_project_wiki_repository_states_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_project_wiki_repository_states_needs_verification" + + enable_lock_retries! + + def up + create_table :project_wiki_repository_states, id: false do |t| + t.datetime_with_timezone :verification_started_at + t.datetime_with_timezone :verification_retry_at + t.datetime_with_timezone :verified_at + t.references :project, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade } + t.integer :verification_state, default: 0, limit: 2, null: false + t.integer :verification_retry_count, limit: 2 + t.binary :verification_checksum, using: 'verification_checksum::bytea' + t.text :verification_failure, limit: 255 + + t.index :verification_state, + name: VERIFICATION_STATE_INDEX_NAME + + t.index :verified_at, + where: "(verification_state = 0)", + order: { verified_at: 'ASC NULLS FIRST' }, + name: PENDING_VERIFICATION_INDEX_NAME + + t.index :verification_retry_at, + where: "(verification_state = 3)", + order: { verification_retry_at: 'ASC NULLS FIRST' }, + name: FAILED_VERIFICATION_INDEX_NAME + + t.index :verification_state, + where: "(verification_state = 0 OR verification_state = 3)", + name: NEEDS_VERIFICATION_INDEX_NAME + end + end + + def down + drop_table :project_wiki_repository_states + end +end diff --git a/db/migrate/20220929171925_add_pypi_package_requests_forwarding_to_namespace_package_settings.rb b/db/migrate/20220929171925_add_pypi_package_requests_forwarding_to_namespace_package_settings.rb new file mode 100644 index 00000000000..e99640d471f --- /dev/null +++ b/db/migrate/20220929171925_add_pypi_package_requests_forwarding_to_namespace_package_settings.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class AddPypiPackageRequestsForwardingToNamespacePackageSettings < Gitlab::Database::Migration[2.0] + def change + # adds columns to match the format used in + # Gitlab::Database::MigrationHelpers::CascadingNamespaceSettings#add_cascading_namespace_setting + add_column(:namespace_package_settings, + :pypi_package_requests_forwarding, + :boolean, + null: true, + default: nil + ) + + add_column(:namespace_package_settings, + :lock_pypi_package_requests_forwarding, + :boolean, + default: false, + null: false + ) + + add_column(:application_settings, + :lock_pypi_package_requests_forwarding, + :boolean, + default: false, + null: false + ) + end +end diff --git a/db/migrate/20220929172356_add_npm_package_requests_forwarding_to_namespace_package_settings.rb b/db/migrate/20220929172356_add_npm_package_requests_forwarding_to_namespace_package_settings.rb new file mode 100644 index 00000000000..61cc2c26ec7 --- /dev/null +++ b/db/migrate/20220929172356_add_npm_package_requests_forwarding_to_namespace_package_settings.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class AddNpmPackageRequestsForwardingToNamespacePackageSettings < Gitlab::Database::Migration[2.0] + def change + # adds columns to match the format used in + # Gitlab::Database::MigrationHelpers::CascadingNamespaceSettings#add_cascading_namespace_setting + add_column(:namespace_package_settings, + :npm_package_requests_forwarding, + :boolean, + null: true, + default: nil + ) + + add_column(:namespace_package_settings, + :lock_npm_package_requests_forwarding, + :boolean, + default: false, + null: false + ) + + add_column(:application_settings, + :lock_npm_package_requests_forwarding, + :boolean, + default: false, + null: false + ) + end +end diff --git a/db/migrate/20220930125609_add_migrated_to_state_transition_to_vulnerability_feedback.rb b/db/migrate/20220930125609_add_migrated_to_state_transition_to_vulnerability_feedback.rb new file mode 100644 index 00000000000..b6736a71761 --- /dev/null +++ b/db/migrate/20220930125609_add_migrated_to_state_transition_to_vulnerability_feedback.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddMigratedToStateTransitionToVulnerabilityFeedback < Gitlab::Database::Migration[2.0] + def change + add_column :vulnerability_feedback, :migrated_to_state_transition, :boolean, default: false + end +end diff --git a/db/migrate/20221005072353_create_incident_management_timeline_event_tags.rb b/db/migrate/20221005072353_create_incident_management_timeline_event_tags.rb new file mode 100644 index 00000000000..c046548af01 --- /dev/null +++ b/db/migrate/20221005072353_create_incident_management_timeline_event_tags.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class CreateIncidentManagementTimelineEventTags < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + create_table :incident_management_timeline_event_tags do |t| + t.timestamps_with_timezone null: false + t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade } + t.text :name, limit: 255, null: false + + t.index [:project_id, :name], unique: true, name: 'index_im_timeline_event_tags_name_project_id' + end + end + + def down + drop_table :incident_management_timeline_event_tags + end +end diff --git a/db/migrate/20221005094926_create_incident_management_timeline_event_tag_links.rb b/db/migrate/20221005094926_create_incident_management_timeline_event_tag_links.rb new file mode 100644 index 00000000000..b3ec8f97738 --- /dev/null +++ b/db/migrate/20221005094926_create_incident_management_timeline_event_tag_links.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class CreateIncidentManagementTimelineEventTagLinks < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def up + create_table :incident_management_timeline_event_tag_links do |t| + t.references :timeline_event, + null: false, + index: { name: 'index_im_timeline_event_id' }, + foreign_key: { to_table: :incident_management_timeline_events, column: :timeline_event_id, on_delete: :cascade } + + t.references :timeline_event_tag, + null: false, + index: false, + foreign_key: { + to_table: :incident_management_timeline_event_tags, + column: :timeline_event_tag_id, + on_delete: :cascade + } + + t.index [:timeline_event_tag_id, :timeline_event_id], + unique: true, + name: 'index_im_timeline_event_tags_on_tag_id_and_event_id' + + t.datetime_with_timezone :created_at, null: false + end + end + + def down + drop_table :incident_management_timeline_event_tag_links + end +end diff --git a/db/migrate/20221005103010_add_index_project_id_on_scan_finding_approval_project_rules.rb b/db/migrate/20221005103010_add_index_project_id_on_scan_finding_approval_project_rules.rb new file mode 100644 index 00000000000..990188aa418 --- /dev/null +++ b/db/migrate/20221005103010_add_index_project_id_on_scan_finding_approval_project_rules.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddIndexProjectIdOnScanFindingApprovalProjectRules < Gitlab::Database::Migration[2.0] + INDEX_NAME_ALL = 'scan_finding_approval_project_rule_index_project_id' + INDEX_NAME_28D = 'scan_finding_approval_project_rule_index_created_at_project_id' + SCAN_FINDING_REPORT_TYPE = 4 + + disable_ddl_transaction! + + def up + add_concurrent_index :approval_project_rules, %i[created_at project_id], + where: "report_type = #{SCAN_FINDING_REPORT_TYPE}", name: INDEX_NAME_28D + + add_concurrent_index :approval_project_rules, :project_id, + where: "report_type = #{SCAN_FINDING_REPORT_TYPE}", name: INDEX_NAME_ALL + end + + def down + remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME_ALL + remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME_28D + end +end diff --git a/db/migrate/20221006131506_add_free_user_cap_over_limit_notified_at_to_namespace_details.rb b/db/migrate/20221006131506_add_free_user_cap_over_limit_notified_at_to_namespace_details.rb new file mode 100644 index 00000000000..7237eee18f0 --- /dev/null +++ b/db/migrate/20221006131506_add_free_user_cap_over_limit_notified_at_to_namespace_details.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddFreeUserCapOverLimitNotifiedAtToNamespaceDetails < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + TABLE_NAME = 'namespace_details' + COLUMN_NAME = 'free_user_cap_over_limit_notified_at' + + def up + with_lock_retries do + add_column(TABLE_NAME, COLUMN_NAME, :datetime_with_timezone) + end + end + + def down + with_lock_retries do + remove_column TABLE_NAME, COLUMN_NAME + end + end +end diff --git a/db/migrate/20221006141145_add_targets_to_elastic_reindexing_tasks.rb b/db/migrate/20221006141145_add_targets_to_elastic_reindexing_tasks.rb new file mode 100644 index 00000000000..1631f8ae57e --- /dev/null +++ b/db/migrate/20221006141145_add_targets_to_elastic_reindexing_tasks.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddTargetsToElasticReindexingTasks < Gitlab::Database::Migration[2.0] + def change + add_column :elastic_reindexing_tasks, :targets, :text, array: true + end +end diff --git a/db/migrate/20221008032350_add_password_expiration_migration.rb b/db/migrate/20221008032350_add_password_expiration_migration.rb new file mode 100644 index 00000000000..7dbc73294bb --- /dev/null +++ b/db/migrate/20221008032350_add_password_expiration_migration.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddPasswordExpirationMigration < Gitlab::Database::Migration[2.0] + def change + add_column :application_settings, :password_expiration_enabled, :boolean, default: false, null: false, + comment: 'JiHu-specific column' + add_column :application_settings, :password_expires_in_days, :integer, default: 90, null: false, + comment: 'JiHu-specific column' + add_column :application_settings, :password_expires_notice_before_days, :integer, default: 7, null: false, + comment: 'JiHu-specific column' + end +end diff --git a/db/migrate/20221009085130_add_mr_checks_columns_to_namespace_settings.rb b/db/migrate/20221009085130_add_mr_checks_columns_to_namespace_settings.rb new file mode 100644 index 00000000000..947a662575a --- /dev/null +++ b/db/migrate/20221009085130_add_mr_checks_columns_to_namespace_settings.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddMrChecksColumnsToNamespaceSettings < Gitlab::Database::Migration[2.0] + def change + add_column :namespace_settings, :only_allow_merge_if_pipeline_succeeds, :boolean, default: false, null: false + add_column :namespace_settings, :allow_merge_on_skipped_pipeline, :boolean, default: false, null: false + add_column :namespace_settings, :only_allow_merge_if_all_discussions_are_resolved, \ + :boolean, default: false, null: false + end +end diff --git a/db/migrate/20221011162637_add_partial_index_project_incident_management_settings_on_project_id_and_sla_timer.rb b/db/migrate/20221011162637_add_partial_index_project_incident_management_settings_on_project_id_and_sla_timer.rb new file mode 100644 index 00000000000..4238311005c --- /dev/null +++ b/db/migrate/20221011162637_add_partial_index_project_incident_management_settings_on_project_id_and_sla_timer.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddPartialIndexProjectIncidentManagementSettingsOnProjectIdAndSlaTimer < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_project_incident_management_settings_on_p_id_sla_timer' + + def up + add_concurrent_index :project_incident_management_settings, :project_id, + name: INDEX_NAME, + where: 'sla_timer = TRUE' + end + + def down + remove_concurrent_index_by_name :project_incident_management_settings, name: INDEX_NAME + end +end diff --git a/db/migrate/20221011210455_add_use_legacy_web_ide_to_user_preferences.rb b/db/migrate/20221011210455_add_use_legacy_web_ide_to_user_preferences.rb new file mode 100644 index 00000000000..1b434e10ab0 --- /dev/null +++ b/db/migrate/20221011210455_add_use_legacy_web_ide_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddUseLegacyWebIdeToUserPreferences < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + add_column :user_preferences, :use_legacy_web_ide, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20221012033107_add_password_last_changed_at_to_user_details.rb b/db/migrate/20221012033107_add_password_last_changed_at_to_user_details.rb new file mode 100644 index 00000000000..db2f411ab92 --- /dev/null +++ b/db/migrate/20221012033107_add_password_last_changed_at_to_user_details.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddPasswordLastChangedAtToUserDetails < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + add_column :user_details, :password_last_changed_at, :datetime_with_timezone, comment: 'JiHu-specific column' + end +end diff --git a/db/migrate/20221012135524_add_scan_file_path_limit_for_dast_site_profile.rb b/db/migrate/20221012135524_add_scan_file_path_limit_for_dast_site_profile.rb new file mode 100644 index 00000000000..ab8846c8043 --- /dev/null +++ b/db/migrate/20221012135524_add_scan_file_path_limit_for_dast_site_profile.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddScanFilePathLimitForDastSiteProfile < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_text_limit :dast_site_profiles, :scan_file_path, 1024 + end + + def down + remove_text_limit :dast_site_profiles, :scan_file_path + end +end diff --git a/db/migrate/20221014031033_add_temp_index_to_project_features_where_releases_access_level_gt_repository.rb b/db/migrate/20221014031033_add_temp_index_to_project_features_where_releases_access_level_gt_repository.rb new file mode 100644 index 00000000000..14077e30780 --- /dev/null +++ b/db/migrate/20221014031033_add_temp_index_to_project_features_where_releases_access_level_gt_repository.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddTempIndexToProjectFeaturesWhereReleasesAccessLevelGtRepository < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'tmp_idx_project_features_on_releases_al_and_repo_al_partial' + + # Temporary index to be removed in 15.6 https://gitlab.com/gitlab-org/gitlab/-/issues/377915 + def up + add_concurrent_index :project_features, + [:releases_access_level, :repository_access_level], + name: INDEX_NAME, + where: 'releases_access_level > repository_access_level' + end + + def down + remove_concurrent_index_by_name :project_features, INDEX_NAME + end +end diff --git a/db/migrate/20221014034338_populate_releases_access_level_from_repository.rb b/db/migrate/20221014034338_populate_releases_access_level_from_repository.rb new file mode 100644 index 00000000000..6e61d972bf6 --- /dev/null +++ b/db/migrate/20221014034338_populate_releases_access_level_from_repository.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class PopulateReleasesAccessLevelFromRepository < Gitlab::Database::Migration[2.0] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + disable_ddl_transaction! + + def up + update_column_in_batches( + :project_features, + :releases_access_level, + Arel.sql('repository_access_level') + ) do |table, query| + query.where(table[:releases_access_level].gt(table[:repository_access_level])) + end + end + + def down + # no-op + end +end diff --git a/db/migrate/20221014190040_drop_notes_note_trigram_index.rb b/db/migrate/20221014190040_drop_notes_note_trigram_index.rb new file mode 100644 index 00000000000..efa35b24d98 --- /dev/null +++ b/db/migrate/20221014190040_drop_notes_note_trigram_index.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class DropNotesNoteTrigramIndex < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_notes_on_note_gin_trigram' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :notes, INDEX_NAME + end + + def down + # no-op + # we never want to add this index back since it doesn't exist in production + # we are only using this migration to cleanup other environments where this index does exist + end +end diff --git a/db/migrate/20221018081416_members_remove_member_namespace_id_not_null_constraint.rb b/db/migrate/20221018081416_members_remove_member_namespace_id_not_null_constraint.rb new file mode 100644 index 00000000000..e4cbcd24bc4 --- /dev/null +++ b/db/migrate/20221018081416_members_remove_member_namespace_id_not_null_constraint.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class MembersRemoveMemberNamespaceIdNotNullConstraint < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + CONSTRAINT_NAME = 'check_508774aac0' + + def up + remove_not_null_constraint :members, :member_namespace_id, constraint_name: CONSTRAINT_NAME + end + + def down + add_not_null_constraint :members, :member_namespace_id, validate: false, constraint_name: CONSTRAINT_NAME + end +end -- cgit v1.2.1