diff options
Diffstat (limited to 'db/migrate')
78 files changed, 1415 insertions, 8 deletions
diff --git a/db/migrate/20200609212701_add_incident_settings_to_all_existing_projects.rb b/db/migrate/20200609212701_add_incident_settings_to_all_existing_projects.rb index 60286e0dca6..a2931824ef5 100644 --- a/db/migrate/20200609212701_add_incident_settings_to_all_existing_projects.rb +++ b/db/migrate/20200609212701_add_incident_settings_to_all_existing_projects.rb @@ -8,7 +8,7 @@ class AddIncidentSettingsToAllExistingProjects < ActiveRecord::Migration[6.0] # to preserve behavior for existing projects that # are using the create issue functionality with the default setting of true query = <<-SQL - WITH project_ids AS ( + WITH project_ids AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}( SELECT DISTINCT issues.project_id AS id FROM issues LEFT OUTER JOIN project_incident_management_settings diff --git a/db/migrate/20200928233632_remove_terraform_state_verification_indexes.rb b/db/migrate/20200928233632_remove_terraform_state_verification_indexes.rb index 0256d580cd6..b5a7bb5e39d 100644 --- a/db/migrate/20200928233632_remove_terraform_state_verification_indexes.rb +++ b/db/migrate/20200928233632_remove_terraform_state_verification_indexes.rb @@ -4,8 +4,8 @@ class RemoveTerraformStateVerificationIndexes < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers DOWNTIME = false - CHECKSUM_INDEX_NAME = "terraform_states_verification_checksum_partial".freeze - FAILURE_INDEX_NAME = "terraform_states_verification_failure_partial".freeze + CHECKSUM_INDEX_NAME = "terraform_states_verification_checksum_partial" + FAILURE_INDEX_NAME = "terraform_states_verification_failure_partial" disable_ddl_transaction! diff --git a/db/migrate/20201214032220_add_has_external_wiki_trigger.rb b/db/migrate/20201214032220_add_has_external_wiki_trigger.rb index f6e066b75da..c77b887d509 100644 --- a/db/migrate/20201214032220_add_has_external_wiki_trigger.rb +++ b/db/migrate/20201214032220_add_has_external_wiki_trigger.rb @@ -4,10 +4,10 @@ class AddHasExternalWikiTrigger < ActiveRecord::Migration[6.0] include Gitlab::Database::SchemaHelpers DOWNTIME = false - FUNCTION_NAME = 'set_has_external_wiki'.freeze - TRIGGER_ON_INSERT_NAME = 'trigger_has_external_wiki_on_insert'.freeze - TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_wiki_on_update'.freeze - TRIGGER_ON_DELETE_NAME = 'trigger_has_external_wiki_on_delete'.freeze + FUNCTION_NAME = 'set_has_external_wiki' + TRIGGER_ON_INSERT_NAME = 'trigger_has_external_wiki_on_insert' + TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_wiki_on_update' + TRIGGER_ON_DELETE_NAME = 'trigger_has_external_wiki_on_delete' def up create_trigger_function(FUNCTION_NAME, replace: true) do diff --git a/db/migrate/20201218194311_create_admin_notes.rb b/db/migrate/20201218194311_create_admin_notes.rb new file mode 100644 index 00000000000..32f5818cdfb --- /dev/null +++ b/db/migrate/20201218194311_create_admin_notes.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class CreateAdminNotes < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + create_table_with_constraints :namespace_admin_notes do |t| + t.timestamps_with_timezone + t.references :namespace, null: false, foreign_key: { on_delete: :cascade } + t.text :note + + t.text_limit :note, 1000 + end + end + + def down + drop_table :namespace_admin_notes + end +end diff --git a/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb b/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb index 0ecf194eb97..9c99414792e 100644 --- a/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb +++ b/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb @@ -7,7 +7,7 @@ class DropTemporaryIndexOnCiBuilds < ActiveRecord::Migration[6.0] disable_ddl_transaction! - INDEX = 'tmp_build_stage_position_index'.freeze + INDEX = 'tmp_build_stage_position_index' def up remove_concurrent_index_by_name :ci_builds, INDEX diff --git a/db/migrate/20210106061254_add_unique_index_for_golang_packages.rb b/db/migrate/20210106061254_add_unique_index_for_golang_packages.rb new file mode 100644 index 00000000000..44237699fda --- /dev/null +++ b/db/migrate/20210106061254_add_unique_index_for_golang_packages.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddUniqueIndexForGolangPackages < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_golang' + PACKAGE_TYPE_GOLANG = 8 + + disable_ddl_transaction! + + def up + add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, where: "package_type = #{PACKAGE_TYPE_GOLANG}", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name(:packages_packages, INDEX_NAME) + end +end diff --git a/db/migrate/20210219211845_add_version_usage_data_id_to_raw_usage_data.rb b/db/migrate/20210219211845_add_version_usage_data_id_to_raw_usage_data.rb new file mode 100644 index 00000000000..1b49fdd98bd --- /dev/null +++ b/db/migrate/20210219211845_add_version_usage_data_id_to_raw_usage_data.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddVersionUsageDataIdToRawUsageData < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :raw_usage_data, :version_usage_data_id_value, :bigint + end +end diff --git a/db/migrate/20210223230600_update_rubygems_metadata_metadata.rb b/db/migrate/20210223230600_update_rubygems_metadata_metadata.rb new file mode 100644 index 00000000000..39e79be301e --- /dev/null +++ b/db/migrate/20210223230600_update_rubygems_metadata_metadata.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class UpdateRubygemsMetadataMetadata < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_text_limit :packages_rubygems_metadata, :metadata + add_text_limit :packages_rubygems_metadata, :metadata, 30000 + end + + def down + remove_text_limit :packages_rubygems_metadata, :metadata + add_text_limit :packages_rubygems_metadata, :metadata, 255, validate: false + end +end diff --git a/db/migrate/20210224161552_add_jira_issue_transition_automatic_to_jira_tracker_data.rb b/db/migrate/20210224161552_add_jira_issue_transition_automatic_to_jira_tracker_data.rb new file mode 100644 index 00000000000..6c788b9d554 --- /dev/null +++ b/db/migrate/20210224161552_add_jira_issue_transition_automatic_to_jira_tracker_data.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddJiraIssueTransitionAutomaticToJiraTrackerData < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :jira_tracker_data, :jira_issue_transition_automatic, :boolean, null: false, default: false + end +end diff --git a/db/migrate/20210302025305_add_excluded_urls_and_request_headers_to_dast_site_profiles.rb b/db/migrate/20210302025305_add_excluded_urls_and_request_headers_to_dast_site_profiles.rb new file mode 100644 index 00000000000..167b8d2c509 --- /dev/null +++ b/db/migrate/20210302025305_add_excluded_urls_and_request_headers_to_dast_site_profiles.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddExcludedUrlsAndRequestHeadersToDastSiteProfiles < ActiveRecord::Migration[6.0] + DOWNTIME = false + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20210311022012_add_text_limits_to_dast_site_profiles + def change + add_column :dast_site_profiles, :excluded_urls, :text, array: true, default: [], null: false + add_column :dast_site_profiles, :auth_enabled, :boolean, default: false, null: false + add_column :dast_site_profiles, :auth_url, :text + add_column :dast_site_profiles, :auth_username_field, :text + add_column :dast_site_profiles, :auth_password_field, :text + add_column :dast_site_profiles, :auth_username, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20210305031822_create_dast_site_profile_variables.rb b/db/migrate/20210305031822_create_dast_site_profile_variables.rb new file mode 100644 index 00000000000..f55755aa731 --- /dev/null +++ b/db/migrate/20210305031822_create_dast_site_profile_variables.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class CreateDastSiteProfileVariables < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + table_comment = { owner: 'group::dynamic analysis', description: 'Secret variables used in DAST on-demand scans' } + + encrypted_value_constraint_name = check_constraint_name(:dast_site_profile_secret_variables, 'encrypted_value', 'max_length') + encrypted_value_iv_constraint_name = check_constraint_name(:dast_site_profile_secret_variables, 'encrypted_value_iv', 'max_length') + + create_table_with_constraints :dast_site_profile_secret_variables, comment: table_comment.to_json do |t| + t.references :dast_site_profile, null: false, foreign_key: { on_delete: :cascade }, index: false + + t.timestamps_with_timezone + + t.integer :variable_type, null: false, default: 1, limit: 2 + + t.text :key, null: false + t.binary :encrypted_value, null: false + t.binary :encrypted_value_iv, null: false, unique: true + + t.index [:dast_site_profile_id, :key], unique: true, name: :index_site_profile_secret_variables_on_site_profile_id_and_key + + t.text_limit :key, 255 + + # This does not currently have first-class support via create_table_with_constraints + t.check_constraint encrypted_value_constraint_name, 'length(encrypted_value) <= 13352' + t.check_constraint encrypted_value_iv_constraint_name, 'length(encrypted_value_iv) <= 17' + end + end + + def down + drop_table :dast_site_profile_secret_variables + end +end diff --git a/db/migrate/20210305180331_create_ci_unit_tests.rb b/db/migrate/20210305180331_create_ci_unit_tests.rb new file mode 100644 index 00000000000..970834a025b --- /dev/null +++ b/db/migrate/20210305180331_create_ci_unit_tests.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class CreateCiUnitTests < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:ci_unit_tests) + create_table :ci_unit_tests do |t| + t.bigint :project_id, null: false + t.text :key_hash, null: false + t.text :name, null: false + t.text :suite_name, null: false + + t.index [:project_id, :key_hash], unique: true + # NOTE: FK for projects will be added on a separate migration as per guidelines + end + end + + add_text_limit :ci_unit_tests, :key_hash, 64 + add_text_limit :ci_unit_tests, :name, 255 + add_text_limit :ci_unit_tests, :suite_name, 255 + end + + def down + drop_table :ci_unit_tests + end +end diff --git a/db/migrate/20210305182740_add_projects_fk_to_ci_unit_tests.rb b/db/migrate/20210305182740_add_projects_fk_to_ci_unit_tests.rb new file mode 100644 index 00000000000..5e750d78a24 --- /dev/null +++ b/db/migrate/20210305182740_add_projects_fk_to_ci_unit_tests.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddProjectsFkToCiUnitTests < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ci_unit_tests, :projects, column: :project_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :ci_unit_tests, column: :project_id + end + end +end diff --git a/db/migrate/20210305182855_create_ci_unit_test_failures.rb b/db/migrate/20210305182855_create_ci_unit_test_failures.rb new file mode 100644 index 00000000000..b3f68cdba4a --- /dev/null +++ b/db/migrate/20210305182855_create_ci_unit_test_failures.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class CreateCiUnitTestFailures < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + create_table :ci_unit_test_failures do |t| + t.datetime_with_timezone :failed_at, null: false + t.bigint :unit_test_id, null: false + t.bigint :build_id, null: false + + t.index [:unit_test_id, :failed_at, :build_id], name: 'index_unit_test_failures_unique_columns', unique: true, order: { failed_at: :desc } + t.index :build_id + # NOTE: Adding the index for failed_at now for later use when we do scheduled clean up + t.index :failed_at, order: { failed_at: :desc }, name: 'index_unit_test_failures_failed_at' + t.foreign_key :ci_unit_tests, column: :unit_test_id, on_delete: :cascade + # NOTE: FK for ci_builds will be added on a separate migration as per guidelines + end + end + + def down + drop_table :ci_unit_test_failures + end +end diff --git a/db/migrate/20210305183904_add_ci_builds_fk_to_ci_unit_test_failures.rb b/db/migrate/20210305183904_add_ci_builds_fk_to_ci_unit_test_failures.rb new file mode 100644 index 00000000000..9cf75ba6059 --- /dev/null +++ b/db/migrate/20210305183904_add_ci_builds_fk_to_ci_unit_test_failures.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddCiBuildsFkToCiUnitTestFailures < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ci_unit_test_failures, :ci_builds, column: :build_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :ci_unit_test_failures, column: :build_id + end + end +end diff --git a/db/migrate/20210308175224_change_namespace_settings_delayed_project_removal_null.rb b/db/migrate/20210308175224_change_namespace_settings_delayed_project_removal_null.rb new file mode 100644 index 00000000000..5b731b78117 --- /dev/null +++ b/db/migrate/20210308175224_change_namespace_settings_delayed_project_removal_null.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class ChangeNamespaceSettingsDelayedProjectRemovalNull < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + change_column :namespace_settings, :delayed_project_removal, :boolean, null: true, default: nil + end + + def down + change_column_default :namespace_settings, :delayed_project_removal, false + change_column_null :namespace_settings, :delayed_project_removal, false, false + end +end diff --git a/db/migrate/20210308175225_add_lock_delayed_project_removal_to_namespace_settings.rb b/db/migrate/20210308175225_add_lock_delayed_project_removal_to_namespace_settings.rb new file mode 100644 index 00000000000..e88f3e7ea0d --- /dev/null +++ b/db/migrate/20210308175225_add_lock_delayed_project_removal_to_namespace_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddLockDelayedProjectRemovalToNamespaceSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :namespace_settings, :lock_delayed_project_removal, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20210308175226_add_delayed_project_removal_to_application_settings.rb b/db/migrate/20210308175226_add_delayed_project_removal_to_application_settings.rb new file mode 100644 index 00000000000..1ccb25878e4 --- /dev/null +++ b/db/migrate/20210308175226_add_delayed_project_removal_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDelayedProjectRemovalToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :delayed_project_removal, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20210308175227_add_lock_delayed_project_removal_to_application_settings.rb b/db/migrate/20210308175227_add_lock_delayed_project_removal_to_application_settings.rb new file mode 100644 index 00000000000..c63175493de --- /dev/null +++ b/db/migrate/20210308175227_add_lock_delayed_project_removal_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddLockDelayedProjectRemovalToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :lock_delayed_project_removal, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20210309160106_add_admin_mode_to_application_setting.rb b/db/migrate/20210309160106_add_admin_mode_to_application_setting.rb new file mode 100644 index 00000000000..a7b634596d2 --- /dev/null +++ b/db/migrate/20210309160106_add_admin_mode_to_application_setting.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddAdminModeToApplicationSetting < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :admin_mode, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20210311022012_add_text_limits_to_dast_site_profiles.rb b/db/migrate/20210311022012_add_text_limits_to_dast_site_profiles.rb new file mode 100644 index 00000000000..7858449be14 --- /dev/null +++ b/db/migrate/20210311022012_add_text_limits_to_dast_site_profiles.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AddTextLimitsToDastSiteProfiles < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_text_limit :dast_site_profiles, :auth_url, 1024 + add_text_limit :dast_site_profiles, :auth_username_field, 255 + add_text_limit :dast_site_profiles, :auth_password_field, 255 + add_text_limit :dast_site_profiles, :auth_username, 255 + end + + def down + remove_text_limit :dast_site_profiles, :auth_username + remove_text_limit :dast_site_profiles, :auth_password_field + remove_text_limit :dast_site_profiles, :auth_username_field + remove_text_limit :dast_site_profiles, :auth_url + end +end diff --git a/db/migrate/20210311120152_add_metrics_to_batched_background_migration_jobs.rb b/db/migrate/20210311120152_add_metrics_to_batched_background_migration_jobs.rb new file mode 100644 index 00000000000..523010a4aea --- /dev/null +++ b/db/migrate/20210311120152_add_metrics_to_batched_background_migration_jobs.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddMetricsToBatchedBackgroundMigrationJobs < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :batched_background_migration_jobs, :metrics, :jsonb, null: false, default: {} + end +end diff --git a/db/migrate/20210311120153_initialize_conversion_of_events_id_to_bigint.rb b/db/migrate/20210311120153_initialize_conversion_of_events_id_to_bigint.rb new file mode 100644 index 00000000000..72536d24fe1 --- /dev/null +++ b/db/migrate/20210311120153_initialize_conversion_of_events_id_to_bigint.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class InitializeConversionOfEventsIdToBigint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + # Initialize the conversion of events.id to bigint + # Primary Key of the Events table + initialize_conversion_of_integer_to_bigint :events, :id + end + + def down + trigger_name = rename_trigger_name(:events, :id, :id_convert_to_bigint) + + remove_rename_triggers_for_postgresql :events, trigger_name + + remove_column :events, :id_convert_to_bigint + end +end diff --git a/db/migrate/20210311120154_initialize_conversion_of_push_event_payloads_event_id_to_bigint.rb b/db/migrate/20210311120154_initialize_conversion_of_push_event_payloads_event_id_to_bigint.rb new file mode 100644 index 00000000000..9ce3b59e2dd --- /dev/null +++ b/db/migrate/20210311120154_initialize_conversion_of_push_event_payloads_event_id_to_bigint.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class InitializeConversionOfPushEventPayloadsEventIdToBigint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + # Foreign key that references events.id + # Also Primary key of the push_event_payloads table + initialize_conversion_of_integer_to_bigint :push_event_payloads, :event_id, primary_key: :event_id + end + + def down + trigger_name = rename_trigger_name(:push_event_payloads, :event_id, :event_id_convert_to_bigint) + + remove_rename_triggers_for_postgresql :push_event_payloads, trigger_name + + remove_column :push_event_payloads, :event_id_convert_to_bigint + end +end diff --git a/db/migrate/20210312140029_add_owner_and_id_index_on_active_ci_pipeline_schedules.rb b/db/migrate/20210312140029_add_owner_and_id_index_on_active_ci_pipeline_schedules.rb new file mode 100644 index 00000000000..111486a17ab --- /dev/null +++ b/db/migrate/20210312140029_add_owner_and_id_index_on_active_ci_pipeline_schedules.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddOwnerAndIdIndexOnActiveCiPipelineSchedules < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_ci_pipeline_schedules_on_owner_id_and_id_and_active' + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipeline_schedules, [:owner_id, :id], where: "active = TRUE", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ci_pipeline_schedules, INDEX_NAME + end +end diff --git a/db/migrate/20210312174321_add_enforced_git_check_to_saml_provider.rb b/db/migrate/20210312174321_add_enforced_git_check_to_saml_provider.rb new file mode 100644 index 00000000000..89553a53084 --- /dev/null +++ b/db/migrate/20210312174321_add_enforced_git_check_to_saml_provider.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddEnforcedGitCheckToSamlProvider < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + add_column :saml_providers, :git_check_enforced, :boolean, default: false, null: false + end + + def down + remove_column :saml_providers, :git_check_enforced + end +end diff --git a/db/migrate/20210312193532_add_resource_access_token_creation_allowed_to_namespace_settings.rb b/db/migrate/20210312193532_add_resource_access_token_creation_allowed_to_namespace_settings.rb new file mode 100644 index 00000000000..1de9d87cf25 --- /dev/null +++ b/db/migrate/20210312193532_add_resource_access_token_creation_allowed_to_namespace_settings.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true +class AddResourceAccessTokenCreationAllowedToNamespaceSettings < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :namespace_settings, :resource_access_token_creation_allowed, :boolean, default: true, null: false + end + end + + def down + with_lock_retries do + remove_column :namespace_settings, :resource_access_token_creation_allowed + end + end +end diff --git a/db/migrate/20210313045617_add_verification_state_and_started_at_to_snippet_repositories.rb b/db/migrate/20210313045617_add_verification_state_and_started_at_to_snippet_repositories.rb new file mode 100644 index 00000000000..e2d6dff23fa --- /dev/null +++ b/db/migrate/20210313045617_add_verification_state_and_started_at_to_snippet_repositories.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddVerificationStateAndStartedAtToSnippetRepositories < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + change_table(:snippet_repositories) do |t| + t.integer :verification_state, default: 0, limit: 2, null: false + t.column :verification_started_at, :datetime_with_timezone + end + end +end diff --git a/db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb b/db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb new file mode 100644 index 00000000000..ebbc1126aa2 --- /dev/null +++ b/db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AddVerificationIndexesToSnippetRepositories < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + VERIFICATION_STATE_INDEX_NAME = "index_snippet_repositories_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_snippet_repositories_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_snippet_repositories_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_snippet_repositories_needs_verification" + + disable_ddl_transaction! + + def up + add_concurrent_index :snippet_repositories, :verification_state, name: VERIFICATION_STATE_INDEX_NAME + add_concurrent_index :snippet_repositories, :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME + add_concurrent_index :snippet_repositories, :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME + add_concurrent_index :snippet_repositories, :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME + end + + def down + remove_concurrent_index_by_name :snippet_repositories, VERIFICATION_STATE_INDEX_NAME + remove_concurrent_index_by_name :snippet_repositories, PENDING_VERIFICATION_INDEX_NAME + remove_concurrent_index_by_name :snippet_repositories, FAILED_VERIFICATION_INDEX_NAME + remove_concurrent_index_by_name :snippet_repositories, NEEDS_VERIFICATION_INDEX_NAME + end +end diff --git a/db/migrate/20210316094047_add_trial_extension_type_to_gitlab_subscription_histories.rb b/db/migrate/20210316094047_add_trial_extension_type_to_gitlab_subscription_histories.rb new file mode 100644 index 00000000000..3915689e0af --- /dev/null +++ b/db/migrate/20210316094047_add_trial_extension_type_to_gitlab_subscription_histories.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddTrialExtensionTypeToGitlabSubscriptionHistories < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :gitlab_subscription_histories, :trial_extension_type, :smallint + end +end diff --git a/db/migrate/20210316094323_add_trial_extension_type_to_gitlab_subscriptions.rb b/db/migrate/20210316094323_add_trial_extension_type_to_gitlab_subscriptions.rb new file mode 100644 index 00000000000..fb0ee789277 --- /dev/null +++ b/db/migrate/20210316094323_add_trial_extension_type_to_gitlab_subscriptions.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddTrialExtensionTypeToGitlabSubscriptions < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :gitlab_subscriptions, :trial_extension_type, :smallint + end + end + + def down + with_lock_retries do + remove_column :gitlab_subscriptions, :trial_extension_type + end + end +end diff --git a/db/migrate/20210316152500_add_index_ci_stages_on_pipeline_id_and_id.rb b/db/migrate/20210316152500_add_index_ci_stages_on_pipeline_id_and_id.rb new file mode 100644 index 00000000000..1128bf586ae --- /dev/null +++ b/db/migrate/20210316152500_add_index_ci_stages_on_pipeline_id_and_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexCiStagesOnPipelineIdAndId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_ci_stages_on_pipeline_id_and_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_stages, %i[pipeline_id id], where: 'status IN (0, 1, 2, 8, 9, 10)', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ci_stages, INDEX_NAME + end +end diff --git a/db/migrate/20210317035357_create_dast_profiles_pipelines.rb b/db/migrate/20210317035357_create_dast_profiles_pipelines.rb new file mode 100644 index 00000000000..f7a29958f12 --- /dev/null +++ b/db/migrate/20210317035357_create_dast_profiles_pipelines.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class CreateDastProfilesPipelines < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Profiles and CI Pipelines' } + + create_table :dast_profiles_pipelines, primary_key: [:dast_profile_id, :ci_pipeline_id], comment: table_comment.to_json do |t| + t.bigint :dast_profile_id, null: false + t.bigint :ci_pipeline_id, null: false + + t.index :ci_pipeline_id, unique: true, name: :index_dast_profiles_pipelines_on_ci_pipeline_id + end + end + + def down + drop_table :dast_profiles_pipelines + end +end diff --git a/db/migrate/20210317100520_create_elastic_index_settings.rb b/db/migrate/20210317100520_create_elastic_index_settings.rb new file mode 100644 index 00000000000..61c1cbb3518 --- /dev/null +++ b/db/migrate/20210317100520_create_elastic_index_settings.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class CreateElasticIndexSettings < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + create_table_with_constraints :elastic_index_settings do |t| + t.timestamps_with_timezone null: false + t.integer :number_of_replicas, null: false, default: 1, limit: 2 + t.integer :number_of_shards, null: false, default: 5, limit: 2 + t.text :alias_name, null: false + + t.text_limit :alias_name, 255 + t.index :alias_name, unique: true + end + end + + def down + drop_table :elastic_index_settings + end +end diff --git a/db/migrate/20210317104301_create_in_product_marketing_emails.rb b/db/migrate/20210317104301_create_in_product_marketing_emails.rb new file mode 100644 index 00000000000..b8c6b952c97 --- /dev/null +++ b/db/migrate/20210317104301_create_in_product_marketing_emails.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class CreateInProductMarketingEmails < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + UNIQUE_INDEX_NAME = 'index_in_product_marketing_emails_on_user_track_series' + + disable_ddl_transaction! + + def up + with_lock_retries do + create_table :in_product_marketing_emails do |t| + t.bigint :user_id, null: false + t.datetime_with_timezone :cta_clicked_at + t.integer :track, null: false, limit: 2 + t.integer :series, null: false, limit: 2 + + t.timestamps_with_timezone + end + end + + add_index :in_product_marketing_emails, :user_id + add_index :in_product_marketing_emails, [:user_id, :track, :series], unique: true, name: UNIQUE_INDEX_NAME + end + + def down + with_lock_retries do + drop_table :in_product_marketing_emails + end + end +end diff --git a/db/migrate/20210317105904_add_user_foreign_key_to_in_product_marketing_emails.rb b/db/migrate/20210317105904_add_user_foreign_key_to_in_product_marketing_emails.rb new file mode 100644 index 00000000000..f0b4d97d2cf --- /dev/null +++ b/db/migrate/20210317105904_add_user_foreign_key_to_in_product_marketing_emails.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddUserForeignKeyToInProductMarketingEmails < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :in_product_marketing_emails, :users, column: :user_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :in_product_marketing_emails, column: :user_id + end + end +end diff --git a/db/migrate/20210317192943_add_expiry_notification_delivered_to_keys.rb b/db/migrate/20210317192943_add_expiry_notification_delivered_to_keys.rb new file mode 100644 index 00000000000..15f319b3965 --- /dev/null +++ b/db/migrate/20210317192943_add_expiry_notification_delivered_to_keys.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddExpiryNotificationDeliveredToKeys < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :keys, :expiry_notification_delivered_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20210318134427_delete_security_findings_without_uuid.rb b/db/migrate/20210318134427_delete_security_findings_without_uuid.rb new file mode 100644 index 00000000000..f8e0f0fb32b --- /dev/null +++ b/db/migrate/20210318134427_delete_security_findings_without_uuid.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class DeleteSecurityFindingsWithoutUuid < ActiveRecord::Migration[6.0] + DOWNTIME = false + + disable_ddl_transaction! + + class SecurityFinding < ActiveRecord::Base + include EachBatch + + self.table_name = 'security_findings' + + scope :without_uuid, -> { where(uuid: nil) } + end + + def up + SecurityFinding.without_uuid.each_batch(of: 10_000) do |relation| + relation.delete_all + end + end + + def down + # no-op + end +end diff --git a/db/migrate/20210322063407_add_dast_profile_id_fk_to_dast_profiles_pipelines.rb b/db/migrate/20210322063407_add_dast_profile_id_fk_to_dast_profiles_pipelines.rb new file mode 100644 index 00000000000..4e9b3ddd41c --- /dev/null +++ b/db/migrate/20210322063407_add_dast_profile_id_fk_to_dast_profiles_pipelines.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddDastProfileIdFkToDastProfilesPipelines < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :dast_profiles_pipelines, :dast_profiles, column: :dast_profile_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :dast_profiles_pipelines, column: :dast_profile_id + end + end +end diff --git a/db/migrate/20210322063450_add_ci_pipeline_id_fk_to_dast_profiles_pipelines.rb b/db/migrate/20210322063450_add_ci_pipeline_id_fk_to_dast_profiles_pipelines.rb new file mode 100644 index 00000000000..f1dce7f0cd8 --- /dev/null +++ b/db/migrate/20210322063450_add_ci_pipeline_id_fk_to_dast_profiles_pipelines.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddCiPipelineIdFkToDastProfilesPipelines < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :dast_profiles_pipelines, :ci_pipelines, column: :ci_pipeline_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :dast_profiles_pipelines, column: :ci_pipeline_id + end + end +end diff --git a/db/migrate/20210322182751_add_index_to_keys_on_expires_at_and_expiry_notification_undelivered.rb b/db/migrate/20210322182751_add_index_to_keys_on_expires_at_and_expiry_notification_undelivered.rb new file mode 100644 index 00000000000..6387d8a6a43 --- /dev/null +++ b/db/migrate/20210322182751_add_index_to_keys_on_expires_at_and_expiry_notification_undelivered.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIndexToKeysOnExpiresAtAndExpiryNotificationUndelivered < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_keys_on_expires_at_and_expiry_notification_undelivered' + disable_ddl_transaction! + + def up + add_concurrent_index :keys, + "date(timezone('UTC', expires_at)), expiry_notification_delivered_at", + where: 'expiry_notification_delivered_at IS NULL', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name(:keys, INDEX_NAME) + end +end diff --git a/db/migrate/20210323064751_add_namespace_traversal_ids_index.rb b/db/migrate/20210323064751_add_namespace_traversal_ids_index.rb new file mode 100644 index 00000000000..162173f6629 --- /dev/null +++ b/db/migrate/20210323064751_add_namespace_traversal_ids_index.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddNamespaceTraversalIdsIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_namespaces_on_traversal_ids' + + disable_ddl_transaction! + + def up + add_concurrent_index :namespaces, :traversal_ids, using: :gin, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :namespaces, INDEX_NAME + end +end diff --git a/db/migrate/20210323155010_populate_dismissal_information_for_vulnerabilities.rb b/db/migrate/20210323155010_populate_dismissal_information_for_vulnerabilities.rb new file mode 100644 index 00000000000..aee6d5484d5 --- /dev/null +++ b/db/migrate/20210323155010_populate_dismissal_information_for_vulnerabilities.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +class PopulateDismissalInformationForVulnerabilities < ActiveRecord::Migration[6.0] + DOWNTIME = false + BATCH_SIZE = 100 + UPDATE_QUERY = <<~SQL + UPDATE + vulnerabilities + SET + dismissed_at = COALESCE(dismissed_at, updated_at), + dismissed_by_id = COALESCE(dismissed_by_id, updated_by_id, last_edited_by_id, author_id) + WHERE + vulnerabilities.id IN (%{ids}) + SQL + + class Vulnerability < ActiveRecord::Base + include EachBatch + + self.table_name = 'vulnerabilities' + + enum state: { detected: 1, confirmed: 4, resolved: 3, dismissed: 2 } + + scope :broken, -> { dismissed.where('dismissed_at IS NULL OR dismissed_by_id IS NULL') } + end + + def up + Vulnerability.broken.each_batch(of: BATCH_SIZE) do |batch| + query = format(UPDATE_QUERY, ids: batch.select(:id).to_sql) + + connection.execute(query) + end + end + + def down + # no-op + end +end diff --git a/db/migrate/20210323182846_add_project_status_date_index_to_merge_requests.rb b/db/migrate/20210323182846_add_project_status_date_index_to_merge_requests.rb new file mode 100644 index 00000000000..1ec6bc0bf2e --- /dev/null +++ b/db/migrate/20210323182846_add_project_status_date_index_to_merge_requests.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddProjectStatusDateIndexToMergeRequests < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = "idx_mrs_on_target_id_and_created_at_and_state_id" + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, %i[target_project_id state_id created_at id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :merge_requests, INDEX_NAME + end +end diff --git a/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb b/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb new file mode 100644 index 00000000000..68ce5363b70 --- /dev/null +++ b/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb @@ -0,0 +1,28 @@ +# 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 AddIndexMirrorDataOnRetryNextExecutionWhereStatus < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + INDEX_NAME = 'index_mirror_data_non_scheduled_or_started' + + disable_ddl_transaction! + + def up + add_concurrent_index :project_mirror_data, + [:next_execution_timestamp, :retry_count], + where: "(status)::text <> ALL ('{scheduled,started}'::text[])", + name: INDEX_NAME + end + + def down + remove_concurrent_index :project_mirror_data, + [:next_execution_timestamp, :retry_count], + where: "(status)::text <> ALL ('{scheduled,started}'::text[])", + name: INDEX_NAME + end +end diff --git a/db/migrate/20210324131727_migrate_elastic_index_settings.rb b/db/migrate/20210324131727_migrate_elastic_index_settings.rb new file mode 100644 index 00000000000..4dcfc6cf952 --- /dev/null +++ b/db/migrate/20210324131727_migrate_elastic_index_settings.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class MigrateElasticIndexSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + ALIAS_NAME = [Rails.application.class.module_parent_name.downcase, Rails.env].join('-') + + class ElasticIndexSetting < ActiveRecord::Base + end + + class ApplicationSetting < ActiveRecord::Base + end + + def up + setting = ApplicationSetting.first + number_of_replicas = setting&.elasticsearch_replicas || 1 + number_of_shards = setting&.elasticsearch_shards || 5 + + return if ElasticIndexSetting.exists?(alias_name: ALIAS_NAME) + + ElasticIndexSetting.create!( + alias_name: ALIAS_NAME, + number_of_replicas: number_of_replicas, + number_of_shards: number_of_shards + ) + end + + def down + ElasticIndexSetting.where(alias_name: ALIAS_NAME).delete_all + end +end diff --git a/db/migrate/20210325092215_add_not_valid_foreign_key_to_group_hooks.rb b/db/migrate/20210325092215_add_not_valid_foreign_key_to_group_hooks.rb new file mode 100644 index 00000000000..2389f90d498 --- /dev/null +++ b/db/migrate/20210325092215_add_not_valid_foreign_key_to_group_hooks.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddNotValidForeignKeyToGroupHooks < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :web_hooks, :namespaces, column: :group_id, on_delete: :cascade, validate: false + end + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :web_hooks, column: :group_id + end + end +end diff --git a/db/migrate/20210325113129_validate_foreign_key_on_service_hooks.rb b/db/migrate/20210325113129_validate_foreign_key_on_service_hooks.rb new file mode 100644 index 00000000000..17dd4cad6ae --- /dev/null +++ b/db/migrate/20210325113129_validate_foreign_key_on_service_hooks.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class ValidateForeignKeyOnServiceHooks < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + CONSTRAINT_NAME = 'fk_d47999a98a' + + def up + validate_foreign_key :web_hooks, :service_id, name: CONSTRAINT_NAME + end + + def down + # no-op + end +end diff --git a/db/migrate/20210325150837_add_verification_state_to_ci_pipeline_artifact.rb b/db/migrate/20210325150837_add_verification_state_to_ci_pipeline_artifact.rb new file mode 100644 index 00000000000..f6c506e59b7 --- /dev/null +++ b/db/migrate/20210325150837_add_verification_state_to_ci_pipeline_artifact.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddVerificationStateToCiPipelineArtifact < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + change_table(:ci_pipeline_artifacts, bulk: true) do |t| + t.column :verification_started_at, :datetime_with_timezone + t.column :verification_retry_at, :datetime_with_timezone + t.column :verified_at, :datetime_with_timezone + 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 # rubocop:disable Migration/AddLimitToTextColumns + end + end +end diff --git a/db/migrate/20210325151758_add_verification_failure_limit_to_ci_pipeline_artifact.rb b/db/migrate/20210325151758_add_verification_failure_limit_to_ci_pipeline_artifact.rb new file mode 100644 index 00000000000..bc4dee2181f --- /dev/null +++ b/db/migrate/20210325151758_add_verification_failure_limit_to_ci_pipeline_artifact.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddVerificationFailureLimitToCiPipelineArtifact < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + CONSTRAINT_NAME = 'ci_pipeline_artifacts_verification_failure_text_limit' + + def up + add_text_limit :ci_pipeline_artifacts, :verification_failure, 255, constraint_name: CONSTRAINT_NAME + end + + def down + remove_check_constraint(:ci_pipeline_artifacts, CONSTRAINT_NAME) + end +end diff --git a/db/migrate/20210325152011_add_verification_indexes_to_ci_pipeline_artifacts.rb b/db/migrate/20210325152011_add_verification_indexes_to_ci_pipeline_artifacts.rb new file mode 100644 index 00000000000..0822aee35a4 --- /dev/null +++ b/db/migrate/20210325152011_add_verification_indexes_to_ci_pipeline_artifacts.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AddVerificationIndexesToCiPipelineArtifacts < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + VERIFICATION_STATE_INDEX_NAME = "index_ci_pipeline_artifacts_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_ci_pipeline_artifacts_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_ci_pipeline_artifacts_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_ci_pipeline_artifacts_needs_verification" + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipeline_artifacts, :verification_state, name: VERIFICATION_STATE_INDEX_NAME + add_concurrent_index :ci_pipeline_artifacts, :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME + add_concurrent_index :ci_pipeline_artifacts, :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME + add_concurrent_index :ci_pipeline_artifacts, :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ci_pipeline_artifacts, VERIFICATION_STATE_INDEX_NAME + remove_concurrent_index_by_name :ci_pipeline_artifacts, PENDING_VERIFICATION_INDEX_NAME + remove_concurrent_index_by_name :ci_pipeline_artifacts, FAILED_VERIFICATION_INDEX_NAME + remove_concurrent_index_by_name :ci_pipeline_artifacts, NEEDS_VERIFICATION_INDEX_NAME + end +end diff --git a/db/migrate/20210326035553_add_index_for_project_deployments_with_environment_id_and_updated_at.rb b/db/migrate/20210326035553_add_index_for_project_deployments_with_environment_id_and_updated_at.rb new file mode 100644 index 00000000000..d10c9401a31 --- /dev/null +++ b/db/migrate/20210326035553_add_index_for_project_deployments_with_environment_id_and_updated_at.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIndexForProjectDeploymentsWithEnvironmentIdAndUpdatedAt < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + INDEX_NAME = 'index_deployments_on_project_and_environment_and_updated_at' + + def up + add_concurrent_index :deployments, [:project_id, :environment_id, :updated_at], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :deployments, INDEX_NAME + end +end diff --git a/db/migrate/20210326190903_create_vulnerability_finding_evidences.rb b/db/migrate/20210326190903_create_vulnerability_finding_evidences.rb new file mode 100644 index 00000000000..4de02a6762e --- /dev/null +++ b/db/migrate/20210326190903_create_vulnerability_finding_evidences.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class CreateVulnerabilityFindingEvidences < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + create_table_with_constraints :vulnerability_finding_evidences do |t| + t.timestamps_with_timezone null: false + + t.references :vulnerability_occurrence, index: { name: 'finding_evidences_on_vulnerability_occurrence_id' }, null: false, foreign_key: { on_delete: :cascade } + t.text :summary + + t.text_limit :summary, 8_000_000 + end + end + + def down + with_lock_retries do + drop_table :vulnerability_finding_evidences + end + end +end diff --git a/db/migrate/20210329095548_add_target_project_and_source_branch_index_to_merge_request.rb b/db/migrate/20210329095548_add_target_project_and_source_branch_index_to_merge_request.rb new file mode 100644 index 00000000000..d351de6bd77 --- /dev/null +++ b/db/migrate/20210329095548_add_target_project_and_source_branch_index_to_merge_request.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddTargetProjectAndSourceBranchIndexToMergeRequest < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_merge_requests_on_target_project_id_and_source_branch' + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, [:target_project_id, :source_branch], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :epic_issues, INDEX_NAME + end +end diff --git a/db/migrate/20210329191850_add_finding_signature_table.rb b/db/migrate/20210329191850_add_finding_signature_table.rb new file mode 100644 index 00000000000..74a12d54a8e --- /dev/null +++ b/db/migrate/20210329191850_add_finding_signature_table.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class AddFindingSignatureTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + SIGNATURE_IDX = :idx_vuln_signatures_on_occurrences_id_and_signature_sha + UNIQ_IDX = :idx_vuln_signatures_uniqueness_signature_sha + + def up + with_lock_retries do + create_table :vulnerability_finding_signatures do |t| + t.references :finding, + index: true, + null: false, + foreign_key: { to_table: :vulnerability_occurrences, column: :finding_id, on_delete: :cascade } + + t.timestamps_with_timezone null: false + + t.integer :algorithm_type, null: false, limit: 2 + t.binary :signature_sha, null: false + + t.index %i[finding_id signature_sha], + name: SIGNATURE_IDX, + unique: true # only one link should exist between occurrence and the signature + + t.index %i[finding_id algorithm_type signature_sha], + name: UNIQ_IDX, + unique: true # these should be unique + end + end + end + + def down + with_lock_retries do + drop_table :vulnerability_finding_signatures + end + end +end diff --git a/db/migrate/20210329192716_add_composite_index_to_award_emoji.rb b/db/migrate/20210329192716_add_composite_index_to_award_emoji.rb new file mode 100644 index 00000000000..ce37afdbc29 --- /dev/null +++ b/db/migrate/20210329192716_add_composite_index_to_award_emoji.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddCompositeIndexToAwardEmoji < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'idx_award_emoji_on_user_emoji_name_awardable_type_awardable_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :award_emoji, %i[user_id name awardable_type awardable_id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :award_emoji, INDEX_NAME + end +end diff --git a/db/migrate/20210330015805_add_cloud_to_licenses.rb b/db/migrate/20210330015805_add_cloud_to_licenses.rb new file mode 100644 index 00000000000..d0c7112d0b0 --- /dev/null +++ b/db/migrate/20210330015805_add_cloud_to_licenses.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddCloudToLicenses < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :licenses, :cloud, :boolean, default: false + end +end diff --git a/db/migrate/20210331125111_add_default_target_project.rb b/db/migrate/20210331125111_add_default_target_project.rb new file mode 100644 index 00000000000..1a2c5ccca7d --- /dev/null +++ b/db/migrate/20210331125111_add_default_target_project.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddDefaultTargetProject < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + def up + with_lock_retries do + add_column :project_settings, :mr_default_target_self, :boolean, default: false, null: false + end + end + + def down + with_lock_retries do + remove_column :project_settings, :mr_default_target_self + end + end +end diff --git a/db/migrate/20210331145548_add_index_for_last_deployment.rb b/db/migrate/20210331145548_add_index_for_last_deployment.rb new file mode 100644 index 00000000000..a50d8ea403a --- /dev/null +++ b/db/migrate/20210331145548_add_index_for_last_deployment.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexForLastDeployment < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_deployments_on_environment_id_status_and_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :deployments, [:environment_id, :status, :id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :deployments, INDEX_NAME + end +end diff --git a/db/migrate/20210331180118_remove_deprecated_index_from_award_emoji.rb b/db/migrate/20210331180118_remove_deprecated_index_from_award_emoji.rb new file mode 100644 index 00000000000..b8787eb171c --- /dev/null +++ b/db/migrate/20210331180118_remove_deprecated_index_from_award_emoji.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class RemoveDeprecatedIndexFromAwardEmoji < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_award_emoji_on_user_id_and_name' + + disable_ddl_transaction! + + def up + # Index deprecated in favor of idx_award_emoji_on_user_emoji_name_awardable_type_awardable_id + remove_concurrent_index_by_name(:award_emoji, INDEX_NAME) + end + + def down + add_concurrent_index(:award_emoji, [:user_id, :name], name: INDEX_NAME) + end +end diff --git a/db/migrate/20210401134157_add_index_to_pages_deployments.rb b/db/migrate/20210401134157_add_index_to_pages_deployments.rb new file mode 100644 index 00000000000..aef27c7c6f9 --- /dev/null +++ b/db/migrate/20210401134157_add_index_to_pages_deployments.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToPagesDeployments < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + disable_ddl_transaction! + + INDEX_NAME = 'index_pages_deployments_on_file_store_and_id' + + def up + add_concurrent_index :pages_deployments, [:file_store, :id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :pages_deployments, INDEX_NAME + end +end diff --git a/db/migrate/20210401134455_remove_index_mirror_data_on_next_execution_and_retry_count.rb b/db/migrate/20210401134455_remove_index_mirror_data_on_next_execution_and_retry_count.rb new file mode 100644 index 00000000000..ee59e72e398 --- /dev/null +++ b/db/migrate/20210401134455_remove_index_mirror_data_on_next_execution_and_retry_count.rb @@ -0,0 +1,30 @@ +# 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 RemoveIndexMirrorDataOnNextExecutionAndRetryCount < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + DOWNTIME = false + + INDEX_NAME = 'index_mirror_data_on_next_execution_and_retry_count' + + def up + remove_concurrent_index( + :project_mirror_data, + %i[next_execution_timestamp retry_count], + name: INDEX_NAME + ) + end + + def down + add_concurrent_index( + :project_mirror_data, + %i[next_execution_timestamp retry_count], + name: INDEX_NAME + ) + end +end diff --git a/db/migrate/20210401175134_add_before_expiry_notification_delivered_to_keys.rb b/db/migrate/20210401175134_add_before_expiry_notification_delivered_to_keys.rb new file mode 100644 index 00000000000..6a2ea0e738c --- /dev/null +++ b/db/migrate/20210401175134_add_before_expiry_notification_delivered_to_keys.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddBeforeExpiryNotificationDeliveredToKeys < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :keys, :before_expiry_notification_delivered_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20210401192808_add_index_to_keys_on_expires_at_and_before_expiry_notification_undelivered.rb b/db/migrate/20210401192808_add_index_to_keys_on_expires_at_and_before_expiry_notification_undelivered.rb new file mode 100644 index 00000000000..ff792d2e6e6 --- /dev/null +++ b/db/migrate/20210401192808_add_index_to_keys_on_expires_at_and_before_expiry_notification_undelivered.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIndexToKeysOnExpiresAtAndBeforeExpiryNotificationUndelivered < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'idx_keys_expires_at_and_before_expiry_notification_undelivered' + disable_ddl_transaction! + + def up + add_concurrent_index :keys, + "date(timezone('UTC', expires_at)), before_expiry_notification_delivered_at", + where: 'before_expiry_notification_delivered_at IS NULL', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name(:keys, INDEX_NAME) + end +end diff --git a/db/migrate/20210406063442_create_namespaces_id_parent_id_partial_index.rb b/db/migrate/20210406063442_create_namespaces_id_parent_id_partial_index.rb new file mode 100644 index 00000000000..073d1ee2bc5 --- /dev/null +++ b/db/migrate/20210406063442_create_namespaces_id_parent_id_partial_index.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateNamespacesIdParentIdPartialIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + NAME = 'index_namespaces_id_parent_id_is_null' + + disable_ddl_transaction! + + def up + add_concurrent_index :namespaces, :id, where: 'parent_id IS NULL', name: NAME + end + + def down + remove_concurrent_index :namespaces, :id, name: NAME + end +end diff --git a/db/migrate/20210406140057_add_total_tuple_count_to_batched_migrations.rb b/db/migrate/20210406140057_add_total_tuple_count_to_batched_migrations.rb new file mode 100644 index 00000000000..32b5f27a577 --- /dev/null +++ b/db/migrate/20210406140057_add_total_tuple_count_to_batched_migrations.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTotalTupleCountToBatchedMigrations < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + add_column :batched_background_migrations, :total_tuple_count, :bigint + end + + def down + remove_column :batched_background_migrations, :total_tuple_count + end +end diff --git a/db/migrate/20210407002511_add_type_to_dast_site_profile.rb b/db/migrate/20210407002511_add_type_to_dast_site_profile.rb new file mode 100644 index 00000000000..99d9970a2a8 --- /dev/null +++ b/db/migrate/20210407002511_add_type_to_dast_site_profile.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddTypeToDastSiteProfile < ActiveRecord::Migration[6.0] + def change + add_column :dast_site_profiles, :target_type, :integer, limit: 2, default: 0, null: false + end +end diff --git a/db/migrate/20210409084242_create_index_on_notes_for_cherry_picked_merge_requests.rb b/db/migrate/20210409084242_create_index_on_notes_for_cherry_picked_merge_requests.rb new file mode 100644 index 00000000000..2bcdf4c8982 --- /dev/null +++ b/db/migrate/20210409084242_create_index_on_notes_for_cherry_picked_merge_requests.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateIndexOnNotesForCherryPickedMergeRequests < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + NAME = 'index_notes_for_cherry_picked_merge_requests' + + disable_ddl_transaction! + + def up + add_concurrent_index :notes, [:project_id, :commit_id], where: "((noteable_type)::text = 'MergeRequest'::text)", name: NAME + end + + def down + remove_concurrent_index_by_name :notes, name: NAME + end +end diff --git a/db/migrate/20210411212813_add_clusters_integrations_prometheus.rb b/db/migrate/20210411212813_add_clusters_integrations_prometheus.rb new file mode 100644 index 00000000000..7b7894fdcc8 --- /dev/null +++ b/db/migrate/20210411212813_add_clusters_integrations_prometheus.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddClustersIntegrationsPrometheus < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + def up + with_lock_retries do + create_table :clusters_integration_prometheus, id: false do |t| + t.timestamps_with_timezone null: false + t.references :cluster, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade } + t.boolean :enabled, null: false, default: false + end + end + end + + def down + with_lock_retries do + drop_table :clusters_integration_prometheus + end + end +end diff --git a/db/migrate/20210412132736_add_instance_url_to_jira_connect_installations.rb b/db/migrate/20210412132736_add_instance_url_to_jira_connect_installations.rb new file mode 100644 index 00000000000..78b5e7d5d35 --- /dev/null +++ b/db/migrate/20210412132736_add_instance_url_to_jira_connect_installations.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddInstanceUrlToJiraConnectInstallations < ActiveRecord::Migration[6.0] + DOWNTIME = false + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in db/migrate/20210216163811_add_text_limit_to_jira_connect_installations_instance_url.rb + def up + add_column :jira_connect_installations, :instance_url, :text + end + # rubocop:enable Migration/AddLimitToTextColumns + + def down + remove_column :jira_connect_installations, :instance_url + end +end diff --git a/db/migrate/20210412132824_add_text_limit_to_jira_connect_installations_instance_url.rb b/db/migrate/20210412132824_add_text_limit_to_jira_connect_installations_instance_url.rb new file mode 100644 index 00000000000..22c82ccd223 --- /dev/null +++ b/db/migrate/20210412132824_add_text_limit_to_jira_connect_installations_instance_url.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddTextLimitToJiraConnectInstallationsInstanceUrl < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_text_limit :jira_connect_installations, :instance_url, 255 + end + + def down + remove_text_limit :jira_connect_installations, :instance_url + end +end diff --git a/db/migrate/20210412142223_add_user_index_on_spam_logs.rb b/db/migrate/20210412142223_add_user_index_on_spam_logs.rb new file mode 100644 index 00000000000..0a12f0f1a87 --- /dev/null +++ b/db/migrate/20210412142223_add_user_index_on_spam_logs.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddUserIndexOnSpamLogs < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + INDEX_NAME = 'index_spam_logs_on_user_id' + + def up + add_concurrent_index :spam_logs, :user_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :spam_logs, INDEX_NAME + end +end diff --git a/db/migrate/20210413121101_add_created_at_web_hook_id_index_to_partitioned_web_hook_log.rb b/db/migrate/20210413121101_add_created_at_web_hook_id_index_to_partitioned_web_hook_log.rb new file mode 100644 index 00000000000..344f4859b47 --- /dev/null +++ b/db/migrate/20210413121101_add_created_at_web_hook_id_index_to_partitioned_web_hook_log.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddCreatedAtWebHookIdIndexToPartitionedWebHookLog < ActiveRecord::Migration[6.0] + include Gitlab::Database::PartitioningMigrationHelpers + + DOWNTIME = false + + CREATED_AT_WEB_HOOK_ID_INDEX_NAME = 'index_web_hook_logs_part_on_created_at_and_web_hook_id' + + disable_ddl_transaction! + + def up + add_concurrent_partitioned_index :web_hook_logs_part_0c5294f417, + [:created_at, :web_hook_id], + name: CREATED_AT_WEB_HOOK_ID_INDEX_NAME + end + + def down + remove_concurrent_partitioned_index_by_name :web_hook_logs_part_0c5294f417, CREATED_AT_WEB_HOOK_ID_INDEX_NAME + end +end diff --git a/db/migrate/20210413123832_add_index_on_web_hook_id_to_partitioned_web_hook_log.rb b/db/migrate/20210413123832_add_index_on_web_hook_id_to_partitioned_web_hook_log.rb new file mode 100644 index 00000000000..300c19d3e51 --- /dev/null +++ b/db/migrate/20210413123832_add_index_on_web_hook_id_to_partitioned_web_hook_log.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexOnWebHookIdToPartitionedWebHookLog < ActiveRecord::Migration[6.0] + include Gitlab::Database::PartitioningMigrationHelpers + + DOWNTIME = false + + WEB_HOOK_ID_INDEX_NAME = 'index_web_hook_logs_part_on_web_hook_id' + + disable_ddl_transaction! + + def up + add_concurrent_partitioned_index :web_hook_logs_part_0c5294f417, + :web_hook_id, + name: WEB_HOOK_ID_INDEX_NAME + end + + def down + remove_concurrent_partitioned_index_by_name :web_hook_logs_part_0c5294f417, WEB_HOOK_ID_INDEX_NAME + end +end diff --git a/db/migrate/20210414095944_add_index_services_on_project_and_type_where_inherit_null.rb b/db/migrate/20210414095944_add_index_services_on_project_and_type_where_inherit_null.rb new file mode 100644 index 00000000000..395742318e2 --- /dev/null +++ b/db/migrate/20210414095944_add_index_services_on_project_and_type_where_inherit_null.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexServicesOnProjectAndTypeWhereInheritNull < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + INDEX_NAME = 'index_services_on_project_and_type_where_inherit_null' + + def up + add_concurrent_index(:services, [:project_id, :type], where: 'inherit_from_id IS NULL', name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(:services, INDEX_NAME) + end +end diff --git a/db/migrate/20210414131600_add_external_pipeline_validation_to_application_setting.rb b/db/migrate/20210414131600_add_external_pipeline_validation_to_application_setting.rb new file mode 100644 index 00000000000..537f7727691 --- /dev/null +++ b/db/migrate/20210414131600_add_external_pipeline_validation_to_application_setting.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddExternalPipelineValidationToApplicationSetting < ActiveRecord::Migration[6.0] + def up + add_column :application_settings, :external_pipeline_validation_service_timeout, :integer + # rubocop:disable Migration/AddLimitToTextColumns + add_column :application_settings, :encrypted_external_pipeline_validation_service_token, :text + add_column :application_settings, :encrypted_external_pipeline_validation_service_token_iv, :text + add_column :application_settings, :external_pipeline_validation_service_url, :text + # rubocop:enable Migration/AddLimitToTextColumns + end + + def down + remove_column :application_settings, :external_pipeline_validation_service_timeout + remove_column :application_settings, :encrypted_external_pipeline_validation_service_token + remove_column :application_settings, :encrypted_external_pipeline_validation_service_token_iv + remove_column :application_settings, :external_pipeline_validation_service_url + end +end diff --git a/db/migrate/20210415142700_add_url_limit_to_pipeline_validation.rb b/db/migrate/20210415142700_add_url_limit_to_pipeline_validation.rb new file mode 100644 index 00000000000..9c38e04a96b --- /dev/null +++ b/db/migrate/20210415142700_add_url_limit_to_pipeline_validation.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddUrlLimitToPipelineValidation < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + CONSTRAINT_NAME = 'app_settings_ext_pipeline_validation_service_url_text_limit' + + def up + add_text_limit :application_settings, :external_pipeline_validation_service_url, 255, constraint_name: CONSTRAINT_NAME + end + + def down + remove_check_constraint(:application_settings, CONSTRAINT_NAME) + end +end diff --git a/db/migrate/20210415144538_remove_index_epics_on_group_id_from_epics.rb b/db/migrate/20210415144538_remove_index_epics_on_group_id_from_epics.rb new file mode 100644 index 00000000000..f691af4d8d2 --- /dev/null +++ b/db/migrate/20210415144538_remove_index_epics_on_group_id_from_epics.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveIndexEpicsOnGroupIdFromEpics < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + INDEX_NAME = 'index_epics_on_group_id' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :epics, INDEX_NAME + end + + def down + add_concurrent_index :epics, :group_id, name: INDEX_NAME + end +end |