diff options
Diffstat (limited to 'db/migrate')
295 files changed, 1587 insertions, 4036 deletions
diff --git a/db/migrate/20210603140302_add_pronouns_to_user_details.rb b/db/migrate/20210603140302_add_pronouns_to_user_details.rb deleted file mode 100644 index f28d45bdf6f..00000000000 --- a/db/migrate/20210603140302_add_pronouns_to_user_details.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddPronounsToUserDetails < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210607050531_add_text_limit_to_user_details_pronouns - with_lock_retries do - add_column :user_details, :pronouns, :text, null: true - end - # rubocop:enable Migration/AddLimitToTextColumns - end - - def down - with_lock_retries do - remove_column :user_details, :pronouns - end - end -end diff --git a/db/migrate/20210603222333_remove_builds_email_service_from_services.rb b/db/migrate/20210603222333_remove_builds_email_service_from_services.rb deleted file mode 100644 index 791b8b659af..00000000000 --- a/db/migrate/20210603222333_remove_builds_email_service_from_services.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveBuildsEmailServiceFromServices < ActiveRecord::Migration[6.1] - def up - execute("DELETE from services WHERE type = 'BuildsEmailService'") - end - - def down - # no-op - end -end diff --git a/db/migrate/20210604032738_create_dast_site_profiles_builds.rb b/db/migrate/20210604032738_create_dast_site_profiles_builds.rb deleted file mode 100644 index 6e653b36787..00000000000 --- a/db/migrate/20210604032738_create_dast_site_profiles_builds.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateDastSiteProfilesBuilds < ActiveRecord::Migration[6.1] - def up - table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Site Profiles and CI Builds' } - - create_table :dast_site_profiles_builds, primary_key: [:dast_site_profile_id, :ci_build_id], comment: Gitlab::Json.dump(table_comment) do |t| - t.bigint :dast_site_profile_id, null: false - t.bigint :ci_build_id, null: false - - t.index :ci_build_id, unique: true, name: :dast_site_profiles_builds_on_ci_build_id - end - end - - def down - drop_table :dast_site_profiles_builds - end -end diff --git a/db/migrate/20210604034158_add_ci_build_id_fk_to_dast_site_profiles_builds.rb b/db/migrate/20210604034158_add_ci_build_id_fk_to_dast_site_profiles_builds.rb deleted file mode 100644 index 6908da69e08..00000000000 --- a/db/migrate/20210604034158_add_ci_build_id_fk_to_dast_site_profiles_builds.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddCiBuildIdFkToDastSiteProfilesBuilds < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_site_profiles_builds, :ci_builds, column: :ci_build_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :dast_site_profiles_builds, column: :ci_build_id - end - end -end diff --git a/db/migrate/20210604034354_add_dast_site_profile_id_fk_to_dast_site_profiles_builds.rb b/db/migrate/20210604034354_add_dast_site_profile_id_fk_to_dast_site_profiles_builds.rb deleted file mode 100644 index 58fe3090a4f..00000000000 --- a/db/migrate/20210604034354_add_dast_site_profile_id_fk_to_dast_site_profiles_builds.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddDastSiteProfileIdFkToDastSiteProfilesBuilds < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_site_profiles_builds, :dast_site_profiles, column: :dast_site_profile_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :dast_site_profiles_builds, column: :dast_site_profile_id - end - end -end diff --git a/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb b/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb deleted file mode 100644 index 0fe3ada4c0d..00000000000 --- a/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateDastScannerProfilesBuilds < ActiveRecord::Migration[6.1] - def up - table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Scanner Profiles and CI Builds' } - - create_table :dast_scanner_profiles_builds, primary_key: [:dast_scanner_profile_id, :ci_build_id], comment: Gitlab::Json.dump(table_comment) do |t| - t.bigint :dast_scanner_profile_id, null: false - t.bigint :ci_build_id, null: false - - t.index :ci_build_id, unique: true, name: :dast_scanner_profiles_builds_on_ci_build_id - end - end - - def down - drop_table :dast_scanner_profiles_builds - end -end diff --git a/db/migrate/20210604051742_add_ci_build_id_fk_to_dast_scanner_profiles_builds.rb b/db/migrate/20210604051742_add_ci_build_id_fk_to_dast_scanner_profiles_builds.rb deleted file mode 100644 index cc495c749c5..00000000000 --- a/db/migrate/20210604051742_add_ci_build_id_fk_to_dast_scanner_profiles_builds.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddCiBuildIdFkToDastScannerProfilesBuilds < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_scanner_profiles_builds, :ci_builds, column: :ci_build_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :dast_scanner_profiles_builds, column: :ci_build_id - end - end -end diff --git a/db/migrate/20210604051917_add_dast_scanner_profile_id_fk_to_dast_scanner_profiles_builds.rb b/db/migrate/20210604051917_add_dast_scanner_profile_id_fk_to_dast_scanner_profiles_builds.rb deleted file mode 100644 index 0c14c798da4..00000000000 --- a/db/migrate/20210604051917_add_dast_scanner_profile_id_fk_to_dast_scanner_profiles_builds.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddDastScannerProfileIdFkToDastScannerProfilesBuilds < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_scanner_profiles_builds, :dast_scanner_profiles, column: :dast_scanner_profile_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :dast_scanner_profiles_builds, column: :dast_scanner_profile_id - end - end -end diff --git a/db/migrate/20210604082145_create_external_status_checks_table.rb b/db/migrate/20210604082145_create_external_status_checks_table.rb deleted file mode 100644 index c1ad3df6c9e..00000000000 --- a/db/migrate/20210604082145_create_external_status_checks_table.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -class CreateExternalStatusChecksTable < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - create_table_with_constraints :external_status_checks, if_not_exists: true do |t| - t.references :project, foreign_key: { on_delete: :cascade }, null: false, index: false - t.timestamps_with_timezone - t.text :external_url, null: false - t.text_limit :external_url, 255 - t.text :name, null: false - t.text_limit :name, 255 - - t.index([:project_id, :name], - unique: true, - name: 'idx_on_external_status_checks_project_id_name') - t.index([:project_id, :external_url], - unique: true, - name: 'idx_on_external_status_checks_project_id_external_url') - end - - create_table :external_status_checks_protected_branches do |t| - t.bigint :external_status_check_id, null: false - t.bigint :protected_branch_id, null: false - - t.index :external_status_check_id, name: 'index_esc_protected_branches_on_external_status_check_id' - t.index :protected_branch_id, name: 'index_esc_protected_branches_on_protected_branch_id' - end - end - - def down - with_lock_retries do - drop_table :external_status_checks_protected_branches, force: :cascade, if_exists: true - end - - with_lock_retries do - drop_table :external_status_checks, force: :cascade, if_exists: true - end - end -end diff --git a/db/migrate/20210604085600_rename_status_check_responses_approval_rule.rb b/db/migrate/20210604085600_rename_status_check_responses_approval_rule.rb deleted file mode 100644 index a12aef9455d..00000000000 --- a/db/migrate/20210604085600_rename_status_check_responses_approval_rule.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true -class RenameStatusCheckResponsesApprovalRule < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - execute('DELETE FROM status_check_responses') - - unless column_exists?(:status_check_responses, :external_status_check_id) - add_column :status_check_responses, :external_status_check_id, :bigint, null: false # rubocop:disable Rails/NotNullColumn - end - - add_concurrent_foreign_key :status_check_responses, :external_status_checks, column: :external_status_check_id, on_delete: :cascade - add_concurrent_foreign_key :status_check_responses, :merge_requests, column: :merge_request_id, on_delete: :cascade - - add_concurrent_index :status_check_responses, :external_status_check_id - - # Setting this to true so that we can remove the column in a future release once the column has been removed. It has been ignored in 14.0 - change_column_null :status_check_responses, :external_approval_rule_id, true - - with_lock_retries do - remove_foreign_key :status_check_responses, :external_approval_rules - end - end - - def down - change_column_null :status_check_responses, :external_approval_rule_id, false - with_lock_retries do - add_foreign_key :status_check_responses, :external_approval_rules - end - remove_column :status_check_responses, :external_status_check_id - end -end diff --git a/db/migrate/20210607050531_add_text_limit_to_user_details_pronouns.rb b/db/migrate/20210607050531_add_text_limit_to_user_details_pronouns.rb deleted file mode 100644 index 41c543e5deb..00000000000 --- a/db/migrate/20210607050531_add_text_limit_to_user_details_pronouns.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToUserDetailsPronouns < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_text_limit :user_details, :pronouns, 50 - end - - def down - remove_text_limit :user_details, :pronouns - end -end diff --git a/db/migrate/20210607080044_remove_temporary_index_on_security_findings_scan_id.rb b/db/migrate/20210607080044_remove_temporary_index_on_security_findings_scan_id.rb deleted file mode 100644 index 5357059f475..00000000000 --- a/db/migrate/20210607080044_remove_temporary_index_on_security_findings_scan_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveTemporaryIndexOnSecurityFindingsScanId < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'tmp_index_on_security_findings_scan_id' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :security_findings, INDEX_NAME - end - - def down - add_concurrent_index :security_findings, :scan_id, where: 'uuid is null', name: INDEX_NAME - end -end diff --git a/db/migrate/20210607154719_add_job_token_scope_enabled_to_ci_cd_settings.rb b/db/migrate/20210607154719_add_job_token_scope_enabled_to_ci_cd_settings.rb deleted file mode 100644 index 20b9e8d95ee..00000000000 --- a/db/migrate/20210607154719_add_job_token_scope_enabled_to_ci_cd_settings.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddJobTokenScopeEnabledToCiCdSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :project_ci_cd_settings, :job_token_scope_enabled, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :project_ci_cd_settings, :job_token_scope_enabled - end - end -end diff --git a/db/migrate/20210608103230_add_issue_id_to_test_report.rb b/db/migrate/20210608103230_add_issue_id_to_test_report.rb deleted file mode 100644 index f4e723d0af8..00000000000 --- a/db/migrate/20210608103230_add_issue_id_to_test_report.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIssueIdToTestReport < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :requirements_management_test_reports, :issue_id, :bigint, null: true - end - end - - def down - with_lock_retries do - remove_column :requirements_management_test_reports, :issue_id - end - end -end diff --git a/db/migrate/20210608103235_add_issue_index_to_test_report.rb b/db/migrate/20210608103235_add_issue_index_to_test_report.rb deleted file mode 100644 index 41f1970b2a9..00000000000 --- a/db/migrate/20210608103235_add_issue_index_to_test_report.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIssueIndexToTestReport < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_requirements_management_test_reports_on_issue_id' - - def up - add_concurrent_index :requirements_management_test_reports, :issue_id, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :requirements_management_test_reports, INDEX_NAME - end -end diff --git a/db/migrate/20210608110752_change_column_null_test_report_requirement.rb b/db/migrate/20210608110752_change_column_null_test_report_requirement.rb deleted file mode 100644 index 44a614a34ce..00000000000 --- a/db/migrate/20210608110752_change_column_null_test_report_requirement.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ChangeColumnNullTestReportRequirement < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - TARGET_TABLE = :requirements_management_test_reports - - def up - with_lock_retries do - change_column_null TARGET_TABLE, :requirement_id, true - end - end - - def down - # no-op as it's difficult to revert - end -end diff --git a/db/migrate/20210608110760_add_requirement_test_reports_foreign_key.rb b/db/migrate/20210608110760_add_requirement_test_reports_foreign_key.rb deleted file mode 100644 index e256bce6ae0..00000000000 --- a/db/migrate/20210608110760_add_requirement_test_reports_foreign_key.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddRequirementTestReportsForeignKey < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - TARGET_TABLE = :requirements_management_test_reports - CONSTRAINT_NAME = 'requirements_test_reports_requirement_id_xor_issue_id' - - def up - add_concurrent_foreign_key TARGET_TABLE, :issues, column: :issue_id - - add_check_constraint(TARGET_TABLE, 'num_nonnulls(requirement_id, issue_id) = 1', CONSTRAINT_NAME) - end - - def down - remove_check_constraint TARGET_TABLE, CONSTRAINT_NAME - - with_lock_retries do - remove_foreign_key_if_exists(TARGET_TABLE, column: :issue_id) - end - end -end diff --git a/db/migrate/20210609013512_add_unique_index_for_batched_background_migrations.rb b/db/migrate/20210609013512_add_unique_index_for_batched_background_migrations.rb deleted file mode 100644 index 28214aedce6..00000000000 --- a/db/migrate/20210609013512_add_unique_index_for_batched_background_migrations.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexForBatchedBackgroundMigrations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - TABLE_NAME = :batched_background_migrations - INDEX_NAME = 'index_batched_background_migrations_on_unique_configuration' - REDUNDANT_INDEX_NAME = 'index_batched_migrations_on_job_table_and_column_name' - - def up - add_concurrent_index TABLE_NAME, - %i[job_class_name table_name column_name job_arguments], - unique: true, - name: INDEX_NAME - - remove_concurrent_index_by_name TABLE_NAME, REDUNDANT_INDEX_NAME - end - - def down - add_concurrent_index TABLE_NAME, - %i[job_class_name table_name column_name], - name: REDUNDANT_INDEX_NAME - - remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME - end -end diff --git a/db/migrate/20210609090856_add_expiry_id_ssh_key_notification_index.rb b/db/migrate/20210609090856_add_expiry_id_ssh_key_notification_index.rb deleted file mode 100644 index 406bbe2095f..00000000000 --- a/db/migrate/20210609090856_add_expiry_id_ssh_key_notification_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddExpiryIdSshKeyNotificationIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_keys_on_expires_at_and_id' - - def up - add_concurrent_index :keys, - "date(timezone('UTC', expires_at)), id", - 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/20210609192728_add_status_check_foreign_key_to_external_status_check_id.rb b/db/migrate/20210609192728_add_status_check_foreign_key_to_external_status_check_id.rb deleted file mode 100644 index 461d5838aed..00000000000 --- a/db/migrate/20210609192728_add_status_check_foreign_key_to_external_status_check_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddStatusCheckForeignKeyToExternalStatusCheckId < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :external_status_checks_protected_branches, :external_status_checks, column: :external_status_check_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :external_status_checks_protected_branches, column: :external_status_check_id - end - end -end diff --git a/db/migrate/20210609193101_add_status_check_foreign_key_to_protected_branch_id.rb b/db/migrate/20210609193101_add_status_check_foreign_key_to_protected_branch_id.rb deleted file mode 100644 index 6eeee60ec3a..00000000000 --- a/db/migrate/20210609193101_add_status_check_foreign_key_to_protected_branch_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddStatusCheckForeignKeyToProtectedBranchId < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :external_status_checks_protected_branches, :protected_branches, column: :protected_branch_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :external_status_checks_protected_branches, column: :protected_branch_id - end - end -end diff --git a/db/migrate/20210610102410_add_protected_attribute_to_pending_builds.rb b/db/migrate/20210610102410_add_protected_attribute_to_pending_builds.rb deleted file mode 100644 index 026fa0d7043..00000000000 --- a/db/migrate/20210610102410_add_protected_attribute_to_pending_builds.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddProtectedAttributeToPendingBuilds < ActiveRecord::Migration[6.1] - def change - add_column :ci_pending_builds, :protected, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20210610153556_delete_legacy_operations_feature_flags.rb b/db/migrate/20210610153556_delete_legacy_operations_feature_flags.rb deleted file mode 100644 index f0bcbe5e472..00000000000 --- a/db/migrate/20210610153556_delete_legacy_operations_feature_flags.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class DeleteLegacyOperationsFeatureFlags < ActiveRecord::Migration[6.1] - LEGACY_FEATURE_FLAG_VERSION = 1 - - def up - execute("DELETE FROM operations_feature_flags WHERE version = #{LEGACY_FEATURE_FLAG_VERSION}") - end - - def down - # no-op - end -end diff --git a/db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb b/db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb deleted file mode 100644 index ef2177fa9ce..00000000000 --- a/db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddPagesFileEntriesToPlanLimits < ActiveRecord::Migration[6.1] - def change - add_column(:plan_limits, :pages_file_entries, :integer, default: 200_000, null: false) - end -end diff --git a/db/migrate/20210611100359_rebuild_index_for_cadence_iterations_automation.rb b/db/migrate/20210611100359_rebuild_index_for_cadence_iterations_automation.rb deleted file mode 100644 index ecd8bac22be..00000000000 --- a/db/migrate/20210611100359_rebuild_index_for_cadence_iterations_automation.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -class RebuildIndexForCadenceIterationsAutomation < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'cadence_create_iterations_automation' - - disable_ddl_transaction! - - def up - return if index_exists_and_is_valid? - - remove_concurrent_index_by_name :iterations_cadences, INDEX_NAME - - disable_statement_timeout do - execute( - <<-SQL - CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON iterations_cadences - USING BTREE(automatic, duration_in_weeks, (DATE ((COALESCE("iterations_cadences"."last_run_date", DATE('01-01-1970')) + "iterations_cadences"."duration_in_weeks" * INTERVAL '1 week')))) - WHERE duration_in_weeks IS NOT NULL - SQL - ) - end - end - - def down - remove_concurrent_index_by_name :iterations_cadences, INDEX_NAME - end - - def index_exists_and_is_valid? - execute( - <<-SQL - SELECT identifier - FROM postgres_indexes - WHERE identifier LIKE '%#{INDEX_NAME}' AND valid_index=TRUE - SQL - ).any? - end -end diff --git a/db/migrate/20210611101034_add_devops_adoption_sast_dast.rb b/db/migrate/20210611101034_add_devops_adoption_sast_dast.rb deleted file mode 100644 index 0a9eb64a5fc..00000000000 --- a/db/migrate/20210611101034_add_devops_adoption_sast_dast.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionSastDast < ActiveRecord::Migration[6.1] - def change - add_column :analytics_devops_adoption_snapshots, :sast_enabled_count, :integer - add_column :analytics_devops_adoption_snapshots, :dast_enabled_count, :integer - end -end diff --git a/db/migrate/20210614131002_add_detection_method_to_vulnerabilities_finding.rb b/db/migrate/20210614131002_add_detection_method_to_vulnerabilities_finding.rb deleted file mode 100644 index cc37c5f1020..00000000000 --- a/db/migrate/20210614131002_add_detection_method_to_vulnerabilities_finding.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddDetectionMethodToVulnerabilitiesFinding < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :vulnerability_occurrences, :detection_method, :smallint, null: false, default: 0 - end - end - - def down - with_lock_retries do - remove_column :vulnerability_occurrences, :detection_method - end - end -end diff --git a/db/migrate/20210614142311_add_running_container_scanning_max_size_to_plan_limits.rb b/db/migrate/20210614142311_add_running_container_scanning_max_size_to_plan_limits.rb deleted file mode 100644 index 248fff6c42f..00000000000 --- a/db/migrate/20210614142311_add_running_container_scanning_max_size_to_plan_limits.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddRunningContainerScanningMaxSizeToPlanLimits < ActiveRecord::Migration[6.0] - def change - add_column :plan_limits, :ci_max_artifact_size_running_container_scanning, :integer, null: false, default: 0 - end -end diff --git a/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb b/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb deleted file mode 100644 index e6b7ba7616d..00000000000 --- a/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexForHelmPackages < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_helm' - PACKAGE_TYPE_HELM = 11 - - disable_ddl_transaction! - - def up - add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, where: "package_type = #{PACKAGE_TYPE_HELM}", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_packages, INDEX_NAME - end -end diff --git a/db/migrate/20210615064342_add_issue_id_to_requirement.rb b/db/migrate/20210615064342_add_issue_id_to_requirement.rb deleted file mode 100644 index a6d85bd9d6e..00000000000 --- a/db/migrate/20210615064342_add_issue_id_to_requirement.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIssueIdToRequirement < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :requirements, :issue_id, :bigint, null: true - end - end - - def down - with_lock_retries do - remove_column :requirements, :issue_id - end - end -end diff --git a/db/migrate/20210616110748_add_issue_index_to_requirement.rb b/db/migrate/20210616110748_add_issue_index_to_requirement.rb deleted file mode 100644 index 747ee3875dc..00000000000 --- a/db/migrate/20210616110748_add_issue_index_to_requirement.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIssueIndexToRequirement < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_requirements_on_issue_id' - - def up - add_concurrent_index :requirements, :issue_id, name: INDEX_NAME, unique: true - end - - def down - remove_concurrent_index_by_name :requirements, INDEX_NAME - end -end diff --git a/db/migrate/20210616111311_add_issue_requirement_foreign_key.rb b/db/migrate/20210616111311_add_issue_requirement_foreign_key.rb deleted file mode 100644 index ed851da9f31..00000000000 --- a/db/migrate/20210616111311_add_issue_requirement_foreign_key.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddIssueRequirementForeignKey < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - TARGET_TABLE = :requirements - - def up - add_concurrent_foreign_key TARGET_TABLE, :issues, column: :issue_id - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(TARGET_TABLE, column: :issue_id) - end - end -end diff --git a/db/migrate/20210616134905_add_timestamp_to_schema_migration.rb b/db/migrate/20210616134905_add_timestamp_to_schema_migration.rb deleted file mode 100644 index 7086b20c48f..00000000000 --- a/db/migrate/20210616134905_add_timestamp_to_schema_migration.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTimestampToSchemaMigration < ActiveRecord::Migration[6.1] - def up - # Add a nullable column with default null first - add_column :schema_migrations, :finished_at, :timestamptz - - # Change default to NOW() for new records - change_column_default :schema_migrations, :finished_at, -> { 'NOW()' } - end - - def down - remove_column :schema_migrations, :finished_at - end -end diff --git a/db/migrate/20210616154808_remove_ci_build_protected_index.rb b/db/migrate/20210616154808_remove_ci_build_protected_index.rb deleted file mode 100644 index 25a8d159c1e..00000000000 --- a/db/migrate/20210616154808_remove_ci_build_protected_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class RemoveCiBuildProtectedIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - INDEX_NAME = 'index_ci_builds_on_protected' - - disable_ddl_transaction! - - def up - remove_concurrent_index :ci_builds, :protected, name: INDEX_NAME - end - - def down - add_concurrent_index :ci_builds, :protected, name: INDEX_NAME - end -end diff --git a/db/migrate/20210616185947_add_mailgun_settings_to_application_setting.rb b/db/migrate/20210616185947_add_mailgun_settings_to_application_setting.rb deleted file mode 100644 index 8447ff79d12..00000000000 --- a/db/migrate/20210616185947_add_mailgun_settings_to_application_setting.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddMailgunSettingsToApplicationSetting < ActiveRecord::Migration[6.1] - def change - add_column :application_settings, :encrypted_mailgun_signing_key, :binary - add_column :application_settings, :encrypted_mailgun_signing_key_iv, :binary - - add_column :application_settings, :mailgun_events_enabled, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210617022324_create_incident_management_pending_alert_escalations.rb b/db/migrate/20210617022324_create_incident_management_pending_alert_escalations.rb deleted file mode 100644 index 32249c9ed56..00000000000 --- a/db/migrate/20210617022324_create_incident_management_pending_alert_escalations.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -class CreateIncidentManagementPendingAlertEscalations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - execute(<<~SQL) - - CREATE TABLE incident_management_pending_alert_escalations ( - id bigserial NOT NULL, - rule_id bigint, - alert_id bigint NOT NULL, - schedule_id bigint NOT NULL, - process_at timestamp with time zone NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - status smallint NOT NULL, - PRIMARY KEY (id, process_at) - ) PARTITION BY RANGE (process_at); - - CREATE INDEX index_incident_management_pending_alert_escalations_on_alert_id - ON incident_management_pending_alert_escalations USING btree (alert_id); - - CREATE INDEX index_incident_management_pending_alert_escalations_on_rule_id - ON incident_management_pending_alert_escalations USING btree (rule_id); - - CREATE INDEX index_incident_management_pending_alert_escalations_on_schedule_id - ON incident_management_pending_alert_escalations USING btree (schedule_id); - - ALTER TABLE incident_management_pending_alert_escalations ADD CONSTRAINT fk_rails_fcbfd9338b - FOREIGN KEY (schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE; - - ALTER TABLE incident_management_pending_alert_escalations ADD CONSTRAINT fk_rails_057c1e3d87 - FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE SET NULL; - - ALTER TABLE incident_management_pending_alert_escalations ADD CONSTRAINT fk_rails_8d8de95da9 - FOREIGN KEY (alert_id) REFERENCES alert_management_alerts(id) ON DELETE CASCADE; - SQL - end - end - - def down - with_lock_retries do - drop_table :incident_management_pending_alert_escalations - end - end -end diff --git a/db/migrate/20210617161348_cascade_delete_freeze_periods.rb b/db/migrate/20210617161348_cascade_delete_freeze_periods.rb deleted file mode 100644 index 90623b27920..00000000000 --- a/db/migrate/20210617161348_cascade_delete_freeze_periods.rb +++ /dev/null @@ -1,23 +0,0 @@ -# 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 CascadeDeleteFreezePeriods < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - OLD_PROJECT_FK = 'fk_rails_2e02bbd1a6' - NEW_PROJECT_FK = 'fk_2e02bbd1a6' - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :ci_freeze_periods, :projects, column: :project_id, on_delete: :cascade, name: NEW_PROJECT_FK - remove_foreign_key_if_exists :ci_freeze_periods, :projects, column: :project_id, name: OLD_PROJECT_FK - end - - def down - add_concurrent_foreign_key :ci_freeze_periods, :projects, column: :project_id, on_delete: nil, name: OLD_PROJECT_FK - remove_foreign_key_if_exists :ci_freeze_periods, :projects, column: :project_id, name: NEW_PROJECT_FK - end -end diff --git a/db/migrate/20210617180131_migrate_usage_ping_sidekiq_queue.rb b/db/migrate/20210617180131_migrate_usage_ping_sidekiq_queue.rb deleted file mode 100644 index 9eebc6feb14..00000000000 --- a/db/migrate/20210617180131_migrate_usage_ping_sidekiq_queue.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class MigrateUsagePingSidekiqQueue < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - # rubocop:disable Migration/SidekiqQueueMigrate - def up - sidekiq_queue_migrate 'cronjob:gitlab_usage_ping', to: 'cronjob:gitlab_service_ping' - end - - def down - sidekiq_queue_migrate 'cronjob:gitlab_service_ping', to: 'cronjob:gitlab_usage_ping' - end - # rubocop:enable Migration/SidekiqQueueMigrate -end diff --git a/db/migrate/20210621043337_rename_services_to_integrations.rb b/db/migrate/20210621043337_rename_services_to_integrations.rb deleted file mode 100644 index 845c3c01a2a..00000000000 --- a/db/migrate/20210621043337_rename_services_to_integrations.rb +++ /dev/null @@ -1,151 +0,0 @@ -# frozen_string_literal: true - -class RenameServicesToIntegrations < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - enable_lock_retries! - - # Function and trigger names match those migrated in: - # - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49916 - # - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51852 - - WIKI_FUNCTION_NAME = 'set_has_external_wiki' - TRACKER_FUNCTION_NAME = 'set_has_external_issue_tracker' - - WIKI_TRIGGER_ON_INSERT_NAME = 'trigger_has_external_wiki_on_insert' - WIKI_TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_wiki_on_update' - WIKI_TRIGGER_ON_DELETE_NAME = 'trigger_has_external_wiki_on_delete' - - TRACKER_TRIGGER_ON_INSERT_NAME = 'trigger_has_external_issue_tracker_on_insert' - TRACKER_TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_issue_tracker_on_update' - TRACKER_TRIGGER_ON_DELETE_NAME = 'trigger_has_external_issue_tracker_on_delete' - - ALL_TRIGGERS = [ - WIKI_TRIGGER_ON_INSERT_NAME, - WIKI_TRIGGER_ON_UPDATE_NAME, - WIKI_TRIGGER_ON_DELETE_NAME, - TRACKER_TRIGGER_ON_INSERT_NAME, - TRACKER_TRIGGER_ON_UPDATE_NAME, - TRACKER_TRIGGER_ON_DELETE_NAME - ].freeze - - def up - execute('LOCK services IN ACCESS EXCLUSIVE MODE') - - drop_all_triggers(:services) - - rename_table_safely(:services, :integrations) - - recreate_all_triggers(:integrations) - end - - def down - execute('LOCK integrations IN ACCESS EXCLUSIVE MODE') - - drop_all_triggers(:integrations) - - undo_rename_table_safely(:services, :integrations) - - recreate_all_triggers(:services) - end - - private - - def drop_all_triggers(table_name) - ALL_TRIGGERS.each do |trigger_name| - drop_trigger(table_name, trigger_name) - end - end - - def recreate_all_triggers(table_name) - wiki_create_insert_trigger(table_name) - wiki_create_update_trigger(table_name) - wiki_create_delete_trigger(table_name) - - tracker_replace_trigger_function(table_name) - - tracker_create_insert_trigger(table_name) - tracker_create_update_trigger(table_name) - tracker_create_delete_trigger(table_name) - end - - def wiki_create_insert_trigger(table_name) - execute(<<~SQL) - CREATE TRIGGER #{WIKI_TRIGGER_ON_INSERT_NAME} - AFTER INSERT ON #{table_name} - FOR EACH ROW - WHEN (NEW.active = TRUE AND NEW.type = 'ExternalWikiService' AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{WIKI_FUNCTION_NAME}(); - SQL - end - - def wiki_create_update_trigger(table_name) - execute(<<~SQL) - CREATE TRIGGER #{WIKI_TRIGGER_ON_UPDATE_NAME} - AFTER UPDATE ON #{table_name} - FOR EACH ROW - WHEN (NEW.type = 'ExternalWikiService' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{WIKI_FUNCTION_NAME}(); - SQL - end - - def wiki_create_delete_trigger(table_name) - execute(<<~SQL) - CREATE TRIGGER #{WIKI_TRIGGER_ON_DELETE_NAME} - AFTER DELETE ON #{table_name} - FOR EACH ROW - WHEN (OLD.type = 'ExternalWikiService' AND OLD.project_id IS NOT NULL) - EXECUTE FUNCTION #{WIKI_FUNCTION_NAME}(); - SQL - end - - # Using `replace: true` to rewrite the existing function - def tracker_replace_trigger_function(table_name) - create_trigger_function(TRACKER_FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE projects SET has_external_issue_tracker = ( - EXISTS - ( - SELECT 1 - FROM #{table_name} - WHERE project_id = COALESCE(NEW.project_id, OLD.project_id) - AND active = TRUE - AND category = 'issue_tracker' - ) - ) - WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id); - RETURN NULL; - SQL - end - end - - def tracker_create_insert_trigger(table_name) - execute(<<~SQL) - CREATE TRIGGER #{TRACKER_TRIGGER_ON_INSERT_NAME} - AFTER INSERT ON #{table_name} - FOR EACH ROW - WHEN (NEW.category = 'issue_tracker' AND NEW.active = TRUE AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{TRACKER_FUNCTION_NAME}(); - SQL - end - - def tracker_create_update_trigger(table_name) - execute(<<~SQL) - CREATE TRIGGER #{TRACKER_TRIGGER_ON_UPDATE_NAME} - AFTER UPDATE ON #{table_name} - FOR EACH ROW - WHEN (NEW.category = 'issue_tracker' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{TRACKER_FUNCTION_NAME}(); - SQL - end - - def tracker_create_delete_trigger(table_name) - execute(<<~SQL) - CREATE TRIGGER #{TRACKER_TRIGGER_ON_DELETE_NAME} - AFTER DELETE ON #{table_name} - FOR EACH ROW - WHEN (OLD.category = 'issue_tracker' AND OLD.active = TRUE AND OLD.project_id IS NOT NULL) - EXECUTE FUNCTION #{TRACKER_FUNCTION_NAME}(); - SQL - end -end diff --git a/db/migrate/20210621044000_rename_services_indexes_to_integrations.rb b/db/migrate/20210621044000_rename_services_indexes_to_integrations.rb deleted file mode 100644 index 9dba663f6a7..00000000000 --- a/db/migrate/20210621044000_rename_services_indexes_to_integrations.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class RenameServicesIndexesToIntegrations < ActiveRecord::Migration[6.1] - INDEXES = %w( - project_and_type_where_inherit_null - project_id_and_type_unique - template - type - type_and_instance_partial - type_and_template_partial - type_id_when_active_and_project_id_not_null - unique_group_id_and_type - ).freeze - - def up - INDEXES.each do |index| - execute(<<~SQL) - ALTER INDEX IF EXISTS "index_services_on_#{index}" RENAME TO "index_integrations_on_#{index}" - SQL - end - end - - def down - INDEXES.each do |index| - execute(<<~SQL) - ALTER INDEX IF EXISTS "index_integrations_on_#{index}" RENAME TO "index_services_on_#{index}" - SQL - end - end -end diff --git a/db/migrate/20210621084632_add_summary_to_timelogs.rb b/db/migrate/20210621084632_add_summary_to_timelogs.rb deleted file mode 100644 index 45fd7f1e0bc..00000000000 --- a/db/migrate/20210621084632_add_summary_to_timelogs.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddSummaryToTimelogs < ActiveRecord::Migration[6.1] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210621090030_add_text_limit_to_timelogs_summary - def change - add_column :timelogs, :summary, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210621090030_add_text_limit_to_timelogs_summary.rb b/db/migrate/20210621090030_add_text_limit_to_timelogs_summary.rb deleted file mode 100644 index ac872afd3fa..00000000000 --- a/db/migrate/20210621090030_add_text_limit_to_timelogs_summary.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToTimelogsSummary < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_text_limit :timelogs, :summary, 255 - end - - def down - remove_text_limit :timelogs, :summary - end -end diff --git a/db/migrate/20210621091830_add_devops_adoption_snapshot_dependency_scanning.rb b/db/migrate/20210621091830_add_devops_adoption_snapshot_dependency_scanning.rb deleted file mode 100644 index ae19a46b66f..00000000000 --- a/db/migrate/20210621091830_add_devops_adoption_snapshot_dependency_scanning.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionSnapshotDependencyScanning < ActiveRecord::Migration[6.1] - def change - add_column :analytics_devops_adoption_snapshots, :dependency_scanning_enabled_count, :integer - end -end diff --git a/db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb b/db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb deleted file mode 100644 index 03991cea41c..00000000000 --- a/db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyForEnvironmentIdToEnvironments < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - # `validate: false` option is passed here, because validating the existing rows fails by the orphaned deployments, - # which will be cleaned up in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64588. - # The validation runs for only new records or updates, so that we can at least - # stop creating orphaned rows. - add_concurrent_foreign_key :deployments, :environments, column: :environment_id, on_delete: :cascade, validate: false - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :deployments, :environments - end - end -end diff --git a/db/migrate/20210623074226_add_usage_ping_features_enabled_to_application_settings.rb b/db/migrate/20210623074226_add_usage_ping_features_enabled_to_application_settings.rb deleted file mode 100644 index 7a70f695039..00000000000 --- a/db/migrate/20210623074226_add_usage_ping_features_enabled_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddUsagePingFeaturesEnabledToApplicationSettings < ActiveRecord::Migration[6.1] - def up - add_column :application_settings, :usage_ping_features_enabled, :boolean, default: false, null: false - end - - def down - remove_column :application_settings, :usage_ping_features_enabled - end -end diff --git a/db/migrate/20210623123722_add_present_on_default_branch_to_vulnerabilities.rb b/db/migrate/20210623123722_add_present_on_default_branch_to_vulnerabilities.rb deleted file mode 100644 index d528c4c6967..00000000000 --- a/db/migrate/20210623123722_add_present_on_default_branch_to_vulnerabilities.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddPresentOnDefaultBranchToVulnerabilities < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :vulnerabilities, :present_on_default_branch, :boolean, default: true, null: false - end - end - - def down - with_lock_retries do - remove_column :vulnerabilities, :present_on_default_branch - end - end -end diff --git a/db/migrate/20210623133635_create_error_tracking_errors.rb b/db/migrate/20210623133635_create_error_tracking_errors.rb deleted file mode 100644 index e26fbe8df86..00000000000 --- a/db/migrate/20210623133635_create_error_tracking_errors.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class CreateErrorTrackingErrors < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :error_tracking_errors do |t| - t.references :project, index: true, null: false, foreign_key: { on_delete: :cascade } - t.text :name, null: false - t.text :description, null: false - t.text :actor, null: false - t.datetime_with_timezone :first_seen_at, null: false, default: -> { 'NOW()' } - t.datetime_with_timezone :last_seen_at, null: false, default: -> { 'NOW()' } - t.text :platform - - t.text_limit :name, 255 - t.text_limit :description, 1024 - t.text_limit :actor, 255 - t.text_limit :platform, 255 - - t.timestamps_with_timezone - end - end - - def down - drop_table :error_tracking_errors - end -end diff --git a/db/migrate/20210623163342_add_index_to_compliance_management_frameworks_pipeline_configuration.rb b/db/migrate/20210623163342_add_index_to_compliance_management_frameworks_pipeline_configuration.rb deleted file mode 100644 index 81903230f43..00000000000 --- a/db/migrate/20210623163342_add_index_to_compliance_management_frameworks_pipeline_configuration.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToComplianceManagementFrameworksPipelineConfiguration < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_compliance_frameworks_id_where_frameworks_not_null' - - def up - add_concurrent_index :compliance_management_frameworks, :id, name: INDEX_NAME, where: 'pipeline_configuration_full_path IS NOT NULL' - end - - def down - remove_concurrent_index_by_name :compliance_management_frameworks, INDEX_NAME - end -end diff --git a/db/migrate/20210624112821_add_devops_adoption_coverage_fuzzing.rb b/db/migrate/20210624112821_add_devops_adoption_coverage_fuzzing.rb deleted file mode 100644 index 6ca040dbfbc..00000000000 --- a/db/migrate/20210624112821_add_devops_adoption_coverage_fuzzing.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionCoverageFuzzing < ActiveRecord::Migration[6.1] - def change - add_column :analytics_devops_adoption_snapshots, :coverage_fuzzing_enabled_count, :integer - end -end diff --git a/db/migrate/20210624180613_add_last_synced_at_to_licenses.rb b/db/migrate/20210624180613_add_last_synced_at_to_licenses.rb deleted file mode 100644 index 085fccdc20f..00000000000 --- a/db/migrate/20210624180613_add_last_synced_at_to_licenses.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddLastSyncedAtToLicenses < ActiveRecord::Migration[6.1] - def change - add_column :licenses, :last_synced_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20210625094554_create_error_tracking_error_events.rb b/db/migrate/20210625094554_create_error_tracking_error_events.rb deleted file mode 100644 index c1ed6d6ce6e..00000000000 --- a/db/migrate/20210625094554_create_error_tracking_error_events.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class CreateErrorTrackingErrorEvents < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :error_tracking_error_events do |t| - t.references :error, - index: true, - null: false, - foreign_key: { on_delete: :cascade, to_table: :error_tracking_errors } - - t.text :description, null: false - t.text :environment - t.text :level - t.datetime_with_timezone :occurred_at, null: false - t.jsonb :payload, null: false, default: {} - - t.text_limit :description, 255 - t.text_limit :environment, 255 - t.text_limit :level, 255 - - t.timestamps_with_timezone - end - end - - def down - drop_table :error_tracking_error_events - end -end diff --git a/db/migrate/20210627204936_add_plan_limits_max_size_cluster_image_scanning_column.rb b/db/migrate/20210627204936_add_plan_limits_max_size_cluster_image_scanning_column.rb deleted file mode 100644 index 322e6991d0b..00000000000 --- a/db/migrate/20210627204936_add_plan_limits_max_size_cluster_image_scanning_column.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddPlanLimitsMaxSizeClusterImageScanningColumn < ActiveRecord::Migration[6.0] - def change - add_column :plan_limits, :ci_max_artifact_size_cluster_image_scanning, :integer, null: false, default: 0 - end -end diff --git a/db/migrate/20210628154900_create_detached_partitions_table.rb b/db/migrate/20210628154900_create_detached_partitions_table.rb deleted file mode 100644 index cf31d71835a..00000000000 --- a/db/migrate/20210628154900_create_detached_partitions_table.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class CreateDetachedPartitionsTable < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :detached_partitions do |t| - t.timestamps_with_timezone null: false - t.datetime_with_timezone :drop_after, null: false - t.text :table_name, null: false - - # Postgres identifier names can be up to 63 bytes - # See https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS - t.text_limit :table_name, 63 - end - end - - def down - with_lock_retries do - drop_table :detached_partitions - end - end -end diff --git a/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb b/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb deleted file mode 100644 index 14b6b9efad3..00000000000 --- a/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AssociateExistingDastBuildsWithVariables < ActiveRecord::Migration[6.1] - def up - # no-op: Must have run before %"15.X" as it is not compatible with decomposed CI database - end - - def down - # No-op - end -end diff --git a/db/migrate/20210629153519_add_index_to_bulk_import_entities_on_bulk_import_id_and_status.rb b/db/migrate/20210629153519_add_index_to_bulk_import_entities_on_bulk_import_id_and_status.rb deleted file mode 100644 index c84a42cbea4..00000000000 --- a/db/migrate/20210629153519_add_index_to_bulk_import_entities_on_bulk_import_id_and_status.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToBulkImportEntitiesOnBulkImportIdAndStatus < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - NEW_INDEX_NAME = 'index_bulk_import_entities_on_bulk_import_id_and_status' - OLD_INDEX_NAME = 'index_bulk_import_entities_on_bulk_import_id' - - def up - add_concurrent_index :bulk_import_entities, [:bulk_import_id, :status], name: NEW_INDEX_NAME - remove_concurrent_index_by_name :bulk_import_entities, name: OLD_INDEX_NAME - end - - def down - add_concurrent_index :bulk_import_entities, :bulk_import_id, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :bulk_import_entities, name: NEW_INDEX_NAME - end -end diff --git a/db/migrate/20210630144339_add_invite_email_success_to_members.rb b/db/migrate/20210630144339_add_invite_email_success_to_members.rb deleted file mode 100644 index 6c341ecb3f3..00000000000 --- a/db/migrate/20210630144339_add_invite_email_success_to_members.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddInviteEmailSuccessToMembers < ActiveRecord::Migration[6.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb b/db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb deleted file mode 100644 index 5df0f84ab78..00000000000 --- a/db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddCustomersDotJwtSigningKeyToApplicationSettings < ActiveRecord::Migration[6.1] - DOWNTIME = false - - def change - add_column :application_settings, :encrypted_customers_dot_jwt_signing_key, :binary - add_column :application_settings, :encrypted_customers_dot_jwt_signing_key_iv, :binary - end -end diff --git a/db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb b/db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb deleted file mode 100644 index 703b2c7d0b8..00000000000 --- a/db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class GenerateCustomersDotJwtSigningKey < ActiveRecord::Migration[6.1] - DOWNTIME = false - - class ApplicationSetting < ActiveRecord::Base - self.table_name = 'application_settings' - - attr_encrypted :customers_dot_jwt_signing_key, { - mode: :per_attribute_iv, - key: Gitlab::Utils.ensure_utf8_size(Rails.application.secrets.db_key_base, bytes: 32.bytes), - algorithm: 'aes-256-gcm', - encode: true - } - end - - def up - ApplicationSetting.reset_column_information - - ApplicationSetting.find_each do |application_setting| - application_setting.update(customers_dot_jwt_signing_key: OpenSSL::PKey::RSA.new(2048).to_pem) - end - end - - def down - ApplicationSetting.reset_column_information - - ApplicationSetting.find_each do |application_setting| - application_setting.update_columns(encrypted_customers_dot_jwt_signing_key: nil, encrypted_customers_dot_jwt_signing_key_iv: nil) - end - end -end diff --git a/db/migrate/20210701111627_add_upvotes_count_to_issues.rb b/db/migrate/20210701111627_add_upvotes_count_to_issues.rb deleted file mode 100644 index beefb186f37..00000000000 --- a/db/migrate/20210701111627_add_upvotes_count_to_issues.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUpvotesCountToIssues < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :issues, :upvotes_count, :integer, default: 0, null: false - end - end - - def down - remove_column :issues, :upvotes_count - end -end diff --git a/db/migrate/20210702124842_add_ci_job_trace_size_to_plan_limits.rb b/db/migrate/20210702124842_add_ci_job_trace_size_to_plan_limits.rb deleted file mode 100644 index 561c98c449c..00000000000 --- a/db/migrate/20210702124842_add_ci_job_trace_size_to_plan_limits.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddCiJobTraceSizeToPlanLimits < ActiveRecord::Migration[6.1] - def change - add_column(:plan_limits, :ci_jobs_trace_size_limit, :integer, default: 100, null: false) - end -end diff --git a/db/migrate/20210705124128_add_project_settings_previous_default_branch.rb b/db/migrate/20210705124128_add_project_settings_previous_default_branch.rb deleted file mode 100644 index e54d762fa75..00000000000 --- a/db/migrate/20210705124128_add_project_settings_previous_default_branch.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddProjectSettingsPreviousDefaultBranch < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210707173645_add_project_settings_previous_default_branch_text_limit - def up - with_lock_retries do - add_column :project_settings, :previous_default_branch, :text - end - end - # rubocop:enable Migration/AddLimitToTextColumns - - def down - with_lock_retries do - remove_column :project_settings, :previous_default_branch - end - end -end diff --git a/db/migrate/20210705130919_create_container_repos_on_exp_cleanup_status_project_id_start_date_index.rb b/db/migrate/20210705130919_create_container_repos_on_exp_cleanup_status_project_id_start_date_index.rb deleted file mode 100644 index a6983c2d599..00000000000 --- a/db/migrate/20210705130919_create_container_repos_on_exp_cleanup_status_project_id_start_date_index.rb +++ /dev/null @@ -1,24 +0,0 @@ -# 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 CreateContainerReposOnExpCleanupStatusProjectIdStartDateIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - OLD_INDEX_NAME = 'idx_container_repositories_on_exp_cleanup_status_and_start_date' - NEW_INDEX_NAME = 'idx_container_repos_on_exp_cleanup_status_project_id_start_date' - - disable_ddl_transaction! - - def up - add_concurrent_index(:container_repositories, [:expiration_policy_cleanup_status, :project_id, :expiration_policy_started_at], name: NEW_INDEX_NAME) - remove_concurrent_index(:container_repositories, [:expiration_policy_cleanup_status, :expiration_policy_started_at], name: OLD_INDEX_NAME) - end - - def down - add_concurrent_index(:container_repositories, [:expiration_policy_cleanup_status, :expiration_policy_started_at], name: OLD_INDEX_NAME) - remove_concurrent_index(:container_repositories, [:expiration_policy_cleanup_status, :project_id, :expiration_policy_started_at], name: NEW_INDEX_NAME) - end -end diff --git a/db/migrate/20210705132928_add_new_user_signups_cap_to_namespace_settings.rb b/db/migrate/20210705132928_add_new_user_signups_cap_to_namespace_settings.rb deleted file mode 100644 index 7f736bf2b87..00000000000 --- a/db/migrate/20210705132928_add_new_user_signups_cap_to_namespace_settings.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddNewUserSignupsCapToNamespaceSettings < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :namespace_settings, :new_user_signups_cap, :integer, null: true - end - end - - def down - with_lock_retries do - remove_column :namespace_settings, :new_user_signups_cap - end - end -end diff --git a/db/migrate/20210705142714_initialize_conversion_of_ci_builds_metadata_id_to_bigint.rb b/db/migrate/20210705142714_initialize_conversion_of_ci_builds_metadata_id_to_bigint.rb deleted file mode 100644 index ea612100e5a..00000000000 --- a/db/migrate/20210705142714_initialize_conversion_of_ci_builds_metadata_id_to_bigint.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class InitializeConversionOfCiBuildsMetadataIdToBigint < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - TABLE = :ci_builds_metadata - COLUMN = :id - - def up - initialize_conversion_of_integer_to_bigint(TABLE, COLUMN) - end - - def down - revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMN) - end -end diff --git a/db/migrate/20210705144657_add_instance_runners_enabled_to_ci_pending_build.rb b/db/migrate/20210705144657_add_instance_runners_enabled_to_ci_pending_build.rb deleted file mode 100644 index b362fd930a3..00000000000 --- a/db/migrate/20210705144657_add_instance_runners_enabled_to_ci_pending_build.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddInstanceRunnersEnabledToCiPendingBuild < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :ci_pending_builds, :instance_runners_enabled, :boolean, null: false, default: false - end - end - - def down - with_lock_retries do - remove_column :ci_pending_builds, :instance_runners_enabled - end - end -end diff --git a/db/migrate/20210706084713_add_devops_adoption_snapshots_index.rb b/db/migrate/20210706084713_add_devops_adoption_snapshots_index.rb deleted file mode 100644 index 26727b7ad7d..00000000000 --- a/db/migrate/20210706084713_add_devops_adoption_snapshots_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionSnapshotsIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'idx_analytics_devops_adoption_snapshots_finalized' - - def up - add_concurrent_index :analytics_devops_adoption_snapshots, [:namespace_id, :end_time], where: "recorded_at >= end_time", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :analytics_devops_adoption_snapshots, INDEX_NAME - end -end diff --git a/db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb b/db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb deleted file mode 100644 index 866b16a6bb9..00000000000 --- a/db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddRemainingCiMinutesToCiPendingBuild < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column(:ci_pending_builds, :namespace_id, :bigint) - add_column(:ci_pending_builds, :minutes_exceeded, :boolean, null: false, default: false) - end - end - - def down - with_lock_retries do - remove_column(:ci_pending_builds, :minutes_exceeded) - remove_column(:ci_pending_builds, :namespace_id) - end - end -end diff --git a/db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb b/db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb deleted file mode 100644 index 2a04850d905..00000000000 --- a/db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddNamespaceForeignKeyToCiPendingBuild < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - INDEX_NAME = 'index_ci_pending_builds_on_namespace_id' - - def up - add_concurrent_index(:ci_pending_builds, :namespace_id, name: INDEX_NAME) - add_concurrent_foreign_key(:ci_pending_builds, :namespaces, column: :namespace_id, on_delete: :cascade) - end - - def down - remove_foreign_key_if_exists(:ci_pending_builds, column: :namespace_id) - remove_concurrent_index_by_name(:ci_pending_builds, INDEX_NAME) - end -end diff --git a/db/migrate/20210706152139_add_index_type_to_postgres_indexes_view.rb b/db/migrate/20210706152139_add_index_type_to_postgres_indexes_view.rb deleted file mode 100644 index a2a3d74cd49..00000000000 --- a/db/migrate/20210706152139_add_index_type_to_postgres_indexes_view.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -class AddIndexTypeToPostgresIndexesView < ActiveRecord::Migration[6.1] - def up - execute(<<~SQL) - DROP VIEW IF EXISTS postgres_indexes; - - CREATE VIEW postgres_indexes AS - SELECT (pg_namespace.nspname::text || '.'::text) || i.relname::text AS identifier, - pg_index.indexrelid, - pg_namespace.nspname AS schema, - i.relname AS name, - pg_indexes.tablename, - a.amname AS type, - pg_index.indisunique AS "unique", - pg_index.indisvalid AS valid_index, - i.relispartition AS partitioned, - pg_index.indisexclusion AS exclusion, - pg_index.indexprs IS NOT NULL AS expression, - pg_index.indpred IS NOT NULL AS partial, - pg_indexes.indexdef AS definition, - pg_relation_size(i.oid::regclass) AS ondisk_size_bytes - FROM pg_index - JOIN pg_class i ON i.oid = pg_index.indexrelid - JOIN pg_namespace ON i.relnamespace = pg_namespace.oid - JOIN pg_indexes ON i.relname = pg_indexes.indexname - JOIN pg_am a ON i.relam = a.oid - WHERE pg_namespace.nspname <> 'pg_catalog'::name AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name])); - SQL - end - - def down - execute(<<~SQL) - DROP VIEW IF EXISTS postgres_indexes; - - CREATE VIEW postgres_indexes AS - SELECT (((pg_namespace.nspname)::text || '.'::text) || (pg_class.relname)::text) AS identifier, - pg_index.indexrelid, - pg_namespace.nspname AS schema, - pg_class.relname AS name, - pg_indexes.tablename, - pg_index.indisunique AS "unique", - pg_index.indisvalid AS valid_index, - pg_class.relispartition AS partitioned, - pg_index.indisexclusion AS exclusion, - (pg_index.indexprs IS NOT NULL) AS expression, - (pg_index.indpred IS NOT NULL) AS partial, - pg_indexes.indexdef AS definition, - pg_relation_size((pg_class.oid)::regclass) AS ondisk_size_bytes - FROM (((pg_index - JOIN pg_class ON ((pg_class.oid = pg_index.indexrelid))) - JOIN pg_namespace ON ((pg_class.relnamespace = pg_namespace.oid))) - JOIN pg_indexes ON ((pg_class.relname = pg_indexes.indexname))) - WHERE ((pg_namespace.nspname <> 'pg_catalog'::name) AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name]))); - SQL - end -end diff --git a/db/migrate/20210706213537_add_premium_and_ultimate_plan_limits.rb b/db/migrate/20210706213537_add_premium_and_ultimate_plan_limits.rb deleted file mode 100644 index f78e37d645a..00000000000 --- a/db/migrate/20210706213537_add_premium_and_ultimate_plan_limits.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class AddPremiumAndUltimatePlanLimits < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - class Plan < ActiveRecord::Base - self.inheritance_column = :_type_disabled - - has_one :limits, class_name: 'PlanLimits' - end - - class PlanLimits < ActiveRecord::Base - self.inheritance_column = :_type_disabled - - belongs_to :plan - end - - def copy_plan_limits(from_plan_name:, to_plan_name:) - source_plan = Plan.find_by(name: from_plan_name) - target_plan = Plan.find_by(name: to_plan_name) - return unless source_plan && target_plan - return unless source_plan.limits.present? - return if target_plan.limits.present? - - limits = source_plan.limits.dup - limits.plan = target_plan - limits.save! - end - - def up - return unless Gitlab.com? - - copy_plan_limits(from_plan_name: 'gold', to_plan_name: 'ultimate') - copy_plan_limits(from_plan_name: 'silver', to_plan_name: 'premium') - end - - def down - # no-op - end -end diff --git a/db/migrate/20210707095545_add_status_to_merge_request_cleanup_schedules.rb b/db/migrate/20210707095545_add_status_to_merge_request_cleanup_schedules.rb deleted file mode 100644 index 597e274cda2..00000000000 --- a/db/migrate/20210707095545_add_status_to_merge_request_cleanup_schedules.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToMergeRequestCleanupSchedules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_merge_request_cleanup_schedules_on_status' - - disable_ddl_transaction! - - def up - unless column_exists?(:merge_request_cleanup_schedules, :status) - add_column(:merge_request_cleanup_schedules, :status, :integer, limit: 2, default: 0, null: false) - end - - add_concurrent_index(:merge_request_cleanup_schedules, :status, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:merge_request_cleanup_schedules, INDEX_NAME) - - if column_exists?(:merge_request_cleanup_schedules, :status) - remove_column(:merge_request_cleanup_schedules, :status) - end - end -end diff --git a/db/migrate/20210707113056_add_tags_array_to_ci_pending_builds.rb b/db/migrate/20210707113056_add_tags_array_to_ci_pending_builds.rb deleted file mode 100644 index 229dc01fb87..00000000000 --- a/db/migrate/20210707113056_add_tags_array_to_ci_pending_builds.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddTagsArrayToCiPendingBuilds < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :ci_pending_builds, :tag_ids, :integer, array: true, default: [] - end - end - - def down - with_lock_retries do - remove_column :ci_pending_builds, :tag_ids - end - end -end diff --git a/db/migrate/20210707151536_create_vulnerability_finding_evidence_sources.rb b/db/migrate/20210707151536_create_vulnerability_finding_evidence_sources.rb deleted file mode 100644 index 90bc6fb82bd..00000000000 --- a/db/migrate/20210707151536_create_vulnerability_finding_evidence_sources.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class CreateVulnerabilityFindingEvidenceSources < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - create_table_with_constraints :vulnerability_finding_evidence_sources do |t| - t.timestamps_with_timezone null: false - - t.references :vulnerability_finding_evidence, index: { name: 'finding_evidence_sources_on_finding_evidence_id' }, null: false, foreign_key: { on_delete: :cascade } - t.text :name - t.text :url - - t.text_limit :name, 2048 - t.text_limit :url, 2048 - end - end - - def down - with_lock_retries do - drop_table :vulnerability_finding_evidence_sources - end - end -end diff --git a/db/migrate/20210707163659_add_vulnerability_events_to_integrations.rb b/db/migrate/20210707163659_add_vulnerability_events_to_integrations.rb deleted file mode 100644 index c138af486c1..00000000000 --- a/db/migrate/20210707163659_add_vulnerability_events_to_integrations.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddVulnerabilityEventsToIntegrations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def change - add_column :integrations, :vulnerability_events, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210707171536_create_vulnerability_finding_evidence_assets.rb b/db/migrate/20210707171536_create_vulnerability_finding_evidence_assets.rb deleted file mode 100644 index 57c71e6bc17..00000000000 --- a/db/migrate/20210707171536_create_vulnerability_finding_evidence_assets.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class CreateVulnerabilityFindingEvidenceAssets < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - create_table_with_constraints :vulnerability_finding_evidence_assets do |t| - t.timestamps_with_timezone null: false - - t.references :vulnerability_finding_evidence, index: { name: 'finding_evidence_assets_on_finding_evidence_id' }, null: false, foreign_key: { on_delete: :cascade } - t.text :type - t.text :name - t.text :url - - t.text_limit :type, 2048 - t.text_limit :name, 2048 - t.text_limit :url, 2048 - end - end - - def down - with_lock_retries do - drop_table :vulnerability_finding_evidence_assets - end - end -end diff --git a/db/migrate/20210707171554_create_vulnerability_flags.rb b/db/migrate/20210707171554_create_vulnerability_flags.rb deleted file mode 100644 index bf33963b08f..00000000000 --- a/db/migrate/20210707171554_create_vulnerability_flags.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class CreateVulnerabilityFlags < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - FALSE_POSITIVE_ENUM_VALUE = 0 - - disable_ddl_transaction! - - def up - create_table_with_constraints :vulnerability_flags do |t| - t.timestamps_with_timezone null: false - - t.references :vulnerability_occurrence, null: false, foreign_key: { on_delete: :cascade } - - t.integer :flag_type, limit: 2, null: false, default: FALSE_POSITIVE_ENUM_VALUE - - t.text :origin, null: false - t.text :description, null: false - - t.text_limit :origin, 255 - t.text_limit :description, 1024 - end - end - - def down - drop_table :vulnerability_flags - end -end diff --git a/db/migrate/20210707173645_add_project_settings_previous_default_branch_text_limit.rb b/db/migrate/20210707173645_add_project_settings_previous_default_branch_text_limit.rb deleted file mode 100644 index a6a83b00234..00000000000 --- a/db/migrate/20210707173645_add_project_settings_previous_default_branch_text_limit.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddProjectSettingsPreviousDefaultBranchTextLimit < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_text_limit :project_settings, :previous_default_branch, 4096 - end - - def down - remove_text_limit :project_settings, :previous_default_branch - end -end diff --git a/db/migrate/20210707181536_create_vulnerability_finding_evidence_supporting_messages.rb b/db/migrate/20210707181536_create_vulnerability_finding_evidence_supporting_messages.rb deleted file mode 100644 index b9fc822a5a3..00000000000 --- a/db/migrate/20210707181536_create_vulnerability_finding_evidence_supporting_messages.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class CreateVulnerabilityFindingEvidenceSupportingMessages < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table_with_constraints :vulnerability_finding_evidence_supporting_messages do |t| - t.timestamps_with_timezone null: false - - t.references :vulnerability_finding_evidence, index: { name: 'finding_evidence_supporting_messages_on_finding_evidence_id' }, null: false, foreign_key: { on_delete: :cascade } - t.text :name - - t.text_limit :name, 2048 - end - end - - def down - with_lock_retries do - drop_table :vulnerability_finding_evidence_supporting_messages - end - end -end diff --git a/db/migrate/20210708011425_rename_ci_builds_metadata_foreign_key.rb b/db/migrate/20210708011425_rename_ci_builds_metadata_foreign_key.rb deleted file mode 100644 index 70141f4844e..00000000000 --- a/db/migrate/20210708011425_rename_ci_builds_metadata_foreign_key.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class RenameCiBuildsMetadataForeignKey < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - TABLE_NAME = 'ci_builds_metadata' - OLD_PREFIX = 'fk_rails_' - - def up - with_lock_retries(raise_on_exhaustion: true) do - rename_constraint( - TABLE_NAME, - concurrent_foreign_key_name(TABLE_NAME, :build_id, prefix: 'fk_rails_'), - concurrent_foreign_key_name(TABLE_NAME, :build_id) - ) - end - end - - def down - with_lock_retries(raise_on_exhaustion: true) do - rename_constraint( - TABLE_NAME, - concurrent_foreign_key_name(TABLE_NAME, :build_id), - concurrent_foreign_key_name(TABLE_NAME, :build_id, prefix: 'fk_rails_') - ) - end - end -end diff --git a/db/migrate/20210708063032_add_failed_count_to_merge_request_cleanup_schedules.rb b/db/migrate/20210708063032_add_failed_count_to_merge_request_cleanup_schedules.rb deleted file mode 100644 index f613856a18c..00000000000 --- a/db/migrate/20210708063032_add_failed_count_to_merge_request_cleanup_schedules.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddFailedCountToMergeRequestCleanupSchedules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def change - add_column :merge_request_cleanup_schedules, :failed_count, :integer, default: 0, null: false - end -end diff --git a/db/migrate/20210708124229_add_security_scans_created_at_index.rb b/db/migrate/20210708124229_add_security_scans_created_at_index.rb deleted file mode 100644 index d2d1958f5b9..00000000000 --- a/db/migrate/20210708124229_add_security_scans_created_at_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddSecurityScansCreatedAtIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_security_scans_on_created_at' - - def up - add_concurrent_index(:security_scans, :created_at, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:security_scans, INDEX_NAME) - end -end diff --git a/db/migrate/20210708131048_add_error_tracking_counter_cache.rb b/db/migrate/20210708131048_add_error_tracking_counter_cache.rb deleted file mode 100644 index 3bf7e1e3688..00000000000 --- a/db/migrate/20210708131048_add_error_tracking_counter_cache.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddErrorTrackingCounterCache < ActiveRecord::Migration[6.1] - def up - add_column :error_tracking_errors, :events_count, :bigint, null: false, default: 0 - end - - def down - remove_column :error_tracking_errors, :events_count - end -end diff --git a/db/migrate/20210708134446_remove_not_null_constraint_from_terms.rb b/db/migrate/20210708134446_remove_not_null_constraint_from_terms.rb deleted file mode 100644 index 82abfeb57f9..00000000000 --- a/db/migrate/20210708134446_remove_not_null_constraint_from_terms.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveNotNullConstraintFromTerms < ActiveRecord::Migration[6.1] - def up - change_column_null :application_setting_terms, :terms, true - end - - def down - change_column_null :application_setting_terms, :terms, false - end -end diff --git a/db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb b/db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb deleted file mode 100644 index a9175833dd7..00000000000 --- a/db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddScannersColumnToApprovalProjectRules < ActiveRecord::Migration[6.1] - def up - add_column :approval_project_rules, :scanners, :text, array: true - end - - def down - remove_column :approval_project_rules, :scanners - end -end diff --git a/db/migrate/20210709085759_index_batched_migration_jobs_by_max_value.rb b/db/migrate/20210709085759_index_batched_migration_jobs_by_max_value.rb deleted file mode 100644 index 8240e968e7a..00000000000 --- a/db/migrate/20210709085759_index_batched_migration_jobs_by_max_value.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class IndexBatchedMigrationJobsByMaxValue < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_migration_jobs_on_migration_id_and_max_value' - - def up - add_concurrent_index :batched_background_migration_jobs, %i(batched_background_migration_id max_value), name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :batched_background_migration_jobs, INDEX_NAME - end -end diff --git a/db/migrate/20210709132707_change_default_job_token_scope_enabled.rb b/db/migrate/20210709132707_change_default_job_token_scope_enabled.rb deleted file mode 100644 index fbd9f7baa61..00000000000 --- a/db/migrate/20210709132707_change_default_job_token_scope_enabled.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ChangeDefaultJobTokenScopeEnabled < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: false, to: true - end - end - - def down - with_lock_retries do - change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: true, to: false - end - end -end diff --git a/db/migrate/20210709221051_create_work_item_types.rb b/db/migrate/20210709221051_create_work_item_types.rb deleted file mode 100644 index 749689811e0..00000000000 --- a/db/migrate/20210709221051_create_work_item_types.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class CreateWorkItemTypes < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - create_table_with_constraints :work_item_types do |t| - t.integer :base_type, limit: 2, default: 0, null: false - t.integer :cached_markdown_version - t.text :name, null: false - t.text :description # rubocop:disable Migration/AddLimitToTextColumns - t.text :description_html # rubocop:disable Migration/AddLimitToTextColumns - t.text :icon_name, null: true - t.references :namespace, foreign_key: { on_delete: :cascade }, index: false, null: true - t.timestamps_with_timezone null: false - - t.text_limit :name, 255 - t.text_limit :icon_name, 255 - end - - add_concurrent_index :work_item_types, - 'namespace_id, TRIM(BOTH FROM LOWER(name))', - unique: true, - name: :work_item_types_namespace_id_and_name_unique - end - - def down - with_lock_retries do - drop_table :work_item_types - end - end -end diff --git a/db/migrate/20210709221659_add_work_item_type_id_to_issue.rb b/db/migrate/20210709221659_add_work_item_type_id_to_issue.rb deleted file mode 100644 index 38292cd37c5..00000000000 --- a/db/migrate/20210709221659_add_work_item_type_id_to_issue.rb +++ /dev/null @@ -1,31 +0,0 @@ -# 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 AddWorkItemTypeIdToIssue < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - unless column_exists?(:issues, :work_item_type_id) - with_lock_retries do - add_column :issues, :work_item_type_id, :bigint - end - end - - add_concurrent_index :issues, :work_item_type_id - add_concurrent_foreign_key :issues, :work_item_types, column: :work_item_type_id, on_delete: nil - end - - def down - if foreign_key_exists?(:issues, :work_item_types) - remove_foreign_key :issues, column: :work_item_type_id - end - - with_lock_retries do - remove_column :issues, :work_item_type_id - end - end -end diff --git a/db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb b/db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb deleted file mode 100644 index 216d43dd62d..00000000000 --- a/db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class AddLabelAppliedIssuableClosedToIssuableSla < ActiveRecord::Migration[6.1] - def change - add_column :issuable_slas, :label_applied, :boolean, default: false, null: false - add_column :issuable_slas, :issuable_closed, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210713070842_update_merge_request_cleanup_schedules_scheduled_at_index.rb b/db/migrate/20210713070842_update_merge_request_cleanup_schedules_scheduled_at_index.rb deleted file mode 100644 index a19d15d80a0..00000000000 --- a/db/migrate/20210713070842_update_merge_request_cleanup_schedules_scheduled_at_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class UpdateMergeRequestCleanupSchedulesScheduledAtIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_mr_cleanup_schedules_timestamps_status' - OLD_INDEX_NAME = 'index_mr_cleanup_schedules_timestamps' - - disable_ddl_transaction! - - def up - add_concurrent_index(:merge_request_cleanup_schedules, :scheduled_at, where: 'completed_at IS NULL AND status = 0', name: INDEX_NAME) - remove_concurrent_index_by_name(:merge_request_cleanup_schedules, OLD_INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:merge_request_cleanup_schedules, INDEX_NAME) - add_concurrent_index(:merge_request_cleanup_schedules, :scheduled_at, where: 'completed_at IS NULL', name: OLD_INDEX_NAME) - end -end diff --git a/db/migrate/20210713123345_create_dast_profile_schedule.rb b/db/migrate/20210713123345_create_dast_profile_schedule.rb deleted file mode 100644 index ea660de572a..00000000000 --- a/db/migrate/20210713123345_create_dast_profile_schedule.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class CreateDastProfileSchedule < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_dast_profile_schedules_active_next_run_at' - - def up - table_comment = { - owner: 'group::dynamic analysis', description: 'Scheduling for scans using DAST Profiles' - } - - create_table_with_constraints :dast_profile_schedules, comment: Gitlab::Json.dump(table_comment) do |t| - t.bigint :project_id, null: false - t.bigint :dast_profile_id, null: false - t.bigint :user_id - - t.datetime_with_timezone :next_run_at, null: false - t.timestamps_with_timezone null: false - t.boolean :active, default: true, null: false - t.text :cron, null: false - t.text_limit :cron, 255 - - t.index %i[active next_run_at], name: INDEX_NAME - t.index %i[project_id dast_profile_id], unique: true - t.index :dast_profile_id - t.index :user_id - end - end - - def down - with_lock_retries do - drop_table :dast_profile_schedules - end - end -end diff --git a/db/migrate/20210713135152_add_devops_adoption_vulnerability_management_used_count.rb b/db/migrate/20210713135152_add_devops_adoption_vulnerability_management_used_count.rb deleted file mode 100644 index 74f24364177..00000000000 --- a/db/migrate/20210713135152_add_devops_adoption_vulnerability_management_used_count.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionVulnerabilityManagementUsedCount < ActiveRecord::Migration[6.1] - def change - add_column :analytics_devops_adoption_snapshots, :vulnerability_management_used_count, :integer - end -end diff --git a/db/migrate/20210713144637_add_vulnerabilities_created_at_index.rb b/db/migrate/20210713144637_add_vulnerabilities_created_at_index.rb deleted file mode 100644 index 27eb2691754..00000000000 --- a/db/migrate/20210713144637_add_vulnerabilities_created_at_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddVulnerabilitiesCreatedAtIndex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption' - - def up - add_concurrent_index :vulnerabilities, [:project_id, :created_at], where: 'state != 1', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME - end -end diff --git a/db/migrate/20210713211008_create_banned_users.rb b/db/migrate/20210713211008_create_banned_users.rb deleted file mode 100644 index 7e5eb7f95b8..00000000000 --- a/db/migrate/20210713211008_create_banned_users.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class CreateBannedUsers < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - create_table :banned_users, id: false do |t| - t.timestamps_with_timezone null: false - t.references :user, primary_key: true, default: nil, foreign_key: { on_delete: :cascade }, type: :bigint, index: false, null: false - end - end - end - - def down - with_lock_retries do - drop_table :banned_users - end - end -end diff --git a/db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb b/db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb deleted file mode 100644 index f0b9addb5f2..00000000000 --- a/db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveNullConstraintFromSecurityFindings < ActiveRecord::Migration[6.1] - def up - change_column_null :security_findings, :project_fingerprint, true - end - - def down - # no-op, it can not be reverted due to existing records that might not be valid - end -end diff --git a/db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb b/db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb deleted file mode 100644 index 5931941a95e..00000000000 --- a/db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForLabelAppliedToIssuableSla < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_issuable_slas_on_due_at_id_label_applied_issuable_closed' - - def up - add_concurrent_index :issuable_slas, [:due_at, :id], name: INDEX_NAME, where: 'label_applied = FALSE AND issuable_closed = FALSE' - end - - def down - remove_concurrent_index_by_name :issuable_slas, INDEX_NAME - end -end diff --git a/db/migrate/20210714120600_add_detected_at_to_vulnerabilities.rb b/db/migrate/20210714120600_add_detected_at_to_vulnerabilities.rb deleted file mode 100644 index fb18ac4e174..00000000000 --- a/db/migrate/20210714120600_add_detected_at_to_vulnerabilities.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddDetectedAtToVulnerabilities < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :vulnerabilities, :detected_at, :datetime_with_timezone - change_column_default :vulnerabilities, :detected_at, -> { 'NOW()' } - end - end - - def down - with_lock_retries do - remove_column :vulnerabilities, :detected_at - end - end -end diff --git a/db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb b/db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb deleted file mode 100644 index c042a875f57..00000000000 --- a/db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToDastProfileSchedulesOnDastProfile < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_profile_schedules, :dast_profiles, column: :dast_profile_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :dast_profile_schedules, column: :dast_profile_id - end - end -end diff --git a/db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb b/db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb deleted file mode 100644 index 576cee090ff..00000000000 --- a/db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToDastProfileSchedulesOnUser < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_profile_schedules, :users, column: :user_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :dast_profile_schedules, column: :user_id - end - end -end diff --git a/db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb b/db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb deleted file mode 100644 index cfc76c4a12c..00000000000 --- a/db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToDastProfileSchedulesOnProject < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_profile_schedules, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :dast_profile_schedules, column: :project_id - end - end -end diff --git a/db/migrate/20210716074555_revert_default_job_token_scope.rb b/db/migrate/20210716074555_revert_default_job_token_scope.rb deleted file mode 100644 index d28f75605e4..00000000000 --- a/db/migrate/20210716074555_revert_default_job_token_scope.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RevertDefaultJobTokenScope < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: true, to: false - end - end - - def down - with_lock_retries do - change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: false, to: true - end - end -end diff --git a/db/migrate/20210719145532_add_foreign_keys_view.rb b/db/migrate/20210719145532_add_foreign_keys_view.rb deleted file mode 100644 index 2d31371e782..00000000000 --- a/db/migrate/20210719145532_add_foreign_keys_view.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeysView < ActiveRecord::Migration[6.1] - def up - execute(<<~SQL) - CREATE OR REPLACE VIEW postgres_foreign_keys AS - SELECT - pg_constraint.oid AS oid, - pg_constraint.conname AS name, - constrained_namespace.nspname::text || '.'::text || constrained_table.relname::text AS constrained_table_identifier, - referenced_namespace.nspname::text || '.'::text || referenced_table.relname::text AS referenced_table_identifier - FROM pg_constraint - INNER JOIN pg_class constrained_table ON constrained_table.oid = pg_constraint.conrelid - INNER JOIN pg_class referenced_table ON referenced_table.oid = pg_constraint.confrelid - INNER JOIN pg_namespace constrained_namespace ON constrained_table.relnamespace = constrained_namespace.oid - INNER JOIN pg_namespace referenced_namespace ON referenced_table.relnamespace = referenced_namespace.oid - WHERE contype = 'f'; - SQL - end - - def down - execute(<<~SQL) - DROP VIEW IF EXISTS postgres_foreign_keys - SQL - end -end diff --git a/db/migrate/20210719182944_add_request_response_to_supporing_message.rb b/db/migrate/20210719182944_add_request_response_to_supporing_message.rb deleted file mode 100644 index a374361e88d..00000000000 --- a/db/migrate/20210719182944_add_request_response_to_supporing_message.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddRequestResponseToSupporingMessage < ActiveRecord::Migration[6.1] - def change - change_column_null(:vulnerability_finding_evidence_requests, :vulnerability_finding_evidence_id, true) - change_column_null(:vulnerability_finding_evidence_responses, :vulnerability_finding_evidence_id, true) - - # rubocop: disable Migration/AddReference - # Table is empty, so no need to use add_concurrent_foreign_key and add_concurrent_index - add_reference(:vulnerability_finding_evidence_requests, - :vulnerability_finding_evidence_supporting_message, - index: { name: 'finding_evidence_requests_on_supporting_evidence_id' }, - foreign_key: { on_delete: :cascade }) - add_reference(:vulnerability_finding_evidence_responses, - :vulnerability_finding_evidence_supporting_message, - index: { name: 'finding_evidence_responses_on_supporting_evidence_id' }, - foreign_key: { on_delete: :cascade }) - # rubocop:enable Migration/AddReference - end -end diff --git a/db/migrate/20210719192928_add_invite_email_success_to_member.rb b/db/migrate/20210719192928_add_invite_email_success_to_member.rb deleted file mode 100644 index ad629483a82..00000000000 --- a/db/migrate/20210719192928_add_invite_email_success_to_member.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddInviteEmailSuccessToMember < ActiveRecord::Migration[6.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/migrate/20210720083432_change_application_setting_terms_not_null.rb b/db/migrate/20210720083432_change_application_setting_terms_not_null.rb deleted file mode 100644 index 76dbbe68967..00000000000 --- a/db/migrate/20210720083432_change_application_setting_terms_not_null.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class ChangeApplicationSettingTermsNotNull < ActiveRecord::Migration[6.1] - def up - execute("UPDATE application_setting_terms SET terms = '' WHERE terms IS NULL") - change_column_null :application_setting_terms, :terms, false - end - - def down - change_column_null :application_setting_terms, :terms, true - end -end diff --git a/db/migrate/20210720130006_create_error_tracking_client_keys.rb b/db/migrate/20210720130006_create_error_tracking_client_keys.rb deleted file mode 100644 index caea4a3d65b..00000000000 --- a/db/migrate/20210720130006_create_error_tracking_client_keys.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class CreateErrorTrackingClientKeys < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :error_tracking_client_keys do |t| - t.references :project, - index: true, - null: false, - foreign_key: { on_delete: :cascade } - - t.boolean :active, default: true, null: false - t.text :public_key, null: false - t.text_limit :public_key, 255 - - t.timestamps_with_timezone - end - end - - def down - drop_table :error_tracking_client_keys - end -end diff --git a/db/migrate/20210720140841_create_postgres_async_indexes_table.rb b/db/migrate/20210720140841_create_postgres_async_indexes_table.rb deleted file mode 100644 index 99025149840..00000000000 --- a/db/migrate/20210720140841_create_postgres_async_indexes_table.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class CreatePostgresAsyncIndexesTable < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :postgres_async_indexes do |t| - t.timestamps_with_timezone null: false - - t.text :name, null: false - t.text :definition, null: false - t.text :table_name, null: false - - t.text_limit :name, 63 - t.text_limit :definition, 2048 - t.text_limit :table_name, 63 - - t.index :name, unique: true - end - end - - def down - with_lock_retries do - drop_table :postgres_async_indexes - end - end -end diff --git a/db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb b/db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb deleted file mode 100644 index 7e4a785cb54..00000000000 --- a/db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddSignedFileToPackagesDebianProjectDistributions < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files - def change - add_column :packages_debian_project_distributions, :signed_file, :text - add_column :packages_debian_project_distributions, :signed_file_store, :integer, limit: 2, default: 1, null: false - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb b/db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb deleted file mode 100644 index f27c158bed2..00000000000 --- a/db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddSignedFileToPackagesDebianGroupDistributions < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files - def change - add_column :packages_debian_group_distributions, :signed_file, :text - add_column :packages_debian_group_distributions, :signed_file_store, :integer, limit: 2, default: 1, null: false - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb b/db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb deleted file mode 100644 index 77524a5b068..00000000000 --- a/db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToPackagesDebianProjectDistributionsSignedFiles < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_text_limit :packages_debian_project_distributions, :signed_file, 255 - end - - def down - remove_text_limit :packages_debian_project_distributions, :signed_file - end -end diff --git a/db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb b/db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb deleted file mode 100644 index ef203cb2ff7..00000000000 --- a/db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToPackagesDebianGroupDistributionsSignedFiles < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - def up - add_text_limit :packages_debian_group_distributions, :signed_file, 255 - end - - def down - remove_text_limit :packages_debian_group_distributions, :signed_file - end -end diff --git a/db/migrate/20210721134706_add_type_new_to_integrations.rb b/db/migrate/20210721134706_add_type_new_to_integrations.rb deleted file mode 100644 index b43fb73436c..00000000000 --- a/db/migrate/20210721134706_add_type_new_to_integrations.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddTypeNewToIntegrations < ActiveRecord::Migration[6.1] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210721134707_add_text_limit_to_integrations_type_new - def change - add_column :integrations, :type_new, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb b/db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb deleted file mode 100644 index 8fb98abad8c..00000000000 --- a/db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToIntegrationsTypeNew < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_text_limit :integrations, :type_new, 255 - end - - def down - remove_text_limit :integrations, :type_new - end -end diff --git a/db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb b/db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb deleted file mode 100644 index 6b1f2aeba18..00000000000 --- a/db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -class AddTriggersToIntegrationsTypeNew < ActiveRecord::Migration[6.1] - include Gitlab::Database::SchemaHelpers - - FUNCTION_NAME = 'integrations_set_type_new' - TRIGGER_ON_INSERT_NAME = 'trigger_type_new_on_insert' - - def up - create_trigger_function(FUNCTION_NAME, replace: true) do - # This list matches `Gitlab::Integrations::StiType::NAMESPACED_INTEGRATIONS`. - # - # If we add new integrations after this migration we can directly use the - # correct class name in `type`, and don't need to add it to `NAMESPACED_INTEGRATIONS`. - <<~SQL - WITH mapping(old_type, new_type) AS (VALUES - ('AsanaService', 'Integrations::Asana'), - ('AssemblaService', 'Integrations::Assembla'), - ('BambooService', 'Integrations::Bamboo'), - ('BugzillaService', 'Integrations::Bugzilla'), - ('BuildkiteService', 'Integrations::Buildkite'), - ('CampfireService', 'Integrations::Campfire'), - ('ConfluenceService', 'Integrations::Confluence'), - ('CustomIssueTrackerService', 'Integrations::CustomIssueTracker'), - ('DatadogService', 'Integrations::Datadog'), - ('DiscordService', 'Integrations::Discord'), - ('DroneCiService', 'Integrations::DroneCi'), - ('EmailsOnPushService', 'Integrations::EmailsOnPush'), - ('EwmService', 'Integrations::Ewm'), - ('ExternalWikiService', 'Integrations::ExternalWiki'), - ('FlowdockService', 'Integrations::Flowdock'), - ('HangoutsChatService', 'Integrations::HangoutsChat'), - ('IrkerService', 'Integrations::Irker'), - ('JenkinsService', 'Integrations::Jenkins'), - ('JiraService', 'Integrations::Jira'), - ('MattermostService', 'Integrations::Mattermost'), - ('MattermostSlashCommandsService', 'Integrations::MattermostSlashCommands'), - ('MicrosoftTeamsService', 'Integrations::MicrosoftTeams'), - ('MockCiService', 'Integrations::MockCi'), - ('MockMonitoringService', 'Integrations::MockMonitoring'), - ('PackagistService', 'Integrations::Packagist'), - ('PipelinesEmailService', 'Integrations::PipelinesEmail'), - ('PivotaltrackerService', 'Integrations::Pivotaltracker'), - ('PrometheusService', 'Integrations::Prometheus'), - ('PushoverService', 'Integrations::Pushover'), - ('RedmineService', 'Integrations::Redmine'), - ('SlackService', 'Integrations::Slack'), - ('SlackSlashCommandsService', 'Integrations::SlackSlashCommands'), - ('TeamcityService', 'Integrations::Teamcity'), - ('UnifyCircuitService', 'Integrations::UnifyCircuit'), - ('YoutrackService', 'Integrations::Youtrack'), - ('WebexTeamsService', 'Integrations::WebexTeams'), - - -- EE-only integrations - ('GithubService', 'Integrations::Github'), - ('GitlabSlackApplicationService', 'Integrations::GitlabSlackApplication') - ) - - UPDATE integrations SET type_new = mapping.new_type - FROM mapping - WHERE integrations.id = NEW.id - AND mapping.old_type = NEW.type; - RETURN NULL; - SQL - end - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME} - AFTER INSERT ON integrations - FOR EACH ROW - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:integrations, TRIGGER_ON_INSERT_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20210721145029_add_state_to_members.rb b/db/migrate/20210721145029_add_state_to_members.rb deleted file mode 100644 index d727c858374..00000000000 --- a/db/migrate/20210721145029_add_state_to_members.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddStateToMembers < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb b/db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb deleted file mode 100644 index 00af9414ab7..00000000000 --- a/db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddIsRemovedToEscalationRules < ActiveRecord::Migration[6.1] - def change - add_column :incident_management_escalation_rules, :is_removed, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb b/db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb deleted file mode 100644 index cf52a43435f..00000000000 --- a/db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class UpdateEscalationRuleFkForPendingAlertEscalations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - OLD_FOREIGN_KEY_CONSTRAINT = 'fk_rails_057c1e3d87' - - # Swap foreign key contrainst from ON DELETE SET NULL to ON DELETE CASCADE - def up - remove_foreign_key_if_exists :incident_management_pending_alert_escalations, :incident_management_escalation_rules, name: OLD_FOREIGN_KEY_CONSTRAINT - - add_concurrent_partitioned_foreign_key :incident_management_pending_alert_escalations, - :incident_management_escalation_rules, - column: :rule_id - end - - def down - remove_foreign_key_if_exists :incident_management_pending_alert_escalations, :incident_management_escalation_rules, column: :rule_id - - add_concurrent_partitioned_foreign_key :incident_management_pending_alert_escalations, - :incident_management_escalation_rules, - column: :rule_id, - on_delete: :nullify, - name: OLD_FOREIGN_KEY_CONSTRAINT - end -end diff --git a/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb b/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb deleted file mode 100644 index 89adaf89693..00000000000 --- a/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class RemoveScheduleAndStatusNullConstraintsFromPendingEscalationsAlert < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - # In preparation of removal of these columns in 14.3. - def up - with_lock_retries do - change_column_null :incident_management_pending_alert_escalations, :status, true - change_column_null :incident_management_pending_alert_escalations, :schedule_id, true - end - end - - def down - backfill_from_rules_and_disallow_column_null :status, value: :status - backfill_from_rules_and_disallow_column_null :schedule_id, value: :oncall_schedule_id - end - - private - - def backfill_from_rules_and_disallow_column_null(column, value:) - with_lock_retries do - execute <<~SQL - UPDATE incident_management_pending_alert_escalations AS escalations - SET #{column} = rules.#{value} - FROM incident_management_escalation_rules AS rules - WHERE rule_id = rules.id - AND escalations.#{column} IS NULL - SQL - - change_column_null :incident_management_pending_alert_escalations, column, false - end - end -end diff --git a/db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb b/db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb deleted file mode 100644 index 3c0fa35d9c3..00000000000 --- a/db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddVulnerabilityAmountColumnIntoApprovalProjectRules < ActiveRecord::Migration[6.1] - def up - add_column :approval_project_rules, :vulnerabilities_allowed, :integer, limit: 2 - end - - def down - remove_column :approval_project_rules, :vulnerabilities_allowed - end -end diff --git a/db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb b/db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb deleted file mode 100644 index 7146c6c9537..00000000000 --- a/db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class RemoveNullConstraintOnScheduleFromEscalationRules < ActiveRecord::Migration[6.1] - def up - change_column_null :incident_management_escalation_rules, :oncall_schedule_id, true - end - - def down - exec_query 'DELETE FROM incident_management_escalation_rules WHERE oncall_schedule_id IS NULL' - - change_column_null :incident_management_escalation_rules, :oncall_schedule_id, false - end -end diff --git a/db/migrate/20210722074242_add_user_to_escalation_rules.rb b/db/migrate/20210722074242_add_user_to_escalation_rules.rb deleted file mode 100644 index 061dd6194f7..00000000000 --- a/db/migrate/20210722074242_add_user_to_escalation_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddUserToEscalationRules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :incident_management_escalation_rules, :user_id, :bigint, null: true - end - end - - def down - with_lock_retries do - remove_column :incident_management_escalation_rules, :user_id - end - end -end diff --git a/db/migrate/20210722074256_add_user_index_to_escalation_rules.rb b/db/migrate/20210722074256_add_user_index_to_escalation_rules.rb deleted file mode 100644 index 047149d6e7c..00000000000 --- a/db/migrate/20210722074256_add_user_index_to_escalation_rules.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class AddUserIndexToEscalationRules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - USER_INDEX_NAME = 'index_escalation_rules_on_user' - OLD_UNIQUE_INDEX_NAME = 'index_on_policy_schedule_status_elapsed_time_escalation_rules' - NEW_UNIQUE_INDEX_NAME = 'index_escalation_rules_on_all_attributes' - - def up - remove_concurrent_index_by_name :incident_management_escalation_rules, OLD_UNIQUE_INDEX_NAME - - add_concurrent_index :incident_management_escalation_rules, :user_id, name: USER_INDEX_NAME - add_concurrent_index :incident_management_escalation_rules, - [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds, :user_id], - unique: true, - name: NEW_UNIQUE_INDEX_NAME - end - - def down - remove_concurrent_index_by_name :incident_management_escalation_rules, USER_INDEX_NAME - remove_concurrent_index_by_name :incident_management_escalation_rules, NEW_UNIQUE_INDEX_NAME - - exec_query 'DELETE FROM incident_management_escalation_rules WHERE oncall_schedule_id IS NULL' - - add_concurrent_index :incident_management_escalation_rules, - [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds], - unique: true, - name: OLD_UNIQUE_INDEX_NAME - end -end diff --git a/db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb b/db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb deleted file mode 100644 index acdfc1ed835..00000000000 --- a/db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddUserFkToEscalationRules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :incident_management_escalation_rules, :users, column: :user_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :incident_management_escalation_rules, column: :user_id - end - end -end diff --git a/db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb b/db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb deleted file mode 100644 index bd140e1da56..00000000000 --- a/db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddXorCheckConstraintForEscalationRules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - CONSTRAINT_NAME = 'escalation_rules_one_of_oncall_schedule_or_user' - - def up - add_check_constraint :incident_management_escalation_rules, 'num_nonnulls(oncall_schedule_id, user_id) = 1', CONSTRAINT_NAME - end - - def down - remove_check_constraint :incident_management_escalation_rules, CONSTRAINT_NAME - end -end diff --git a/db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb b/db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb deleted file mode 100644 index 3f74f72454d..00000000000 --- a/db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class DevopsAdoptionDropRedundantIndexes < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_SAST = 'index_ci_job_artifacts_sast_for_devops_adoption' - INDEX_DAST = 'index_ci_job_artifacts_dast_for_devops_adoption' - - def up - remove_concurrent_index_by_name :ci_job_artifacts, INDEX_SAST - remove_concurrent_index_by_name :ci_job_artifacts, INDEX_DAST - end - - def down - add_concurrent_index :ci_job_artifacts, [:project_id, :created_at], where: "file_type = 5", name: INDEX_SAST - add_concurrent_index :ci_job_artifacts, [:project_id, :created_at], where: "file_type = 8", name: INDEX_DAST - end -end diff --git a/db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb b/db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb deleted file mode 100644 index 974559239d7..00000000000 --- a/db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class OperationsFeatureFlagsCorrectFlexibleRolloutValues < ActiveRecord::Migration[6.1] - STICKINESS = { "USERID" => "userId", "RANDOM" => "random", "SESSIONID" => "sessionId", "DEFAULT" => "default" }.freeze - - def up - STICKINESS.each do |before, after| - update_statement = <<-SQL - UPDATE operations_strategies - SET parameters = parameters || jsonb_build_object('stickiness', '#{quote_string(after)}') - WHERE name = 'flexibleRollout' AND parameters->>'stickiness' = '#{quote_string(before)}' - SQL - - execute(update_statement) - end - end - - def down - STICKINESS.each do |before, after| - update_statement = <<-SQL - UPDATE operations_strategies - SET parameters = parameters || jsonb_build_object('stickiness', '#{quote_string(before)}') - WHERE name = 'flexibleRollout' AND parameters->>'stickiness' = '#{quote_string(after)}' - SQL - - execute(update_statement) - end - end -end diff --git a/db/migrate/20210722151951_add_columns_to_security_scans.rb b/db/migrate/20210722151951_add_columns_to_security_scans.rb deleted file mode 100644 index 341cef057ce..00000000000 --- a/db/migrate/20210722151951_add_columns_to_security_scans.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddColumnsToSecurityScans < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :security_scans, :project_id, :bigint - add_column :security_scans, :pipeline_id, :bigint - end - end - - def down - with_lock_retries do - remove_column :security_scans, :project_id, :bigint - remove_column :security_scans, :pipeline_id, :bigint - end - end -end diff --git a/db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb b/db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb deleted file mode 100644 index 4678aba2cff..00000000000 --- a/db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddOverriddenUuidToSecurityFindings < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column :security_findings, :overridden_uuid, :uuid, null: true - end - end - - def down - with_lock_retries do - remove_column :security_findings, :overridden_uuid - end - end -end diff --git a/db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb b/db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb deleted file mode 100644 index cfaff4d0304..00000000000 --- a/db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class CreateIndexOnEnvironmentsAutoDeleteAt < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_environments_on_state_and_auto_delete_at' - - def up - add_concurrent_index :environments, - %i[auto_delete_at], - where: "auto_delete_at IS NOT NULL AND state = 'stopped'", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :environments, INDEX_NAME - end -end diff --git a/db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb b/db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb deleted file mode 100644 index 5fd558e0c1b..00000000000 --- a/db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddIntegratedToErrorTrackingSetting < ActiveRecord::Migration[6.1] - def up - add_column :project_error_tracking_settings, :integrated, :boolean, null: false, default: false - end - - def down - remove_column :project_error_tracking_settings, :integrated - end -end diff --git a/db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb b/db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb deleted file mode 100644 index bd17a9df5df..00000000000 --- a/db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddVulnerabilitySeveritiesIntoApprovalProjectRules < ActiveRecord::Migration[6.1] - def up - add_column :approval_project_rules, :severity_levels, :text, array: true, null: false, default: [] - end - - def down - remove_column :approval_project_rules, :severity_levels - end -end diff --git a/db/migrate/20210728110654_add_status_to_error_tracking_error.rb b/db/migrate/20210728110654_add_status_to_error_tracking_error.rb deleted file mode 100644 index 035f97dc963..00000000000 --- a/db/migrate/20210728110654_add_status_to_error_tracking_error.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToErrorTrackingError < ActiveRecord::Migration[6.1] - def up - add_column :error_tracking_errors, :status, :integer, null: false, default: 0, limit: 2 - end - - def down - remove_column :error_tracking_errors, :status - end -end diff --git a/db/migrate/20210728174349_add_fk_to_security_scans_columns.rb b/db/migrate/20210728174349_add_fk_to_security_scans_columns.rb deleted file mode 100644 index 418097b92e5..00000000000 --- a/db/migrate/20210728174349_add_fk_to_security_scans_columns.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddFkToSecurityScansColumns < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_index :security_scans, :project_id - add_concurrent_foreign_key :security_scans, :projects, column: :project_id, on_delete: :cascade - - add_concurrent_index :security_scans, :pipeline_id - end - - def down - remove_foreign_key :security_scans, column: :project_id - remove_concurrent_index_by_name :security_scans, name: 'index_security_scans_on_project_id' - - remove_concurrent_index_by_name :security_scans, name: 'index_security_scans_on_pipeline_id' - end -end diff --git a/db/migrate/20210729061526_add_pronunciation_to_user_details.rb b/db/migrate/20210729061526_add_pronunciation_to_user_details.rb deleted file mode 100644 index 6e0c8f1e808..00000000000 --- a/db/migrate/20210729061526_add_pronunciation_to_user_details.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddPronunciationToUserDetails < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210729061556_add_text_limit_to_user_details_pronunciation.rb - with_lock_retries do - add_column :user_details, :pronunciation, :text, null: true - end - # rubocop:enable Migration/AddLimitToTextColumns - end - - def down - with_lock_retries do - remove_column :user_details, :pronunciation - end - end -end diff --git a/db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb b/db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb deleted file mode 100644 index 5466ee7bafa..00000000000 --- a/db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToUserDetailsPronunciation < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_text_limit :user_details, :pronunciation, 255 - end - - def down - remove_text_limit :user_details, :pronunciation - end -end diff --git a/db/migrate/20210729081351_create_topics.rb b/db/migrate/20210729081351_create_topics.rb deleted file mode 100644 index 13ed2dc7ccc..00000000000 --- a/db/migrate/20210729081351_create_topics.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class CreateTopics < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :topics do |t| - t.text :name, null: false - t.text_limit :name, 255 - - t.index :name, unique: true - - t.timestamps_with_timezone - end - end - - def down - with_lock_retries do - drop_table :topics - end - end -end diff --git a/db/migrate/20210729081739_create_project_topics.rb b/db/migrate/20210729081739_create_project_topics.rb deleted file mode 100644 index cbb8842f653..00000000000 --- a/db/migrate/20210729081739_create_project_topics.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class CreateProjectTopics < ActiveRecord::Migration[6.1] - def change - create_table :project_topics do |t| - t.bigint :project_id, null: false - t.bigint :topic_id, null: false - - t.index :project_id - t.index :topic_id - t.index [:project_id, :topic_id], unique: true - - t.timestamps_with_timezone - end - end -end diff --git a/db/migrate/20210729123101_confirm_security_bot.rb b/db/migrate/20210729123101_confirm_security_bot.rb deleted file mode 100644 index 2184cc4e193..00000000000 --- a/db/migrate/20210729123101_confirm_security_bot.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class ConfirmSecurityBot < ActiveRecord::Migration[6.0] - class User < ActiveRecord::Base - self.table_name = 'users' - SECURITY_BOT_TYPE = 8 - end - - def up - User.where(user_type: User::SECURITY_BOT_TYPE, confirmed_at: nil) - .update_all(confirmed_at: Time.current) - end - - # no-op - # Security Bot should be always confirmed - def down - end -end diff --git a/db/migrate/20210729125641_add_foreign_key_to_project_on_project_topic.rb b/db/migrate/20210729125641_add_foreign_key_to_project_on_project_topic.rb deleted file mode 100644 index 27cf5c60cf0..00000000000 --- a/db/migrate/20210729125641_add_foreign_key_to_project_on_project_topic.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToProjectOnProjectTopic < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :project_topics, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :project_topics, column: :project_id - end - end -end diff --git a/db/migrate/20210729125659_add_foreign_key_to_topic_on_project_topic.rb b/db/migrate/20210729125659_add_foreign_key_to_topic_on_project_topic.rb deleted file mode 100644 index 1ada08dca1a..00000000000 --- a/db/migrate/20210729125659_add_foreign_key_to_topic_on_project_topic.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToTopicOnProjectTopic < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :project_topics, :topics, column: :topic_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :project_topics, column: :topic_id - end - end -end diff --git a/db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb b/db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb deleted file mode 100644 index 2193a698272..00000000000 --- a/db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class RemoveForeignKeysFromCiTestCaseFailures < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - TABLE_NAME = :ci_test_case_failures - - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(TABLE_NAME, column: :build_id) - end - - with_lock_retries do - remove_foreign_key_if_exists(TABLE_NAME, column: :test_case_id) - end - end - - def down - add_concurrent_foreign_key(TABLE_NAME, :ci_builds, column: :build_id, on_delete: :cascade) - add_concurrent_foreign_key(TABLE_NAME, :ci_test_cases, column: :test_case_id, on_delete: :cascade) - end -end diff --git a/db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb b/db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb deleted file mode 100644 index 1d0a5f4fd64..00000000000 --- a/db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class RemoveForeignKeysFromCiTestCases < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - TABLE_NAME = :ci_test_cases - - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(TABLE_NAME, column: :project_id) - end - end - - def down - add_concurrent_foreign_key(TABLE_NAME, :projects, column: :project_id, on_delete: :cascade) - end -end diff --git a/db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb b/db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb deleted file mode 100644 index b16904a3b47..00000000000 --- a/db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class CreateIncidentManagementIssuableEscalationStatuses < ActiveRecord::Migration[6.1] - ISSUE_IDX = 'index_uniq_im_issuable_escalation_statuses_on_issue_id' - POLICY_IDX = 'index_im_issuable_escalation_statuses_on_policy_id' - - def change - create_table :incident_management_issuable_escalation_statuses do |t| - t.timestamps_with_timezone - - t.references :issue, foreign_key: { on_delete: :cascade }, index: { unique: true, name: ISSUE_IDX }, null: false - t.references :policy, foreign_key: { to_table: :incident_management_escalation_policies, on_delete: :nullify }, index: { name: POLICY_IDX } - - t.datetime_with_timezone :escalations_started_at - t.datetime_with_timezone :resolved_at - - t.integer :status, default: 0, null: false, limit: 2 - end - end -end diff --git a/db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb b/db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb deleted file mode 100644 index ad517fbbff0..00000000000 --- a/db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class CreateAnalyticsCycleAnalyticsStageEventHashes < ActiveRecord::Migration[6.1] - def change - create_table :analytics_cycle_analytics_stage_event_hashes do |t| - t.binary :hash_sha256 - t.index :hash_sha256, unique: true, name: 'index_cycle_analytics_stage_event_hashes_on_hash_sha_256' - end - end -end diff --git a/db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb b/db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb deleted file mode 100644 index 2909df78a6a..00000000000 --- a/db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddStageHashFkToProjectStages < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - unless column_exists?(:analytics_cycle_analytics_project_stages, :stage_event_hash_id) - add_column :analytics_cycle_analytics_project_stages, :stage_event_hash_id, :bigint - end - - add_concurrent_index :analytics_cycle_analytics_project_stages, :stage_event_hash_id, name: 'index_project_stages_on_stage_event_hash_id' - add_concurrent_foreign_key :analytics_cycle_analytics_project_stages, :analytics_cycle_analytics_stage_event_hashes, column: :stage_event_hash_id, on_delete: :cascade - end - - def down - remove_column :analytics_cycle_analytics_project_stages, :stage_event_hash_id - end -end diff --git a/db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb b/db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb deleted file mode 100644 index 3cd53f2bb50..00000000000 --- a/db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddStageHashFkToGroupStages < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - unless column_exists?(:analytics_cycle_analytics_group_stages, :stage_event_hash_id) - add_column :analytics_cycle_analytics_group_stages, :stage_event_hash_id, :bigint - end - - add_concurrent_index :analytics_cycle_analytics_group_stages, :stage_event_hash_id, name: 'index_group_stages_on_stage_event_hash_id' - add_concurrent_foreign_key :analytics_cycle_analytics_group_stages, :analytics_cycle_analytics_stage_event_hashes, column: :stage_event_hash_id, on_delete: :cascade - end - - def down - remove_column :analytics_cycle_analytics_group_stages, :stage_event_hash_id - end -end diff --git a/db/migrate/20210730194555_create_incident_management_pending_issue_escalations.rb b/db/migrate/20210730194555_create_incident_management_pending_issue_escalations.rb deleted file mode 100644 index 20a6fde96ff..00000000000 --- a/db/migrate/20210730194555_create_incident_management_pending_issue_escalations.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class CreateIncidentManagementPendingIssueEscalations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - execute(<<~SQL) - CREATE TABLE incident_management_pending_issue_escalations ( - id bigserial NOT NULL, - rule_id bigint NOT NULL, - issue_id bigint NOT NULL, - process_at timestamp with time zone NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - PRIMARY KEY (id, process_at) - ) PARTITION BY RANGE (process_at); - - CREATE INDEX index_incident_management_pending_issue_escalations_on_issue_id - ON incident_management_pending_issue_escalations USING btree (issue_id); - - CREATE INDEX index_incident_management_pending_issue_escalations_on_rule_id - ON incident_management_pending_issue_escalations USING btree (rule_id); - SQL - end - end - - def down - with_lock_retries do - drop_table :incident_management_pending_issue_escalations - end - end -end diff --git a/db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb b/db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb deleted file mode 100644 index 38d72496484..00000000000 --- a/db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexToVulnerabilityFlagsTable < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_vulnerability_flags_on_unique_columns' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_flags, [:vulnerability_occurrence_id, :flag_type, :origin], name: INDEX_NAME, unique: true - end - - def down - remove_concurrent_index_by_name :vulnerability_flags, INDEX_NAME - end -end diff --git a/db/migrate/20210804150320_create_base_work_item_types.rb b/db/migrate/20210804150320_create_base_work_item_types.rb deleted file mode 100644 index 836264aae6e..00000000000 --- a/db/migrate/20210804150320_create_base_work_item_types.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class CreateBaseWorkItemTypes < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - module WorkItem - class Type < ActiveRecord::Base - self.table_name = 'work_item_types' - - enum base_type: { - issue: 0, - incident: 1, - test_case: 2, - requirement: 3 - } - - validates :name, uniqueness: { case_sensitive: false, scope: [:namespace_id] } - end - end - - def up - # create default types - WorkItem::Type.create(name: 'Issue', namespace_id: nil, base_type: :issue, icon_name: 'issue-type-issue') - WorkItem::Type.create(name: 'Incident', namespace_id: nil, base_type: :incident, icon_name: 'issue-type-incident') - WorkItem::Type.create(name: 'Test Case', namespace_id: nil, base_type: :test_case, icon_name: 'issue-type-test-case') - WorkItem::Type.create(name: 'Requirement', namespace_id: nil, base_type: :requirement, icon_name: 'issue-type-requirements') - end - - def down - # We expect this table to be empty at the point of the up migration, - # however there is a remote possibility that issues could already be - # using one of these types, with a tight foreign constraint. - # Therefore we will not attempt to remove any data. - end -end diff --git a/db/migrate/20210804200114_create_customer_relations_organizations.rb b/db/migrate/20210804200114_create_customer_relations_organizations.rb deleted file mode 100644 index 9936e97b9bf..00000000000 --- a/db/migrate/20210804200114_create_customer_relations_organizations.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class CreateCustomerRelationsOrganizations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :customer_relations_organizations do |t| - t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade } - t.timestamps_with_timezone null: false - t.integer :state, limit: 1, default: 1, null: false - t.decimal :default_rate, precision: 18, scale: 2 - t.text :name, null: false - t.text :description - - t.text_limit :name, 255 - t.text_limit :description, 1024 - - t.index 'group_id, LOWER(name)', unique: true, name: :index_customer_relations_organizations_on_unique_name_per_group - end - end - - def down - with_lock_retries do - drop_table :customer_relations_organizations - end - end -end diff --git a/db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb b/db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb deleted file mode 100644 index 66fcf485b2f..00000000000 --- a/db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb +++ /dev/null @@ -1,20 +0,0 @@ -# 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 AddTmpIndexApprovalProjectRulesScanners < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'tmp_index_approval_project_rules_scanners' - - disable_ddl_transaction! - - def up - add_concurrent_index :approval_project_rules, :scanners, name: INDEX_NAME, using: :gin, where: "scanners @> '{cluster_image_scanning}'" - end - - def down - remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME - end -end diff --git a/db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb b/db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb deleted file mode 100644 index ea77e29d365..00000000000 --- a/db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddRuleIndexToSecurityOrchestrationPolicyRuleSchedules < ActiveRecord::Migration[6.1] - def change - add_column :security_orchestration_policy_rule_schedules, :rule_index, :integer, null: false, default: 0 - end -end diff --git a/db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb b/db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb deleted file mode 100644 index 34f8ec43a8f..00000000000 --- a/db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddPypiPackageRequestsForwardingToApplicationSettings < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - add_column(:application_settings, :pypi_package_requests_forwarding, :boolean, default: true, null: false) - end - end - - def down - with_lock_retries do - remove_column(:application_settings, :pypi_package_requests_forwarding) - end - end -end diff --git a/db/migrate/20210807101446_add_cadence_to_dast_profile_schedules.rb b/db/migrate/20210807101446_add_cadence_to_dast_profile_schedules.rb deleted file mode 100644 index c9b17e3d5c5..00000000000 --- a/db/migrate/20210807101446_add_cadence_to_dast_profile_schedules.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddCadenceToDastProfileSchedules < ActiveRecord::Migration[6.1] - def change - add_column :dast_profile_schedules, :cadence, :jsonb, null: false, default: {} - end -end diff --git a/db/migrate/20210807101621_add_timezone_to_dast_profile_schedules.rb b/db/migrate/20210807101621_add_timezone_to_dast_profile_schedules.rb deleted file mode 100644 index 3c3eb507432..00000000000 --- a/db/migrate/20210807101621_add_timezone_to_dast_profile_schedules.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class AddTimezoneToDastProfileSchedules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - # We disable these cops here because adding the column is safe. The table does not - # have any data in it as it's behind a feature flag. - # rubocop: disable Rails/NotNullColumn - def up - execute('DELETE FROM dast_profile_schedules') - - unless column_exists?(:dast_profile_schedules, :timezone) - add_column :dast_profile_schedules, :timezone, :text, null: false - end - - add_text_limit :dast_profile_schedules, :timezone, 255 - end - - def down - return unless column_exists?(:dast_profile_schedules, :timezone) - - remove_column :dast_profile_schedules, :timezone - end -end diff --git a/db/migrate/20210807102004_add_starts_at_to_dast_profile_schedules.rb b/db/migrate/20210807102004_add_starts_at_to_dast_profile_schedules.rb deleted file mode 100644 index 4eea5fd7e8c..00000000000 --- a/db/migrate/20210807102004_add_starts_at_to_dast_profile_schedules.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStartsAtToDastProfileSchedules < ActiveRecord::Migration[6.1] - def change - add_column :dast_profile_schedules, :starts_at, :datetime_with_timezone, null: false, default: -> { 'NOW()' } - end -end diff --git a/db/migrate/20210809014850_create_agent_group_authorizations.rb b/db/migrate/20210809014850_create_agent_group_authorizations.rb deleted file mode 100644 index 43d7e63e0a2..00000000000 --- a/db/migrate/20210809014850_create_agent_group_authorizations.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class CreateAgentGroupAuthorizations < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def change - create_table :agent_group_authorizations do |t| - t.bigint :group_id, null: false - t.bigint :agent_id, null: false - t.jsonb :config, null: false - - t.index :group_id - t.index [:agent_id, :group_id], unique: true - end - end -end diff --git a/db/migrate/20210809014918_add_agent_group_authorizations_foreign_keys.rb b/db/migrate/20210809014918_add_agent_group_authorizations_foreign_keys.rb deleted file mode 100644 index 2a3a51d0ca9..00000000000 --- a/db/migrate/20210809014918_add_agent_group_authorizations_foreign_keys.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddAgentGroupAuthorizationsForeignKeys < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :agent_group_authorizations, :namespaces, column: :group_id - add_concurrent_foreign_key :agent_group_authorizations, :cluster_agents, column: :agent_id - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :agent_group_authorizations, column: :group_id - end - - with_lock_retries do - remove_foreign_key_if_exists :agent_group_authorizations, column: :agent_id - end - end -end diff --git a/db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb b/db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb deleted file mode 100644 index 76308e2ea8e..00000000000 --- a/db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RenameTablesCiBuildTraceSection < ActiveRecord::Migration[6.1] - DOWNTIME = false - - def change - # Shorten deprecated to dep to avoid 'Index name..too long' - rename_table(:ci_build_trace_sections, :dep_ci_build_trace_sections) - rename_table(:ci_build_trace_section_names, :dep_ci_build_trace_section_names) - end -end diff --git a/db/migrate/20210811120204_create_customer_relations_contacts.rb b/db/migrate/20210811120204_create_customer_relations_contacts.rb deleted file mode 100644 index 0c26ee0ef59..00000000000 --- a/db/migrate/20210811120204_create_customer_relations_contacts.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class CreateCustomerRelationsContacts < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - create_table_with_constraints :customer_relations_contacts do |t| - t.bigint :group_id, null: false - t.references :organization, index: true, null: true, foreign_key: { to_table: :customer_relations_organizations, on_delete: :cascade } - t.timestamps_with_timezone null: false - t.integer :state, limit: 1, default: 1, null: false - t.text :phone - t.text :first_name, null: false - t.text :last_name, null: false - t.text :email - t.text :description - - t.text_limit :phone, 32 - t.text_limit :first_name, 255 - t.text_limit :last_name, 255 - t.text_limit :email, 255 - t.text_limit :description, 1024 - end - end - - def down - with_lock_retries do - drop_table :customer_relations_contacts - end - end -end diff --git a/db/migrate/20210811193033_add_unique_index_to_vulnerability_finding_links.rb b/db/migrate/20210811193033_add_unique_index_to_vulnerability_finding_links.rb deleted file mode 100644 index cf51bca630a..00000000000 --- a/db/migrate/20210811193033_add_unique_index_to_vulnerability_finding_links.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexToVulnerabilityFindingLinks < Gitlab::Database::Migration[1.0] - # This migration has been moved to db/post_migrate/20220201193033_add_unique_index_to_vulnerability_finding_links_with_truncate.rb - # Previously, this was causing an bug where there was a conflict between the table cleanup and the index creation. - - def up - # no op - end - - def down - # no op - end -end diff --git a/db/migrate/20210812171704_create_project_ci_feature_usages.rb b/db/migrate/20210812171704_create_project_ci_feature_usages.rb deleted file mode 100644 index 376512bcb44..00000000000 --- a/db/migrate/20210812171704_create_project_ci_feature_usages.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class CreateProjectCiFeatureUsages < ActiveRecord::Migration[6.1] - def change - create_table :project_ci_feature_usages do |t| - t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false - t.integer :feature, null: false, limit: 2 - t.boolean :default_branch, default: false, null: false - t.index [:project_id, :feature, :default_branch], unique: true, name: 'index_project_ci_feature_usages_unique_columns' - end - end -end diff --git a/db/migrate/20210813101742_create_zentao_tracker_data.rb b/db/migrate/20210813101742_create_zentao_tracker_data.rb deleted file mode 100644 index 93d9cde3371..00000000000 --- a/db/migrate/20210813101742_create_zentao_tracker_data.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateZentaoTrackerData < ActiveRecord::Migration[6.1] - def change - create_table :zentao_tracker_data do |t| - t.references :integration, foreign_key: { on_delete: :cascade }, type: :bigint, index: true, null: false - t.timestamps_with_timezone - t.binary :encrypted_url - t.binary :encrypted_url_iv - t.binary :encrypted_api_url - t.binary :encrypted_api_url_iv - t.binary :encrypted_zentao_product_xid - t.binary :encrypted_zentao_product_xid_iv - t.binary :encrypted_api_token - t.binary :encrypted_api_token_iv - end - end -end diff --git a/db/migrate/20210813111909_create_ci_build_trace_metadata.rb b/db/migrate/20210813111909_create_ci_build_trace_metadata.rb deleted file mode 100644 index d8b7fd656e0..00000000000 --- a/db/migrate/20210813111909_create_ci_build_trace_metadata.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class CreateCiBuildTraceMetadata < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - create_table :ci_build_trace_metadata, id: false, if_not_exists: true do |t| - t.references :build, - index: false, - primary_key: true, - default: nil, - foreign_key: { to_table: :ci_builds, on_delete: :cascade }, - type: :bigint, - null: false - - t.bigint :trace_artifact_id - t.integer :archival_attempts, default: 0, null: false, limit: 2 - t.binary :checksum - t.binary :remote_checksum - - t.index :trace_artifact_id - end - end - end - - def down - with_lock_retries do - drop_table :ci_build_trace_metadata, if_exists: true - end - end -end diff --git a/db/migrate/20210813131313_create_foreign_key_on_contacts_group_id.rb b/db/migrate/20210813131313_create_foreign_key_on_contacts_group_id.rb deleted file mode 100644 index 58b2471a96a..00000000000 --- a/db/migrate/20210813131313_create_foreign_key_on_contacts_group_id.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class CreateForeignKeyOnContactsGroupId < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_customer_relations_contacts_on_group_id' - - def up - add_concurrent_index :customer_relations_contacts, :group_id, name: INDEX_NAME - add_concurrent_foreign_key :customer_relations_contacts, :namespaces, column: :group_id - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :customer_relations_contacts, column: :group_id - end - - remove_concurrent_index_by_name :customer_relations_contacts, INDEX_NAME - end -end diff --git a/db/migrate/20210816095826_add_unique_index_on_dast_profile_to_dast_profile_schedules.rb b/db/migrate/20210816095826_add_unique_index_on_dast_profile_to_dast_profile_schedules.rb deleted file mode 100644 index b7ea8545df1..00000000000 --- a/db/migrate/20210816095826_add_unique_index_on_dast_profile_to_dast_profile_schedules.rb +++ /dev/null @@ -1,38 +0,0 @@ -# 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 AddUniqueIndexOnDastProfileToDastProfileSchedules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_dast_profile_schedules_on_dast_profile_id' - TABLE = :dast_profile_schedules - # We disable these cops here because changing this index is safe. The table does not - # have any data in it as it's behind a feature flag. - # rubocop: disable Migration/AddIndex - # rubocop: disable Migration/RemoveIndex - def up - execute('DELETE FROM dast_profile_schedules') - - if index_exists_by_name?(TABLE, INDEX_NAME) - remove_index TABLE, :dast_profile_id, name: INDEX_NAME - end - - unless index_exists_by_name?(TABLE, INDEX_NAME) - add_index TABLE, :dast_profile_id, unique: true, name: INDEX_NAME - end - end - - def down - execute('DELETE FROM dast_profile_schedules') - - if index_exists_by_name?(TABLE, INDEX_NAME) - remove_index TABLE, :dast_profile_id, name: INDEX_NAME - end - - unless index_exists_by_name?(TABLE, INDEX_NAME) - add_index TABLE, :dast_profile_id - end - end -end diff --git a/db/migrate/20210816161107_remove_index_containing_faulty_regex.rb b/db/migrate/20210816161107_remove_index_containing_faulty_regex.rb deleted file mode 100644 index d625ae6d13d..00000000000 --- a/db/migrate/20210816161107_remove_index_containing_faulty_regex.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexContainingFaultyRegex < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = "tmp_index_merge_requests_draft_and_status" - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :merge_requests, INDEX_NAME - end - - def down - # noop - # - end -end diff --git a/db/migrate/20210816192041_add_invites_email_success_to_member.rb b/db/migrate/20210816192041_add_invites_email_success_to_member.rb deleted file mode 100644 index 89f475b056c..00000000000 --- a/db/migrate/20210816192041_add_invites_email_success_to_member.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddInvitesEmailSuccessToMember < ActiveRecord::Migration[6.1] - def up - unless column_exists?(:members, :invite_email_success) - add_column :members, :invite_email_success, :boolean, null: false, default: true - end - end - - def down - remove_column :members, :invite_email_success - end -end diff --git a/db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb b/db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb deleted file mode 100644 index 032b15234d8..00000000000 --- a/db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyFromCiBuildMetadataToCiJobArtifacts < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :ci_build_trace_metadata, - :ci_job_artifacts, - column: :trace_artifact_id, - on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :ci_build_trace_metadata, column: :trace_artifact_id - end - end -end diff --git a/db/migrate/20210817130415_add_project_id_name_version_id_to_npm_packages.rb b/db/migrate/20210817130415_add_project_id_name_version_id_to_npm_packages.rb deleted file mode 100644 index e4b681d66fb..00000000000 --- a/db/migrate/20210817130415_add_project_id_name_version_id_to_npm_packages.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddProjectIdNameVersionIdToNpmPackages < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'idx_installable_npm_pkgs_on_project_id_name_version_id' - - def up - add_concurrent_index :packages_packages, [:project_id, :name, :version, :id], where: 'package_type = 2 AND status = 0', name: INDEX_NAME - end - - def down - remove_concurrent_index :packages_packages, [:project_id, :name, :version, :id], where: 'package_type = 2 AND status = 0', name: INDEX_NAME - end -end diff --git a/db/migrate/20210817172214_add_yaml_limits_application_setting.rb b/db/migrate/20210817172214_add_yaml_limits_application_setting.rb deleted file mode 100644 index f502ef9825b..00000000000 --- a/db/migrate/20210817172214_add_yaml_limits_application_setting.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddYamlLimitsApplicationSetting < ActiveRecord::Migration[6.1] - DOWNTIME = false - - def change - add_column :application_settings, :max_yaml_size_bytes, :bigint, default: 1.megabyte, null: false - add_column :application_settings, :max_yaml_depth, :integer, default: 100, null: false - end -end diff --git a/db/migrate/20210818034001_index_historical_data_on_recorded_at.rb b/db/migrate/20210818034001_index_historical_data_on_recorded_at.rb deleted file mode 100644 index 791c5b60e54..00000000000 --- a/db/migrate/20210818034001_index_historical_data_on_recorded_at.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class IndexHistoricalDataOnRecordedAt < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - INDEX_NAME = 'index_historical_data_on_recorded_at' - - disable_ddl_transaction! - - def up - add_concurrent_index :historical_data, :recorded_at, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :historical_data, INDEX_NAME - end -end diff --git a/db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb b/db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb deleted file mode 100644 index d9d05f2b737..00000000000 --- a/db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueCommitDesignUserMentionIndexes < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - COMMIT_INDEX_NAME = 'commit_id_and_note_id_index' - DESIGN_INDEX_NAME = 'design_user_mentions_on_design_id_and_note_id_index' - - COMMIT_UNIQUE_INDEX_NAME = 'commit_user_mentions_on_commit_id_and_note_id_unique_index' - DESIGN_UNIQUE_INDEX_NAME = 'design_user_mentions_on_design_id_and_note_id_unique_index' - - def up - add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], unique: true, name: COMMIT_UNIQUE_INDEX_NAME - add_concurrent_index :design_user_mentions, [:design_id, :note_id], unique: true, name: DESIGN_UNIQUE_INDEX_NAME - - remove_concurrent_index_by_name :commit_user_mentions, COMMIT_INDEX_NAME - remove_concurrent_index_by_name :design_user_mentions, DESIGN_INDEX_NAME - end - - def down - add_concurrent_index :design_user_mentions, [:design_id, :note_id], name: DESIGN_INDEX_NAME - add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], name: COMMIT_INDEX_NAME - - remove_concurrent_index_by_name :design_user_mentions, DESIGN_UNIQUE_INDEX_NAME - remove_concurrent_index_by_name :commit_user_mentions, COMMIT_UNIQUE_INDEX_NAME - end -end diff --git a/db/migrate/20210818061156_remove_project_profile_compound_index_from_dast_profile_schedules.rb b/db/migrate/20210818061156_remove_project_profile_compound_index_from_dast_profile_schedules.rb deleted file mode 100644 index b50947a0a99..00000000000 --- a/db/migrate/20210818061156_remove_project_profile_compound_index_from_dast_profile_schedules.rb +++ /dev/null @@ -1,30 +0,0 @@ -# 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 RemoveProjectProfileCompoundIndexFromDastProfileSchedules < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - TABLE = :dast_profile_schedules - INDEX_NAME = 'index_dast_profile_schedules_on_project_id_and_dast_profile_id' - # We disable these cops here because changing this index is safe. The table does not - # have any data in it as it's behind a feature flag. - # rubocop: disable Migration/AddIndex - # rubocop: disable Migration/RemoveIndex - def up - execute('DELETE FROM dast_profile_schedules') - - if index_exists_by_name?(TABLE, INDEX_NAME) - remove_index TABLE, %i[project_id dast_profile_id], name: INDEX_NAME - end - end - - def down - execute('DELETE FROM dast_profile_schedules') - - unless index_exists_by_name?(TABLE, INDEX_NAME) - add_index TABLE, %i[project_id dast_profile_id], unique: true, name: INDEX_NAME - end - end -end diff --git a/db/migrate/20210818115613_add_index_project_id_on_dast_profile_schedule.rb b/db/migrate/20210818115613_add_index_project_id_on_dast_profile_schedule.rb deleted file mode 100644 index 392b335ab45..00000000000 --- a/db/migrate/20210818115613_add_index_project_id_on_dast_profile_schedule.rb +++ /dev/null @@ -1,13 +0,0 @@ -# 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 AddIndexProjectIdOnDastProfileSchedule < ActiveRecord::Migration[6.1] - # We disable these cops here because changing this index is safe. The table does not - # have any data in it as it's behind a feature flag. - # rubocop: disable Migration/AddIndex - def change - add_index :dast_profile_schedules, :project_id - end -end diff --git a/db/migrate/20210818175949_update_integrations_trigger_type_new_on_insert.rb b/db/migrate/20210818175949_update_integrations_trigger_type_new_on_insert.rb deleted file mode 100644 index 2999a6fd4f6..00000000000 --- a/db/migrate/20210818175949_update_integrations_trigger_type_new_on_insert.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -class UpdateIntegrationsTriggerTypeNewOnInsert < ActiveRecord::Migration[6.1] - include Gitlab::Database::SchemaHelpers - - FUNCTION_NAME = 'integrations_set_type_new' - - def up - # Update `type_new` dynamically based on `type`. - # - # The old class names are in the format `AbcService`, and the new ones `Integrations::Abc`. - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE integrations SET type_new = regexp_replace(NEW.type, '\\A(.+)Service\\Z', 'Integrations::\\1') - WHERE integrations.id = NEW.id; - RETURN NULL; - SQL - end - end - - def down - # We initially went with this static mapping since we assumed that new integrations could - # just use the correct class name directly in `type`, but this will complicate the data migration - # since we plan to drop `type` at some point and replace it with `type_new`, so we still need - # to keep this column filled for all records. - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - WITH mapping(old_type, new_type) AS (VALUES - ('AsanaService', 'Integrations::Asana'), - ('AssemblaService', 'Integrations::Assembla'), - ('BambooService', 'Integrations::Bamboo'), - ('BugzillaService', 'Integrations::Bugzilla'), - ('BuildkiteService', 'Integrations::Buildkite'), - ('CampfireService', 'Integrations::Campfire'), - ('ConfluenceService', 'Integrations::Confluence'), - ('CustomIssueTrackerService', 'Integrations::CustomIssueTracker'), - ('DatadogService', 'Integrations::Datadog'), - ('DiscordService', 'Integrations::Discord'), - ('DroneCiService', 'Integrations::DroneCi'), - ('EmailsOnPushService', 'Integrations::EmailsOnPush'), - ('EwmService', 'Integrations::Ewm'), - ('ExternalWikiService', 'Integrations::ExternalWiki'), - ('FlowdockService', 'Integrations::Flowdock'), - ('HangoutsChatService', 'Integrations::HangoutsChat'), - ('IrkerService', 'Integrations::Irker'), - ('JenkinsService', 'Integrations::Jenkins'), - ('JiraService', 'Integrations::Jira'), - ('MattermostService', 'Integrations::Mattermost'), - ('MattermostSlashCommandsService', 'Integrations::MattermostSlashCommands'), - ('MicrosoftTeamsService', 'Integrations::MicrosoftTeams'), - ('MockCiService', 'Integrations::MockCi'), - ('MockMonitoringService', 'Integrations::MockMonitoring'), - ('PackagistService', 'Integrations::Packagist'), - ('PipelinesEmailService', 'Integrations::PipelinesEmail'), - ('PivotaltrackerService', 'Integrations::Pivotaltracker'), - ('PrometheusService', 'Integrations::Prometheus'), - ('PushoverService', 'Integrations::Pushover'), - ('RedmineService', 'Integrations::Redmine'), - ('SlackService', 'Integrations::Slack'), - ('SlackSlashCommandsService', 'Integrations::SlackSlashCommands'), - ('TeamcityService', 'Integrations::Teamcity'), - ('UnifyCircuitService', 'Integrations::UnifyCircuit'), - ('YoutrackService', 'Integrations::Youtrack'), - ('WebexTeamsService', 'Integrations::WebexTeams'), - - -- EE-only integrations - ('GithubService', 'Integrations::Github'), - ('GitlabSlackApplicationService', 'Integrations::GitlabSlackApplication') - ) - - UPDATE integrations SET type_new = mapping.new_type - FROM mapping - WHERE integrations.id = NEW.id - AND mapping.old_type = NEW.type; - RETURN NULL; - SQL - end - end -end diff --git a/db/migrate/20210818185548_add_tag_ids_index_to_ci_pending_build.rb b/db/migrate/20210818185548_add_tag_ids_index_to_ci_pending_build.rb deleted file mode 100644 index b8e00ed9db0..00000000000 --- a/db/migrate/20210818185548_add_tag_ids_index_to_ci_pending_build.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddTagIdsIndexToCiPendingBuild < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_pending_builds_on_tag_ids' - - def up - add_concurrent_index(:ci_pending_builds, :tag_ids, name: INDEX_NAME, where: 'cardinality(tag_ids) > 0') - end - - def down - remove_concurrent_index_by_name(:ci_pending_builds, name: INDEX_NAME) - end -end diff --git a/db/migrate/20210818193008_add_file_template_project_to_service_desk_settings.rb b/db/migrate/20210818193008_add_file_template_project_to_service_desk_settings.rb deleted file mode 100644 index 4cfd54ac348..00000000000 --- a/db/migrate/20210818193008_add_file_template_project_to_service_desk_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddFileTemplateProjectToServiceDeskSettings < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def change - add_column :service_desk_settings, :file_template_project_id, :bigint, null: true - end -end diff --git a/db/migrate/20210818200455_add_file_template_project_foreign_key_to_service_desk_settings.rb b/db/migrate/20210818200455_add_file_template_project_foreign_key_to_service_desk_settings.rb deleted file mode 100644 index cc8aeecd2b5..00000000000 --- a/db/migrate/20210818200455_add_file_template_project_foreign_key_to_service_desk_settings.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddFileTemplateProjectForeignKeyToServiceDeskSettings < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_service_desk_settings_on_file_template_project_id' - - def up - add_concurrent_index :service_desk_settings, :file_template_project_id, name: INDEX_NAME - add_concurrent_foreign_key :service_desk_settings, :projects, column: :file_template_project_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :service_desk_settings, column: :file_template_project_id - end - - remove_concurrent_index_by_name :service_desk_settings, name: INDEX_NAME - end -end diff --git a/db/migrate/20210818220234_add_default_project_approval_rules_vuln_allowed.rb b/db/migrate/20210818220234_add_default_project_approval_rules_vuln_allowed.rb deleted file mode 100644 index 72d2755effa..00000000000 --- a/db/migrate/20210818220234_add_default_project_approval_rules_vuln_allowed.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddDefaultProjectApprovalRulesVulnAllowed < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DEFAULT_VALUE = 0 - - def up - change_column_default :approval_project_rules, :vulnerabilities_allowed, DEFAULT_VALUE - - update_column_in_batches(:approval_project_rules, :vulnerabilities_allowed, DEFAULT_VALUE) do |table, query| - query.where(table[:vulnerabilities_allowed].eq(nil)) - end - - change_column_null :approval_project_rules, :vulnerabilities_allowed, false - end - - def down - change_column_default :approval_project_rules, :vulnerabilities_allowed, nil - change_column_null :approval_project_rules, :vulnerabilities_allowed, true - end -end diff --git a/db/migrate/20210819120243_add_throttle_files_api_columns.rb b/db/migrate/20210819120243_add_throttle_files_api_columns.rb deleted file mode 100644 index ace093c7b0c..00000000000 --- a/db/migrate/20210819120243_add_throttle_files_api_columns.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddThrottleFilesApiColumns < ActiveRecord::Migration[6.1] - def change - add_column :application_settings, :throttle_unauthenticated_files_api_requests_per_period, :integer, default: 125, null: false - add_column :application_settings, :throttle_unauthenticated_files_api_period_in_seconds, :integer, default: 15, null: false - add_column :application_settings, :throttle_authenticated_files_api_requests_per_period, :integer, default: 500, null: false - add_column :application_settings, :throttle_authenticated_files_api_period_in_seconds, :integer, default: 15, null: false - - add_column :application_settings, :throttle_unauthenticated_files_api_enabled, :boolean, default: false, null: false - add_column :application_settings, :throttle_authenticated_files_api_enabled, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb b/db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb deleted file mode 100644 index a60141991a6..00000000000 --- a/db/migrate/20210819152723_remove_tmp_index_approval_project_rules_scanners.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexApprovalProjectRulesScanners < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_approval_project_rules_scanners' - - def up - remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME - end - - def down - add_concurrent_index :approval_project_rules, :scanners, name: INDEX_NAME, using: :gin, where: "scanners @> '{cluster_image_scanning}'" - end -end diff --git a/db/migrate/20210819153805_set_default_job_token_scope_true.rb b/db/migrate/20210819153805_set_default_job_token_scope_true.rb deleted file mode 100644 index 4536f664950..00000000000 --- a/db/migrate/20210819153805_set_default_job_token_scope_true.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class SetDefaultJobTokenScopeTrue < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: false, to: true - end - end - - def down - with_lock_retries do - change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: true, to: false - end - end -end diff --git a/db/migrate/20210819162047_add_columns_to_namespace_settings.rb b/db/migrate/20210819162047_add_columns_to_namespace_settings.rb deleted file mode 100644 index f617990582a..00000000000 --- a/db/migrate/20210819162047_add_columns_to_namespace_settings.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddColumnsToNamespaceSettings < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :namespace_settings, :setup_for_company, :boolean - add_column :namespace_settings, :jobs_to_be_done, :smallint - end - end - - def down - with_lock_retries do - remove_column :namespace_settings, :setup_for_company - remove_column :namespace_settings, :jobs_to_be_done - end - end -end diff --git a/db/migrate/20210819185500_create_external_audit_event_destinations_table.rb b/db/migrate/20210819185500_create_external_audit_event_destinations_table.rb deleted file mode 100644 index bf0725a77a0..00000000000 --- a/db/migrate/20210819185500_create_external_audit_event_destinations_table.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CreateExternalAuditEventDestinationsTable < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - create_table :audit_events_external_audit_event_destinations do |t| - t.references :namespace, index: false, null: false, foreign_key: { on_delete: :cascade } - t.text :destination_url, null: false, limit: 255 # rubocop:disable Migration/AddLimitToTextColumns - t.timestamps_with_timezone null: false - - t.index [:namespace_id, :destination_url], unique: true, name: 'index_external_audit_event_destinations_on_namespace_id' - end - end -end diff --git a/db/migrate/20210820171834_add_foreign_keys_for_pending_issue_escalations.rb b/db/migrate/20210820171834_add_foreign_keys_for_pending_issue_escalations.rb deleted file mode 100644 index 9d5322de498..00000000000 --- a/db/migrate/20210820171834_add_foreign_keys_for_pending_issue_escalations.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeysForPendingIssueEscalations < ActiveRecord::Migration[6.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_partitioned_foreign_key :incident_management_pending_issue_escalations, - :incident_management_escalation_rules, - column: :rule_id - - add_concurrent_partitioned_foreign_key :incident_management_pending_issue_escalations, - :issues, - column: :issue_id - end - - def down - remove_foreign_key_if_exists :incident_management_pending_issue_escalations, :incident_management_escalation_rules, column: :rule_id - remove_foreign_key_if_exists :incident_management_pending_issue_escalations, :issues, column: :issue_id - end -end diff --git a/db/migrate/20210823172643_create_user_group_callout.rb b/db/migrate/20210823172643_create_user_group_callout.rb deleted file mode 100644 index 72341c0b275..00000000000 --- a/db/migrate/20210823172643_create_user_group_callout.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CreateUserGroupCallout < ActiveRecord::Migration[6.1] - def up - create_table :user_group_callouts do |t| - t.bigint :user_id, null: false - t.bigint :group_id, null: false - t.integer :feature_name, limit: 2, null: false - t.datetime_with_timezone :dismissed_at - - t.index :group_id - t.index [:user_id, :feature_name, :group_id], unique: true, name: 'index_group_user_callouts_feature' - end - end - - def down - drop_table :user_group_callouts - end -end diff --git a/db/migrate/20210823213417_create_dependency_proxy_image_ttl_group_policies.rb b/db/migrate/20210823213417_create_dependency_proxy_image_ttl_group_policies.rb deleted file mode 100644 index 3bbd9c1259e..00000000000 --- a/db/migrate/20210823213417_create_dependency_proxy_image_ttl_group_policies.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class CreateDependencyProxyImageTtlGroupPolicies < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - with_lock_retries do - create_table :dependency_proxy_image_ttl_group_policies, id: false do |t| - t.timestamps_with_timezone null: false - t.references :group, primary_key: true, default: nil, index: false, foreign_key: { to_table: :namespaces, on_delete: :cascade } - t.integer :ttl, default: 90 - t.boolean :enabled, null: false, default: false - end - end - end - - def down - with_lock_retries do - drop_table :dependency_proxy_image_ttl_group_policies - end - end -end diff --git a/db/migrate/20210824055322_add_project_namespace_id_to_project.rb b/db/migrate/20210824055322_add_project_namespace_id_to_project.rb deleted file mode 100644 index 9397ad4aab2..00000000000 --- a/db/migrate/20210824055322_add_project_namespace_id_to_project.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddProjectNamespaceIdToProject < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - with_lock_retries do - # This is being added to Projects as a replacement for Namespace - # See https://gitlab.com/gitlab-org/gitlab/-/issues/337099 - add_column :projects, :project_namespace_id, :bigint # rubocop: disable Migration/AddColumnsToWideTables - end - end - - def down - with_lock_retries do - remove_column :projects, :project_namespace_id - end - end -end diff --git a/db/migrate/20210824105038_add_timestamp_columns_to_ci_build_trace_metadata.rb b/db/migrate/20210824105038_add_timestamp_columns_to_ci_build_trace_metadata.rb deleted file mode 100644 index 5c2391f68ed..00000000000 --- a/db/migrate/20210824105038_add_timestamp_columns_to_ci_build_trace_metadata.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class AddTimestampColumnsToCiBuildTraceMetadata < Gitlab::Database::Migration[1.0] - def change - add_column :ci_build_trace_metadata, :last_archival_attempt_at, :datetime_with_timezone - add_column :ci_build_trace_metadata, :archived_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20210824160459_add_notification_level_to_ci_namespace_monthly_usages.rb b/db/migrate/20210824160459_add_notification_level_to_ci_namespace_monthly_usages.rb deleted file mode 100644 index 15b580af737..00000000000 --- a/db/migrate/20210824160459_add_notification_level_to_ci_namespace_monthly_usages.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddNotificationLevelToCiNamespaceMonthlyUsages < Gitlab::Database::Migration[1.0] - def change - add_column :ci_namespace_monthly_usages, :notification_level, :integer, limit: 2, default: 100, null: false - end -end diff --git a/db/migrate/20210825104558_change_description_limit_error_tracking_event.rb b/db/migrate/20210825104558_change_description_limit_error_tracking_event.rb deleted file mode 100644 index 4663cc513da..00000000000 --- a/db/migrate/20210825104558_change_description_limit_error_tracking_event.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ChangeDescriptionLimitErrorTrackingEvent < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - remove_text_limit :error_tracking_error_events, :description - add_text_limit :error_tracking_error_events, :description, 1024 - end - - def down - remove_text_limit :error_tracking_error_events, :description - add_text_limit :error_tracking_error_events, :description, 255 - end -end diff --git a/db/migrate/20210825104656_create_analytics_cycle_analytics_merge_request_stage_events.rb b/db/migrate/20210825104656_create_analytics_cycle_analytics_merge_request_stage_events.rb deleted file mode 100644 index 2e89dfeacbf..00000000000 --- a/db/migrate/20210825104656_create_analytics_cycle_analytics_merge_request_stage_events.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class CreateAnalyticsCycleAnalyticsMergeRequestStageEvents < ActiveRecord::Migration[6.1] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - include Gitlab::Database::MigrationHelpers - - def up - execute <<~SQL - CREATE TABLE analytics_cycle_analytics_merge_request_stage_events ( - stage_event_hash_id bigint NOT NULL, - merge_request_id bigint NOT NULL, - group_id bigint NOT NULL, - project_id bigint NOT NULL, - milestone_id bigint, - author_id bigint, - start_event_timestamp timestamp with time zone NOT NULL, - end_event_timestamp timestamp with time zone, - PRIMARY KEY (stage_event_hash_id, merge_request_id) - ) PARTITION BY HASH (stage_event_hash_id) - SQL - - create_hash_partitions :analytics_cycle_analytics_merge_request_stage_events, 32 - end - - def down - drop_table :analytics_cycle_analytics_merge_request_stage_events - end -end diff --git a/db/migrate/20210825110016_create_analytics_cycle_analytics_issue_stage_events.rb b/db/migrate/20210825110016_create_analytics_cycle_analytics_issue_stage_events.rb deleted file mode 100644 index acc1d96bd23..00000000000 --- a/db/migrate/20210825110016_create_analytics_cycle_analytics_issue_stage_events.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class CreateAnalyticsCycleAnalyticsIssueStageEvents < ActiveRecord::Migration[6.1] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - include Gitlab::Database::MigrationHelpers - - def up - execute <<~SQL - CREATE TABLE analytics_cycle_analytics_issue_stage_events ( - stage_event_hash_id integer NOT NULL, - issue_id integer NOT NULL, - group_id integer NOT NULL, - project_id integer NOT NULL, - milestone_id integer, - author_id integer, - start_event_timestamp timestamp with time zone NOT NULL, - end_event_timestamp timestamp with time zone, - PRIMARY KEY (stage_event_hash_id, issue_id) - ) PARTITION BY HASH (stage_event_hash_id) - SQL - - create_hash_partitions :analytics_cycle_analytics_issue_stage_events, 32 - end - - def down - drop_table :analytics_cycle_analytics_issue_stage_events - end -end diff --git a/db/migrate/20210825190458_add_user_deactivation_email_option_to_application_settings.rb b/db/migrate/20210825190458_add_user_deactivation_email_option_to_application_settings.rb deleted file mode 100644 index dc3270dc5a7..00000000000 --- a/db/migrate/20210825190458_add_user_deactivation_email_option_to_application_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -# 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 AddUserDeactivationEmailOptionToApplicationSettings < ActiveRecord::Migration[6.1] - def change - add_column :application_settings, :user_deactivation_emails_enabled, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20210825193448_add_iteration_cadence_id_to_issue_boards.rb b/db/migrate/20210825193448_add_iteration_cadence_id_to_issue_boards.rb deleted file mode 100644 index cbe7d08894e..00000000000 --- a/db/migrate/20210825193448_add_iteration_cadence_id_to_issue_boards.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddIterationCadenceIdToIssueBoards < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :boards, :iteration_cadence_id, :bigint - end -end diff --git a/db/migrate/20210826120834_add_locked_to_ci_job_artifacts.rb b/db/migrate/20210826120834_add_locked_to_ci_job_artifacts.rb deleted file mode 100644 index 2149265b4e7..00000000000 --- a/db/migrate/20210826120834_add_locked_to_ci_job_artifacts.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddLockedToCiJobArtifacts < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - TABLE_NAME = 'ci_job_artifacts' - COLUMN_NAME = 'locked' - - def up - with_lock_retries do - add_column TABLE_NAME, COLUMN_NAME, :smallint, default: 2 - end - end - - def down - with_lock_retries do - remove_column TABLE_NAME, COLUMN_NAME - end - end -end diff --git a/db/migrate/20210826122748_create_loose_foreign_keys_deleted_records.rb b/db/migrate/20210826122748_create_loose_foreign_keys_deleted_records.rb deleted file mode 100644 index 5abea4393b4..00000000000 --- a/db/migrate/20210826122748_create_loose_foreign_keys_deleted_records.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class CreateLooseForeignKeysDeletedRecords < ActiveRecord::Migration[6.1] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - def up - constraint_name = check_constraint_name('loose_foreign_keys_deleted_records', 'deleted_table_name', 'max_length') - execute(<<~SQL) - CREATE TABLE loose_foreign_keys_deleted_records ( - created_at timestamp with time zone NOT NULL DEFAULT NOW(), - deleted_table_name text NOT NULL, - deleted_table_primary_key_value bigint NOT NULL, - PRIMARY KEY (created_at, deleted_table_name, deleted_table_primary_key_value), - CONSTRAINT #{constraint_name} CHECK ((char_length(deleted_table_name) <= 63)) - ) PARTITION BY RANGE (created_at); - SQL - - min_date = Date.today - 1.month - max_date = Date.today + 3.months - create_daterange_partitions('loose_foreign_keys_deleted_records', 'created_at', min_date, max_date) - end - - def down - drop_table :loose_foreign_keys_deleted_records - end -end diff --git a/db/migrate/20210826124311_add_index_to_error_tracking_error.rb b/db/migrate/20210826124311_add_index_to_error_tracking_error.rb deleted file mode 100644 index 5973331e487..00000000000 --- a/db/migrate/20210826124311_add_index_to_error_tracking_error.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToErrorTrackingError < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :error_tracking_errors, [:project_id, :status, :last_seen_at], name: 'index_et_errors_on_project_id_and_status_and_last_seen_at' - add_concurrent_index :error_tracking_errors, [:project_id, :status, :first_seen_at], name: 'index_et_errors_on_project_id_and_status_and_first_seen_at' - add_concurrent_index :error_tracking_errors, [:project_id, :status, :events_count], name: 'index_et_errors_on_project_id_and_status_and_events_count' - add_concurrent_index :error_tracking_errors, [:project_id, :status, :id], name: 'index_et_errors_on_project_id_and_status_and_id' - end - - def down - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :last_seen_at], name: 'index_et_errors_on_project_id_and_status_and_last_seen_at' - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :first_seen_at], name: 'index_et_errors_on_project_id_and_status_and_first_seen_at' - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :events_count], name: 'index_et_errors_on_project_id_and_status_and_events_count' - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :id], name: 'index_et_errors_on_project_id_and_status_and_id' - end -end diff --git a/db/migrate/20210826145509_add_function_for_inserting_deleted_records.rb b/db/migrate/20210826145509_add_function_for_inserting_deleted_records.rb deleted file mode 100644 index 631cc27c8c0..00000000000 --- a/db/migrate/20210826145509_add_function_for_inserting_deleted_records.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class AddFunctionForInsertingDeletedRecords < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers - - def up - execute(<<~SQL) - CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}() - RETURNS TRIGGER AS - $$ - BEGIN - INSERT INTO loose_foreign_keys_deleted_records - (deleted_table_name, deleted_table_primary_key_value) - SELECT TG_TABLE_NAME, old_table.id FROM old_table - ON CONFLICT DO NOTHING; - - RETURN NULL; - END - $$ LANGUAGE PLPGSQL - SQL - end - - def down - drop_function(DELETED_RECORDS_INSERT_FUNCTION_NAME) - end -end diff --git a/db/migrate/20210826170902_add_throttle_unauthenticated_api_columns.rb b/db/migrate/20210826170902_add_throttle_unauthenticated_api_columns.rb deleted file mode 100644 index 675da2ea41c..00000000000 --- a/db/migrate/20210826170902_add_throttle_unauthenticated_api_columns.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddThrottleUnauthenticatedApiColumns < ActiveRecord::Migration[6.1] - def change - # The defaults match those from the current `throttle_unauthenticated_*` columns - add_column :application_settings, :throttle_unauthenticated_api_enabled, :boolean, default: false, null: false - add_column :application_settings, :throttle_unauthenticated_api_requests_per_period, :integer, default: 3600, null: false - add_column :application_settings, :throttle_unauthenticated_api_period_in_seconds, :integer, default: 3600, null: false - end -end diff --git a/db/migrate/20210602155110_init_schema.rb b/db/migrate/20210826171758_init_schema.rb index 971a3e0e2db..971a3e0e2db 100644 --- a/db/migrate/20210602155110_init_schema.rb +++ b/db/migrate/20210826171758_init_schema.rb diff --git a/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb b/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb index d25923923f2..29c6d9ce87d 100644 --- a/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb +++ b/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb @@ -26,7 +26,7 @@ class CreateFunctionGitlabSchemaPreventWrite < Gitlab::Database::Migration[2.0] return if Gitlab.com? execute(<<~SQL) - DROP FUNCTION #{TRIGGER_FUNCTION_NAME} + DROP FUNCTION #{TRIGGER_FUNCTION_NAME} CASCADE SQL end end diff --git a/db/migrate/20221116134507_add_projects_emails_enabled_column.rb b/db/migrate/20221116134507_add_projects_emails_enabled_column.rb new file mode 100644 index 00000000000..1499ea2752b --- /dev/null +++ b/db/migrate/20221116134507_add_projects_emails_enabled_column.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true +class AddProjectsEmailsEnabledColumn < Gitlab::Database::Migration[2.0] + enable_lock_retries! + def change + add_column :project_settings, :emails_enabled, :boolean, default: true, null: false + end +end diff --git a/db/migrate/20221116134539_add_namespaces_emails_enabled_column.rb b/db/migrate/20221116134539_add_namespaces_emails_enabled_column.rb new file mode 100644 index 00000000000..e979cbb8aa5 --- /dev/null +++ b/db/migrate/20221116134539_add_namespaces_emails_enabled_column.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +class AddNamespacesEmailsEnabledColumn < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + add_column :namespace_settings, :emails_enabled, :boolean, default: true, null: false + end +end diff --git a/db/migrate/20221128155738_add_discord_to_user_details.rb b/db/migrate/20221128155738_add_discord_to_user_details.rb new file mode 100644 index 00000000000..4d59a53dcd7 --- /dev/null +++ b/db/migrate/20221128155738_add_discord_to_user_details.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddDiscordToUserDetails < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + # rubocop:disable Migration/AddLimitToTextColumns + # limits are added in 20221128165833_add_discord_field_limit_to_user_details.rb + def change + add_column :user_details, :discord, :text, default: '', null: false + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20221128165833_add_discord_field_limit_to_user_details.rb b/db/migrate/20221128165833_add_discord_field_limit_to_user_details.rb new file mode 100644 index 00000000000..a63b2019b20 --- /dev/null +++ b/db/migrate/20221128165833_add_discord_field_limit_to_user_details.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddDiscordFieldLimitToUserDetails < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + USER_DETAILS_FIELD_LIMIT = 500 + + def up + add_text_limit :user_details, :discord, USER_DETAILS_FIELD_LIMIT + end + + def down + remove_text_limit :user_details, :discord + end +end diff --git a/db/migrate/20221216145659_add_pa_clickhouse_connection_string_to_application_settings.rb b/db/migrate/20221216145659_add_pa_clickhouse_connection_string_to_application_settings.rb new file mode 100644 index 00000000000..8774ee8b964 --- /dev/null +++ b/db/migrate/20221216145659_add_pa_clickhouse_connection_string_to_application_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true +class AddPaClickhouseConnectionStringToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :encrypted_product_analytics_clickhouse_connection_string, :binary + add_column :application_settings, :encrypted_product_analytics_clickhouse_connection_string_iv, :binary + end +end diff --git a/db/migrate/20221219112632_add_next_over_limit_check_at_to_namespace_details.rb b/db/migrate/20221219112632_add_next_over_limit_check_at_to_namespace_details.rb new file mode 100644 index 00000000000..dd2acbfd0bb --- /dev/null +++ b/db/migrate/20221219112632_add_next_over_limit_check_at_to_namespace_details.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddNextOverLimitCheckAtToNamespaceDetails < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE_NAME = :namespace_details + COLUMN = :next_over_limit_check_at + + def up + with_lock_retries do + add_column TABLE_NAME, COLUMN, :datetime_with_timezone, null: true + end + end + + def down + with_lock_retries do + remove_column TABLE_NAME, COLUMN + end + end +end diff --git a/db/migrate/20221219122320_copy_clickhouse_connection_string_to_encrypted_var.rb b/db/migrate/20221219122320_copy_clickhouse_connection_string_to_encrypted_var.rb new file mode 100644 index 00000000000..feaa2dab170 --- /dev/null +++ b/db/migrate/20221219122320_copy_clickhouse_connection_string_to_encrypted_var.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true +class CopyClickhouseConnectionStringToEncryptedVar < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + class ApplicationSetting < MigrationRecord + self.table_name = 'application_settings' + + attr_encrypted :product_analytics_clickhouse_connection_string, { + mode: :per_attribute_iv, + key: Settings.attr_encrypted_db_key_base_32, + algorithm: 'aes-256-gcm', + encode: true + }.merge(encode: false, encode_iv: false) + end + + def up + setting = ApplicationSetting.first + + setting.update!(product_analytics_clickhouse_connection_string: setting.clickhouse_connection_string) if setting + end + + def down + # no-op + end +end diff --git a/db/migrate/20221228072549_add_pwa_attributes_to_appearances.rb b/db/migrate/20221228072549_add_pwa_attributes_to_appearances.rb new file mode 100644 index 00000000000..4c800d3305c --- /dev/null +++ b/db/migrate/20221228072549_add_pwa_attributes_to_appearances.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddPwaAttributesToAppearances < Gitlab::Database::Migration[2.1] + # rubocop:disable Migration/AddLimitToTextColumns + def up + add_column :appearances, :pwa_name, :text + add_column :appearances, :pwa_description, :text + end + # rubocop:enable Migration/AddLimitToTextColumns + + def down + remove_column :appearances, :pwa_name + remove_column :appearances, :pwa_description + end +end diff --git a/db/migrate/20221228073206_add_text_limit_to_pwa_attributes.rb b/db/migrate/20221228073206_add_text_limit_to_pwa_attributes.rb new file mode 100644 index 00000000000..0f3bf66dfa8 --- /dev/null +++ b/db/migrate/20221228073206_add_text_limit_to_pwa_attributes.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddTextLimitToPwaAttributes < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :appearances, :pwa_name, 255 + add_text_limit :appearances, :pwa_description, 2048 + end + + def down + remove_text_limit :appearances, :pwa_name + remove_text_limit :appearances, :pwa_description + end +end diff --git a/db/migrate/20221229064959_add_links_to_spam_to_abuse_reports.rb b/db/migrate/20221229064959_add_links_to_spam_to_abuse_reports.rb new file mode 100644 index 00000000000..af4761644c4 --- /dev/null +++ b/db/migrate/20221229064959_add_links_to_spam_to_abuse_reports.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddLinksToSpamToAbuseReports < Gitlab::Database::Migration[2.1] + def change + add_column :abuse_reports, :links_to_spam, :text, array: true, null: false, default: [] + end +end diff --git a/db/migrate/20230102131000_add_smtp_credentials_to_service_desk_settings.rb b/db/migrate/20230102131000_add_smtp_credentials_to_service_desk_settings.rb new file mode 100644 index 00000000000..8d3e3860ceb --- /dev/null +++ b/db/migrate/20230102131000_add_smtp_credentials_to_service_desk_settings.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class AddSmtpCredentialsToServiceDeskSettings < Gitlab::Database::Migration[2.1] + def up + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230102131100_add_text_limits_to_smtp_credentials_on_service_desk_settings.rb + add_column :service_desk_settings, :custom_email_enabled, :boolean, default: false, null: false + # Unique constraint/index is added in 20230102131050_add_unique_constraint_for_custom_email_to_... + add_column :service_desk_settings, :custom_email, :text + add_column :service_desk_settings, :custom_email_smtp_address, :text + add_column :service_desk_settings, :custom_email_smtp_port, :integer + add_column :service_desk_settings, :custom_email_smtp_username, :text + # Encrypted attribute via attr_encrypted needs these two columns + add_column :service_desk_settings, :encrypted_custom_email_smtp_password, :binary + add_column :service_desk_settings, :encrypted_custom_email_smtp_password_iv, :binary + # rubocop:enable Migration/AddLimitToTextColumns + end + + def down + remove_column :service_desk_settings, :custom_email_enabled + remove_column :service_desk_settings, :custom_email + remove_column :service_desk_settings, :custom_email_smtp_address + remove_column :service_desk_settings, :custom_email_smtp_port + remove_column :service_desk_settings, :custom_email_smtp_username + remove_column :service_desk_settings, :encrypted_custom_email_smtp_password + remove_column :service_desk_settings, :encrypted_custom_email_smtp_password_iv + end +end diff --git a/db/migrate/20230102131050_add_unique_constraint_for_custom_email_to_service_desk_settings.rb b/db/migrate/20230102131050_add_unique_constraint_for_custom_email_to_service_desk_settings.rb new file mode 100644 index 00000000000..cfee56ececd --- /dev/null +++ b/db/migrate/20230102131050_add_unique_constraint_for_custom_email_to_service_desk_settings.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddUniqueConstraintForCustomEmailToServiceDeskSettings < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'custom_email_unique_constraint' + + def up + # Force custom_email to be unique instance-wide. This is neccessary because we will match + # incoming service desk emails with a custom email by the custom_email field. + # This also adds the corresponding index + add_concurrent_index(:service_desk_settings, :custom_email, unique: true, name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(:service_desk_settings, INDEX_NAME) + end +end diff --git a/db/migrate/20230102131100_add_text_limits_to_smtp_credentials_on_service_desk_settings.rb b/db/migrate/20230102131100_add_text_limits_to_smtp_credentials_on_service_desk_settings.rb new file mode 100644 index 00000000000..60c96bd6bdb --- /dev/null +++ b/db/migrate/20230102131100_add_text_limits_to_smtp_credentials_on_service_desk_settings.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddTextLimitsToSmtpCredentialsOnServiceDeskSettings < Gitlab::Database::Migration[2.1] + MAXIMUM_LIMIT = 255 + + disable_ddl_transaction! + + def up + add_text_limit :service_desk_settings, :custom_email, MAXIMUM_LIMIT + add_text_limit :service_desk_settings, :custom_email_smtp_address, MAXIMUM_LIMIT + add_text_limit :service_desk_settings, :custom_email_smtp_username, MAXIMUM_LIMIT + end + + def down + remove_text_limit :service_desk_settings, :custom_email + remove_text_limit :service_desk_settings, :custom_email_smtp_address + remove_text_limit :service_desk_settings, :custom_email_smtp_username + end +end diff --git a/db/migrate/20230102180341_add_merge_request_meta_to_merge_requests_compliance_violations.rb b/db/migrate/20230102180341_add_merge_request_meta_to_merge_requests_compliance_violations.rb new file mode 100644 index 00000000000..84e1994e91c --- /dev/null +++ b/db/migrate/20230102180341_add_merge_request_meta_to_merge_requests_compliance_violations.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddMergeRequestMetaToMergeRequestsComplianceViolations < Gitlab::Database::Migration[2.1] + def change + add_column :merge_requests_compliance_violations, :merged_at, :datetime_with_timezone + add_column :merge_requests_compliance_violations, :target_project_id, :integer + add_column :merge_requests_compliance_violations, :title, :text # rubocop:disable Migration/AddLimitToTextColumns + add_column :merge_requests_compliance_violations, :target_branch, :text # rubocop:disable Migration/AddLimitToTextColumns + end +end diff --git a/db/migrate/20230104201524_add_zoekt_shards_and_indexed_namespaces.rb b/db/migrate/20230104201524_add_zoekt_shards_and_indexed_namespaces.rb new file mode 100644 index 00000000000..c9d7bc51041 --- /dev/null +++ b/db/migrate/20230104201524_add_zoekt_shards_and_indexed_namespaces.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddZoektShardsAndIndexedNamespaces < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + create_table :zoekt_shards do |t| + t.text :index_base_url, limit: 1024, index: { unique: true }, null: false + t.text :search_base_url, limit: 1024, index: { unique: true }, null: false + t.timestamps_with_timezone + end + + create_table :zoekt_indexed_namespaces do |t| + t.references :zoekt_shard, null: false, index: false, foreign_key: { on_delete: :cascade } + t.bigint :namespace_id, null: false, index: true + t.timestamps_with_timezone + t.index [:zoekt_shard_id, :namespace_id], unique: true, name: 'index_zoekt_shard_and_namespace' + end + end +end diff --git a/db/migrate/20230106014423_add_constraint_to_links_to_spam.rb b/db/migrate/20230106014423_add_constraint_to_links_to_spam.rb new file mode 100644 index 00000000000..b3d7ff3755a --- /dev/null +++ b/db/migrate/20230106014423_add_constraint_to_links_to_spam.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddConstraintToLinksToSpam < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + CONSTRAINT_NAME = "abuse_reports_links_to_spam_length_check" + + def up + add_check_constraint :abuse_reports, "CARDINALITY(links_to_spam) <= 20", CONSTRAINT_NAME + end + + def down + remove_check_constraint :abuse_reports, CONSTRAINT_NAME + end +end diff --git a/db/migrate/20230106184809_create_dast_profiles_tags.rb b/db/migrate/20230106184809_create_dast_profiles_tags.rb new file mode 100644 index 00000000000..f31eaea5fa8 --- /dev/null +++ b/db/migrate/20230106184809_create_dast_profiles_tags.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateDastProfilesTags < Gitlab::Database::Migration[2.1] + def up + create_table :dast_profiles_tags do |t| + t.references :dast_profile, null: false, foreign_key: { on_delete: :cascade }, + index: { name: 'i_dast_profiles_tags_on_scanner_profiles_id' } + + t.bigint :tag_id, null: false + + t.index :tag_id, name: :index_dast_profiles_tags_on_tag_id + end + end + + def down + drop_table :dast_profiles_tags + end +end diff --git a/db/migrate/20230107125328_add_zoekt_indexed_namespaces_foreign_key.rb b/db/migrate/20230107125328_add_zoekt_indexed_namespaces_foreign_key.rb new file mode 100644 index 00000000000..db995d6603e --- /dev/null +++ b/db/migrate/20230107125328_add_zoekt_indexed_namespaces_foreign_key.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddZoektIndexedNamespacesForeignKey < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :zoekt_indexed_namespaces, :namespaces, column: :namespace_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :zoekt_indexed_namespaces, column: :namespace_id + end + end +end diff --git a/db/migrate/20230109093043_create_namespaces_storage_limit_exclusions.rb b/db/migrate/20230109093043_create_namespaces_storage_limit_exclusions.rb new file mode 100644 index 00000000000..06168587fb5 --- /dev/null +++ b/db/migrate/20230109093043_create_namespaces_storage_limit_exclusions.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class CreateNamespacesStorageLimitExclusions < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def up + create_table :namespaces_storage_limit_exclusions do |t| + t.references :namespace, + foreign_key: { on_delete: :cascade }, + index: true, + null: false + t.text :reason, null: false, limit: 255 + t.timestamps_with_timezone null: false + end + end + + def down + drop_table :namespaces_storage_limit_exclusions + end +end diff --git a/db/migrate/20230109095622_rename_web_hook_calls_to_web_hook_calls_high.rb b/db/migrate/20230109095622_rename_web_hook_calls_to_web_hook_calls_high.rb new file mode 100644 index 00000000000..d3a461b3abb --- /dev/null +++ b/db/migrate/20230109095622_rename_web_hook_calls_to_web_hook_calls_high.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RenameWebHookCallsToWebHookCallsHigh < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + rename_column_concurrently :plan_limits, :web_hook_calls, :web_hook_calls_high + end + + def down + undo_rename_column_concurrently :plan_limits, :web_hook_calls, :web_hook_calls_high + end +end diff --git a/db/migrate/20230109232316_create_wiki_repository_states.rb b/db/migrate/20230109232316_create_wiki_repository_states.rb new file mode 100644 index 00000000000..61afc18c0f6 --- /dev/null +++ b/db/migrate/20230109232316_create_wiki_repository_states.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +class CreateWikiRepositoryStates < Gitlab::Database::Migration[2.0] + VERIFICATION_STATE_INDEX_NAME = "index_wiki_repository_states_on_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_wiki_repository_states_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_wiki_repository_states_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_wiki_repository_states_needs_verification" + + enable_lock_retries! + + def up + create_table :wiki_repository_states 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_wiki_repository, null: false, index: { unique: true }, 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 :wiki_repository_states + end +end diff --git a/db/migrate/20230110212906_add_on_update_action_to_postgres_foreign_keys.rb b/db/migrate/20230110212906_add_on_update_action_to_postgres_foreign_keys.rb new file mode 100644 index 00000000000..6cc3aeed56f --- /dev/null +++ b/db/migrate/20230110212906_add_on_update_action_to_postgres_foreign_keys.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +class AddOnUpdateActionToPostgresForeignKeys < Gitlab::Database::Migration[2.1] + def up + execute(<<~SQL) + -- adding the on_update_action before is_inherited requires recreating the view + DROP VIEW IF EXISTS postgres_foreign_keys; + CREATE OR REPLACE VIEW postgres_foreign_keys AS + SELECT + pg_constraint.oid AS oid, + pg_constraint.conname AS name, + constrained_namespace.nspname::text || '.'::text || constrained_table.relname::text AS constrained_table_identifier, + referenced_namespace.nspname::text || '.'::text || referenced_table.relname::text AS referenced_table_identifier, + constrained_table.relname::text AS constrained_table_name, + referenced_table.relname::text AS referenced_table_name, + constrained_cols.constrained_columns, + referenced_cols.referenced_columns, + pg_constraint.confdeltype AS on_delete_action, + pg_constraint.confupdtype as on_update_action, + pg_constraint.coninhcount > 0 as is_inherited + FROM pg_constraint + INNER JOIN pg_class constrained_table ON constrained_table.oid = pg_constraint.conrelid + INNER JOIN pg_class referenced_table ON referenced_table.oid = pg_constraint.confrelid + INNER JOIN pg_namespace constrained_namespace ON constrained_table.relnamespace = constrained_namespace.oid + INNER JOIN pg_namespace referenced_namespace ON referenced_table.relnamespace = referenced_namespace.oid + CROSS JOIN LATERAL ( + SELECT array_agg(pg_attribute.attname ORDER BY conkey.idx) -- must order here so that attributes are in correct order in array + FROM unnest(pg_constraint.conkey) WITH ORDINALITY conkey(attnum, idx) + INNER JOIN pg_attribute ON pg_attribute.attnum = conkey.attnum AND pg_attribute.attrelid = constrained_table.oid + ) constrained_cols(constrained_columns) + CROSS JOIN LATERAL ( + SELECT array_agg(pg_attribute.attname ORDER BY confkey.idx) + FROM unnest(pg_constraint.confkey) WITH ORDINALITY confkey(attnum, idx) + INNER JOIN pg_attribute ON pg_attribute.attnum = confkey.attnum AND pg_attribute.attrelid = referenced_table.oid + ) referenced_cols(referenced_columns) + WHERE contype = 'f'; + SQL + end + + def down + execute(<<~SQL) + DROP VIEW IF EXISTS postgres_foreign_keys; + CREATE OR REPLACE VIEW postgres_foreign_keys AS + SELECT + pg_constraint.oid AS oid, + pg_constraint.conname AS name, + constrained_namespace.nspname::text || '.'::text || constrained_table.relname::text AS constrained_table_identifier, + referenced_namespace.nspname::text || '.'::text || referenced_table.relname::text AS referenced_table_identifier, + constrained_table.relname::text AS constrained_table_name, + referenced_table.relname::text AS referenced_table_name, + constrained_cols.constrained_columns, + referenced_cols.referenced_columns, + pg_constraint.confdeltype AS on_delete_action, + pg_constraint.coninhcount > 0 as is_inherited + FROM pg_constraint + INNER JOIN pg_class constrained_table ON constrained_table.oid = pg_constraint.conrelid + INNER JOIN pg_class referenced_table ON referenced_table.oid = pg_constraint.confrelid + INNER JOIN pg_namespace constrained_namespace ON constrained_table.relnamespace = constrained_namespace.oid + INNER JOIN pg_namespace referenced_namespace ON referenced_table.relnamespace = referenced_namespace.oid + CROSS JOIN LATERAL ( + SELECT array_agg(pg_attribute.attname ORDER BY conkey.idx) -- must order here so that attributes are in correct order in array + FROM unnest(pg_constraint.conkey) WITH ORDINALITY conkey(attnum, idx) + INNER JOIN pg_attribute ON pg_attribute.attnum = conkey.attnum AND pg_attribute.attrelid = constrained_table.oid + ) constrained_cols(constrained_columns) + CROSS JOIN LATERAL ( + SELECT array_agg(pg_attribute.attname ORDER BY confkey.idx) + FROM unnest(pg_constraint.confkey) WITH ORDINALITY confkey(attnum, idx) + INNER JOIN pg_attribute ON pg_attribute.attnum = confkey.attnum AND pg_attribute.attrelid = referenced_table.oid + ) referenced_cols(referenced_columns) + WHERE contype = 'f'; + SQL + end +end diff --git a/db/migrate/20230111171355_add_allow_possible_spam_to_application_settings.rb b/db/migrate/20230111171355_add_allow_possible_spam_to_application_settings.rb new file mode 100644 index 00000000000..0b6b20e6129 --- /dev/null +++ b/db/migrate/20230111171355_add_allow_possible_spam_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddAllowPossibleSpamToApplicationSettings < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :application_settings, :allow_possible_spam, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20230111174113_create_airflow_dags.rb b/db/migrate/20230111174113_create_airflow_dags.rb new file mode 100644 index 00000000000..798acadd790 --- /dev/null +++ b/db/migrate/20230111174113_create_airflow_dags.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateAirflowDags < Gitlab::Database::Migration[2.1] + enable_lock_retries! + def change + create_table :airflow_dags do |t| + t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false + t.timestamps_with_timezone null: false + t.datetime_with_timezone :next_run + t.boolean :has_import_errors + t.boolean :is_active + t.boolean :is_paused + t.text :dag_name, null: false, limit: 255 + t.text :schedule, limit: 255 + t.text :fileloc, limit: 255 + end + end +end diff --git a/db/migrate/20230113195141_package_metadata_set_default_not_null.rb b/db/migrate/20230113195141_package_metadata_set_default_not_null.rb new file mode 100644 index 00000000000..92aed8a5706 --- /dev/null +++ b/db/migrate/20230113195141_package_metadata_set_default_not_null.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class PackageMetadataSetDefaultNotNull < Gitlab::Database::Migration[2.1] + def change + change_column_null(:pm_package_versions, :pm_package_id, false) + end +end diff --git a/db/migrate/20230116143310_add_pages_unique_domain_columns_to_project_settings.rb b/db/migrate/20230116143310_add_pages_unique_domain_columns_to_project_settings.rb new file mode 100644 index 00000000000..53c4f429243 --- /dev/null +++ b/db/migrate/20230116143310_add_pages_unique_domain_columns_to_project_settings.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddPagesUniqueDomainColumnsToProjectSettings < Gitlab::Database::Migration[2.1] + def up + add_column :project_settings, :pages_unique_domain_enabled, :boolean, default: false, null: false + add_column :project_settings, :pages_unique_domain, :text # rubocop: disable Migration/AddLimitToTextColumns + end + + def down + remove_column :project_settings, :pages_unique_domain_enabled, :boolean + remove_column :project_settings, :pages_unique_domain, :text + end +end diff --git a/db/migrate/20230116143311_add_project_settings_pages_unique_domain_limit.rb b/db/migrate/20230116143311_add_project_settings_pages_unique_domain_limit.rb new file mode 100644 index 00000000000..53c2a344a2c --- /dev/null +++ b/db/migrate/20230116143311_add_project_settings_pages_unique_domain_limit.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddProjectSettingsPagesUniqueDomainLimit < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :project_settings, :pages_unique_domain, 63 + end + + def down + remove_text_limit :project_settings, :pages_unique_domain + end +end diff --git a/db/migrate/20230116143312_add_project_settings_pages_unique_domain_unique_index.rb b/db/migrate/20230116143312_add_project_settings_pages_unique_domain_unique_index.rb new file mode 100644 index 00000000000..3e6fea00ed2 --- /dev/null +++ b/db/migrate/20230116143312_add_project_settings_pages_unique_domain_unique_index.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddProjectSettingsPagesUniqueDomainUniqueIndex < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_index :project_settings, + :pages_unique_domain, + unique: true, + where: 'pages_unique_domain IS NOT NULL', + name: 'unique_index_for_project_pages_unique_domain' + end + + def down + remove_concurrent_index :project_settings, + :pages_unique_domain, + unique: true, + name: 'unique_index_for_project_pages_unique_domain' + end +end diff --git a/db/migrate/20230117173433_create_project_data_transfer.rb b/db/migrate/20230117173433_create_project_data_transfer.rb new file mode 100644 index 00000000000..f63191c991b --- /dev/null +++ b/db/migrate/20230117173433_create_project_data_transfer.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class CreateProjectDataTransfer < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + with_lock_retries do + create_table :project_data_transfers do |t| + t.references :project, index: false, null: false + t.references :namespace, index: true, null: false + t.bigint :repository_egress, null: false, default: 0 + t.bigint :artifacts_egress, null: false, default: 0 + t.bigint :packages_egress, null: false, default: 0 + t.bigint :registry_egress, null: false, default: 0 + t.date :date, null: false + t.datetime_with_timezone :created_at, null: false + + t.index [:project_id, :namespace_id, :date], unique: true, + name: 'index_project_data_transfers_on_project_and_namespace_and_date' + end + end + + add_check_constraint :project_data_transfers, + "(date = date_trunc('month', date))", 'project_data_transfers_project_year_month_constraint' + end + + def down + with_lock_retries do + drop_table :project_data_transfers + end + end +end diff --git a/db/migrate/20230119150727_add_search_curation_settings_to_application_settings.rb b/db/migrate/20230119150727_add_search_curation_settings_to_application_settings.rb new file mode 100644 index 00000000000..f2ae4f49b9d --- /dev/null +++ b/db/migrate/20230119150727_add_search_curation_settings_to_application_settings.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddSearchCurationSettingsToApplicationSettings < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_column :application_settings, :search_max_shard_size_gb, :integer, default: 50, null: false + add_column :application_settings, :search_max_docs_denominator, :integer, default: 5_000_000, null: false + add_column :application_settings, :search_min_docs_before_rollover, :integer, default: 100_000, null: false + end + + def down + remove_column :application_settings, :search_max_shard_size_gb + remove_column :application_settings, :search_max_docs_denominator + remove_column :application_settings, :search_min_docs_before_rollover + end +end diff --git a/db/migrate/20230119151636_add_url_hash_to_web_hook_logs.rb b/db/migrate/20230119151636_add_url_hash_to_web_hook_logs.rb new file mode 100644 index 00000000000..e330ecfdae8 --- /dev/null +++ b/db/migrate/20230119151636_add_url_hash_to_web_hook_logs.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddUrlHashToWebHookLogs < Gitlab::Database::Migration[2.1] + def change + # limit is added in 20230119151940_add_text_limit_to_web_hook_logs_url_hash.rb + add_column :web_hook_logs, :url_hash, :text # rubocop:disable Migration/AddLimitToTextColumns + end +end diff --git a/db/migrate/20230119151940_add_text_limit_to_web_hook_logs_url_hash.rb b/db/migrate/20230119151940_add_text_limit_to_web_hook_logs_url_hash.rb new file mode 100644 index 00000000000..28e719b0a0f --- /dev/null +++ b/db/migrate/20230119151940_add_text_limit_to_web_hook_logs_url_hash.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToWebHookLogsUrlHash < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :web_hook_logs, :url_hash, 44, validate: false + end + + def down + remove_text_limit :web_hook_logs, :url_hash + end +end diff --git a/db/migrate/20230119214643_add_deactivation_email_additional_text_to_application_settings.rb b/db/migrate/20230119214643_add_deactivation_email_additional_text_to_application_settings.rb new file mode 100644 index 00000000000..e2b3e12c0ef --- /dev/null +++ b/db/migrate/20230119214643_add_deactivation_email_additional_text_to_application_settings.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddDeactivationEmailAdditionalTextToApplicationSettings < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230123150648_add_deactivation_email_additional_text_to_application_settings_text_limits.rb + def change + add_column :application_settings, :deactivation_email_additional_text, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230119215436_add_package_metadata_checkpoints.rb b/db/migrate/20230119215436_add_package_metadata_checkpoints.rb new file mode 100644 index 00000000000..a8349a107b1 --- /dev/null +++ b/db/migrate/20230119215436_add_package_metadata_checkpoints.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddPackageMetadataCheckpoints < Gitlab::Database::Migration[2.1] + def up + create_table :pm_checkpoints, id: false do |t| + t.integer :sequence, null: false + t.timestamps_with_timezone + t.integer :purl_type, null: false, primary_key: true + t.integer :chunk, null: false, limit: 2 + end + + change_column(:pm_checkpoints, :purl_type, :integer, limit: 2) + drop_sequence(:pm_checkpoints, :purl_type, 'pm_checkpoints_purl_type_seq') + end + + def down + drop_table :pm_checkpoints + end +end diff --git a/db/migrate/20230120170042_re_add_web_hook_calls_column.rb b/db/migrate/20230120170042_re_add_web_hook_calls_column.rb new file mode 100644 index 00000000000..1096c073f37 --- /dev/null +++ b/db/migrate/20230120170042_re_add_web_hook_calls_column.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class ReAddWebHookCallsColumn < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :plan_limits, :web_hook_calls, :integer, default: 0, null: false, if_not_exists: true + end +end diff --git a/db/migrate/20230120170631_drop_sync_triggers_from_web_hook_calls_plan_limits.rb b/db/migrate/20230120170631_drop_sync_triggers_from_web_hook_calls_plan_limits.rb new file mode 100644 index 00000000000..74c642437b9 --- /dev/null +++ b/db/migrate/20230120170631_drop_sync_triggers_from_web_hook_calls_plan_limits.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class DropSyncTriggersFromWebHookCallsPlanLimits < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def up + drop_trigger('trigger_c0776354152a', 'plan_limits') + drop_trigger('trigger_d0c336b01d00', 'plan_limits') + drop_trigger('trigger_e19c4cf656dc', 'plan_limits') + end + + def down + # noop + end +end diff --git a/db/migrate/20230120171818_sync_plan_limits_web_hook_calls_columns.rb b/db/migrate/20230120171818_sync_plan_limits_web_hook_calls_columns.rb new file mode 100644 index 00000000000..28c29f8731a --- /dev/null +++ b/db/migrate/20230120171818_sync_plan_limits_web_hook_calls_columns.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class SyncPlanLimitsWebHookCallsColumns < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + execute('UPDATE plan_limits SET web_hook_calls=web_hook_calls_high') + end + + def down + # noop + end +end diff --git a/db/migrate/20230123095022_create_scan_result_policies.rb b/db/migrate/20230123095022_create_scan_result_policies.rb new file mode 100644 index 00000000000..6f9eb7d0511 --- /dev/null +++ b/db/migrate/20230123095022_create_scan_result_policies.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateScanResultPolicies < Gitlab::Database::Migration[2.1] + INDEX_NAME = "index_scan_result_policies_on_policy_configuration_id" + + def change + create_table :scan_result_policies do |t| + t.references :security_orchestration_policy_configuration, + null: false, + foreign_key: { on_delete: :cascade }, + index: { name: INDEX_NAME } + + t.timestamps_with_timezone null: false + t.integer :orchestration_policy_idx, limit: 2, null: false + t.text :license_states, array: true, default: [] + end + end +end diff --git a/db/migrate/20230123120004_add_datetime_fields_to_bulk_import_trackers.rb b/db/migrate/20230123120004_add_datetime_fields_to_bulk_import_trackers.rb new file mode 100644 index 00000000000..a35fd382b34 --- /dev/null +++ b/db/migrate/20230123120004_add_datetime_fields_to_bulk_import_trackers.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddDatetimeFieldsToBulkImportTrackers < Gitlab::Database::Migration[2.1] + def up + add_column :bulk_import_trackers, :created_at, :datetime_with_timezone, null: true + add_column :bulk_import_trackers, :updated_at, :datetime_with_timezone, null: true + end + + def down + remove_column :bulk_import_trackers, :created_at + remove_column :bulk_import_trackers, :updated_at + end +end diff --git a/db/migrate/20230123150648_add_deactivation_email_additional_text_to_application_settings_text_limits.rb b/db/migrate/20230123150648_add_deactivation_email_additional_text_to_application_settings_text_limits.rb new file mode 100644 index 00000000000..ae3d3a516e3 --- /dev/null +++ b/db/migrate/20230123150648_add_deactivation_email_additional_text_to_application_settings_text_limits.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddDeactivationEmailAdditionalTextToApplicationSettingsTextLimits < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :application_settings, :deactivation_email_additional_text, 1000 + end + + def down + remove_text_limit :application_settings, :deactivation_email_additional_text + end +end diff --git a/db/migrate/20230124122143_add_deploy_key_id_to_create_access_levels.rb b/db/migrate/20230124122143_add_deploy_key_id_to_create_access_levels.rb new file mode 100644 index 00000000000..d26cf2a1e5f --- /dev/null +++ b/db/migrate/20230124122143_add_deploy_key_id_to_create_access_levels.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddDeployKeyIdToCreateAccessLevels < Gitlab::Database::Migration[2.1] + def up + add_column :protected_tag_create_access_levels, :deploy_key_id, :integer + end + + def down + remove_column :protected_tag_create_access_levels, :deploy_key_id + end +end diff --git a/db/migrate/20230124173255_raise_group_and_project_ci_variable_limits.rb b/db/migrate/20230124173255_raise_group_and_project_ci_variable_limits.rb new file mode 100644 index 00000000000..7a5f05c977c --- /dev/null +++ b/db/migrate/20230124173255_raise_group_and_project_ci_variable_limits.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RaiseGroupAndProjectCiVariableLimits < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + create_or_update_plan_limit('project_ci_variables', 'default', 8000) + create_or_update_plan_limit('group_ci_variables', 'default', 30000) + end + + def down + create_or_update_plan_limit('project_ci_variables', 'default', 200) + create_or_update_plan_limit('group_ci_variables', 'default', 200) + end +end diff --git a/db/migrate/20230124183643_add_checksums_column_to_project_mirror_data.rb b/db/migrate/20230124183643_add_checksums_column_to_project_mirror_data.rb new file mode 100644 index 00000000000..a4c13b4308f --- /dev/null +++ b/db/migrate/20230124183643_add_checksums_column_to_project_mirror_data.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddChecksumsColumnToProjectMirrorData < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :project_mirror_data, :checksums, :jsonb, null: false, default: {} + end +end diff --git a/db/migrate/20230124193917_add_index_for_protected_tag_create_access_levels.rb b/db/migrate/20230124193917_add_index_for_protected_tag_create_access_levels.rb new file mode 100644 index 00000000000..7068f4f0447 --- /dev/null +++ b/db/migrate/20230124193917_add_index_for_protected_tag_create_access_levels.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexForProtectedTagCreateAccessLevels < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + DEPLOY_KEY_INDEX_NAME = 'index_protected_tag_create_access_levels_on_deploy_key_id' + + def up + add_concurrent_foreign_key :protected_tag_create_access_levels, :keys, column: :deploy_key_id, on_delete: :cascade + add_concurrent_index :protected_tag_create_access_levels, :deploy_key_id, + name: DEPLOY_KEY_INDEX_NAME + end + + def down + remove_foreign_key_if_exists :protected_tag_create_access_levels, column: :deploy_key_id + remove_concurrent_index_by_name :protected_tag_create_access_levels, name: DEPLOY_KEY_INDEX_NAME + end +end diff --git a/db/migrate/20230125090315_add_prepared_at_to_merge_request.rb b/db/migrate/20230125090315_add_prepared_at_to_merge_request.rb new file mode 100644 index 00000000000..4e4b4ccf671 --- /dev/null +++ b/db/migrate/20230125090315_add_prepared_at_to_merge_request.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddPreparedAtToMergeRequest < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :merge_requests, 'prepared_at', :datetime_with_timezone + end + end + + def down + with_lock_retries do + remove_column :merge_requests, 'prepared_at' + end + end +end diff --git a/db/migrate/20230126023444_add_timestamps_to_package_metadata_tables.rb b/db/migrate/20230126023444_add_timestamps_to_package_metadata_tables.rb new file mode 100644 index 00000000000..ccf239ac273 --- /dev/null +++ b/db/migrate/20230126023444_add_timestamps_to_package_metadata_tables.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddTimestampsToPackageMetadataTables < Gitlab::Database::Migration[2.1] + def up + add_timestamps_with_timezone(:pm_packages, null: false, default: -> { 'NOW()' }) + add_timestamps_with_timezone(:pm_package_versions, null: false, default: -> { 'NOW()' }) + add_timestamps_with_timezone(:pm_licenses, null: false, default: -> { 'NOW()' }) + add_timestamps_with_timezone(:pm_package_version_licenses, null: false, default: -> { 'NOW()' }) + end + + def down + remove_timestamps(:pm_packages) + remove_timestamps(:pm_package_versions) + remove_timestamps(:pm_licenses) + remove_timestamps(:pm_package_version_licenses) + end +end diff --git a/db/migrate/20230126110439_change_default_value_for_inbound_job_token_scope_enabled.rb b/db/migrate/20230126110439_change_default_value_for_inbound_job_token_scope_enabled.rb new file mode 100644 index 00000000000..9b9de65d423 --- /dev/null +++ b/db/migrate/20230126110439_change_default_value_for_inbound_job_token_scope_enabled.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class ChangeDefaultValueForInboundJobTokenScopeEnabled < Gitlab::Database::Migration[2.1] + def up + change_column_default :project_ci_cd_settings, :inbound_job_token_scope_enabled, from: false, to: true + end + + def down + change_column_default :project_ci_cd_settings, :inbound_job_token_scope_enabled, from: true, to: false + end +end diff --git a/db/migrate/20230126151622_add_ci_triggers_encrypted_token.rb b/db/migrate/20230126151622_add_ci_triggers_encrypted_token.rb new file mode 100644 index 00000000000..8f394d24d6a --- /dev/null +++ b/db/migrate/20230126151622_add_ci_triggers_encrypted_token.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddCiTriggersEncryptedToken < Gitlab::Database::Migration[2.1] + def up + add_column :ci_triggers, :encrypted_token, :binary + add_column :ci_triggers, :encrypted_token_iv, :binary + end + + def down + remove_column :ci_triggers, :encrypted_token + remove_column :ci_triggers, :encrypted_token_iv + end +end diff --git a/db/migrate/20230126210436_add_jira_connect_public_key_storage_enabled_setting.rb b/db/migrate/20230126210436_add_jira_connect_public_key_storage_enabled_setting.rb new file mode 100644 index 00000000000..1d8ac03f9df --- /dev/null +++ b/db/migrate/20230126210436_add_jira_connect_public_key_storage_enabled_setting.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddJiraConnectPublicKeyStorageEnabledSetting < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :jira_connect_public_key_storage_enabled, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20230127093353_initialize_conversion_of_merge_request_metrics_to_bigint.rb b/db/migrate/20230127093353_initialize_conversion_of_merge_request_metrics_to_bigint.rb new file mode 100644 index 00000000000..dfca67a2e2f --- /dev/null +++ b/db/migrate/20230127093353_initialize_conversion_of_merge_request_metrics_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfMergeRequestMetricsToBigint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE = :merge_request_metrics + COLUMNS = %i[id] + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230127121107_add_git_rate_limit_users_alertlist_to_application_settings.rb b/db/migrate/20230127121107_add_git_rate_limit_users_alertlist_to_application_settings.rb new file mode 100644 index 00000000000..b429bea1600 --- /dev/null +++ b/db/migrate/20230127121107_add_git_rate_limit_users_alertlist_to_application_settings.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddGitRateLimitUsersAlertlistToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :git_rate_limit_users_alertlist, + :integer, + array: true, + default: [], + null: false + end +end diff --git a/db/migrate/20230127121443_add_unique_project_download_limit_alertlist_to_namespace_settings.rb b/db/migrate/20230127121443_add_unique_project_download_limit_alertlist_to_namespace_settings.rb new file mode 100644 index 00000000000..4679d668843 --- /dev/null +++ b/db/migrate/20230127121443_add_unique_project_download_limit_alertlist_to_namespace_settings.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddUniqueProjectDownloadLimitAlertlistToNamespaceSettings < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :namespace_settings, :unique_project_download_limit_alertlist, + :integer, + array: true, + default: [], + null: false + end +end diff --git a/db/migrate/20230127151529_add_project_pointer_for_analytics_dashboard.rb b/db/migrate/20230127151529_add_project_pointer_for_analytics_dashboard.rb new file mode 100644 index 00000000000..bbfb0c90596 --- /dev/null +++ b/db/migrate/20230127151529_add_project_pointer_for_analytics_dashboard.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AddProjectPointerForAnalyticsDashboard < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + change_column_null :analytics_dashboards_pointers, :project_id, true + change_column_null :analytics_dashboards_pointers, :namespace_id, true + + unless column_exists?(:analytics_dashboards_pointers, :target_project_id) + add_column :analytics_dashboards_pointers, :target_project_id, :bigint + end + + add_concurrent_foreign_key :analytics_dashboards_pointers, :projects, + column: :target_project_id, + on_delete: :cascade + + add_concurrent_index :analytics_dashboards_pointers, :target_project_id + end + + def down + change_column_null :analytics_dashboards_pointers, :project_id, false + change_column_null :analytics_dashboards_pointers, :namespace_id, false + + return unless column_exists?(:analytics_dashboards_pointers, :target_project_id) + + remove_column :analytics_dashboards_pointers, :target_project_id + end +end diff --git a/db/migrate/20230127151530_migrate_project_pointer_for_analytics_dashboard.rb b/db/migrate/20230127151530_migrate_project_pointer_for_analytics_dashboard.rb new file mode 100644 index 00000000000..233474d0918 --- /dev/null +++ b/db/migrate/20230127151530_migrate_project_pointer_for_analytics_dashboard.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class MigrateProjectPointerForAnalyticsDashboard < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + execute 'UPDATE analytics_dashboards_pointers SET target_project_id = project_id' + execute 'UPDATE analytics_dashboards_pointers SET project_id = NULL' + end + + def down + execute 'UPDATE analytics_dashboards_pointers SET project_id = target_project_id' + execute 'UPDATE analytics_dashboards_pointers SET target_project_id = NULL' + end +end diff --git a/db/migrate/20230127151531_change_dashboard_analytics_project_pointer_project_null.rb b/db/migrate/20230127151531_change_dashboard_analytics_project_pointer_project_null.rb new file mode 100644 index 00000000000..d615185fe8a --- /dev/null +++ b/db/migrate/20230127151531_change_dashboard_analytics_project_pointer_project_null.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class ChangeDashboardAnalyticsProjectPointerProjectNull < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + EXISTENCE_CONSTRAINT = 'chk_analytics_dashboards_pointers_project_or_namespace' + NEW_UNIQ_INDEX = 'idx_uniq_analytics_dashboards_pointers_on_project_id' + OLD_INDEX = 'index_analytics_dashboards_pointers_on_project_id' + + def up + add_check_constraint :analytics_dashboards_pointers, + "(project_id IS NULL) <> (namespace_id IS NULL)", + EXISTENCE_CONSTRAINT + + change_column_null :analytics_dashboards_pointers, :target_project_id, false + + add_concurrent_index :analytics_dashboards_pointers, :project_id, name: NEW_UNIQ_INDEX, unique: true + remove_concurrent_index_by_name :analytics_dashboards_pointers, OLD_INDEX + end + + def down + remove_check_constraint :analytics_dashboards_pointers, EXISTENCE_CONSTRAINT + + change_column_null :analytics_dashboards_pointers, :target_project_id, true + + add_concurrent_index :analytics_dashboards_pointers, :project_id, name: OLD_INDEX + remove_concurrent_index_by_name :analytics_dashboards_pointers, NEW_UNIQ_INDEX + end +end diff --git a/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb b/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb new file mode 100644 index 00000000000..960421ae38e --- /dev/null +++ b/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddIdColumnToPackageMetadataJoinTable < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + COMPOSITE_UNIQUE_INDEX = :i_pm_package_version_licenses_join_ids + + def up + drop_constraint(:pm_package_version_licenses, :pm_package_version_licenses_pkey, cascade: true) + add_column(:pm_package_version_licenses, :id, :primary_key) + add_concurrent_index(:pm_package_version_licenses, [:pm_package_version_id, :pm_license_id], unique: true, + name: COMPOSITE_UNIQUE_INDEX) + end + + def down + remove_column(:pm_package_version_licenses, :id) + add_primary_key_using_index(:pm_package_version_licenses, :pm_package_version_licenses_pkey, COMPOSITE_UNIQUE_INDEX) + remove_concurrent_index_by_name(:pm_package_version_licenses, COMPOSITE_UNIQUE_INDEX) + end +end diff --git a/db/migrate/20230127164007_add_trial_date_index_to_gitlab_subscribtions.rb b/db/migrate/20230127164007_add_trial_date_index_to_gitlab_subscribtions.rb new file mode 100644 index 00000000000..57117638945 --- /dev/null +++ b/db/migrate/20230127164007_add_trial_date_index_to_gitlab_subscribtions.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddTrialDateIndexToGitlabSubscribtions < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_gitlab_subscriptions_on_trial_and_trial_starts_on' + + def up + add_concurrent_index :gitlab_subscriptions, [:trial, :trial_starts_on], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :gitlab_subscriptions, INDEX_NAME + end +end diff --git a/db/migrate/20230129094140_add_widget_definitions.rb b/db/migrate/20230129094140_add_widget_definitions.rb new file mode 100644 index 00000000000..09816f7386d --- /dev/null +++ b/db/migrate/20230129094140_add_widget_definitions.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AddWidgetDefinitions < Gitlab::Database::Migration[2.1] + UNIQUE_INDEX_NAME = 'index_work_item_widget_definitions_on_namespace_type_and_name' + UNIQUE_DEFAULT_NAMESPACE_INDEX_NAME = 'index_work_item_widget_definitions_on_default_witype_and_name' + + def up + create_table :work_item_widget_definitions do |t| + t.references :namespace, index: false + t.references :work_item_type, index: true, null: false + t.integer :widget_type, null: false, limit: 2 + t.boolean :disabled, default: false + t.text :name, limit: 255 + + t.index [:namespace_id, :work_item_type_id, :name], unique: true, name: UNIQUE_INDEX_NAME + t.index [:work_item_type_id, :name], where: "namespace_id is NULL", + unique: true, name: UNIQUE_DEFAULT_NAMESPACE_INDEX_NAME + end + end + + def down + drop_table :work_item_widget_definitions + end +end diff --git a/db/migrate/20230129154126_add_widget_def_namespace_fk.rb b/db/migrate/20230129154126_add_widget_def_namespace_fk.rb new file mode 100644 index 00000000000..cf3f83fdbfe --- /dev/null +++ b/db/migrate/20230129154126_add_widget_def_namespace_fk.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddWidgetDefNamespaceFk < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :work_item_widget_definitions, :work_item_types, + column: :work_item_type_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :work_item_widget_definitions, column: :work_item_type_id + end + end +end diff --git a/db/migrate/20230129154202_add_widget_def_work_item_type_fk.rb b/db/migrate/20230129154202_add_widget_def_work_item_type_fk.rb new file mode 100644 index 00000000000..530f2c78198 --- /dev/null +++ b/db/migrate/20230129154202_add_widget_def_work_item_type_fk.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddWidgetDefWorkItemTypeFk < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :work_item_widget_definitions, :namespaces, column: :namespace_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :work_item_widget_definitions, column: :namespace_id + end + end +end diff --git a/db/migrate/20230129154819_add_widgets_for_work_item_types.rb b/db/migrate/20230129154819_add_widgets_for_work_item_types.rb new file mode 100644 index 00000000000..b936ea2e409 --- /dev/null +++ b/db/migrate/20230129154819_add_widgets_for_work_item_types.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +class AddWidgetsForWorkItemTypes < Gitlab::Database::Migration[2.1] + class WorkItemType < MigrationRecord + self.table_name = 'work_item_types' + end + + class WidgetDefinition < MigrationRecord + self.table_name = 'work_item_widget_definitions' + end + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + widget_names = { + assignees: 'Assignees', + labels: 'Labels', + description: 'Description', + hierarchy: 'Hierarchy', + start_and_due_date: 'Start and due date', + milestone: 'Milestone', + notes: 'Notes', + iteration: 'Iteration', + weight: 'Weight', + health_status: 'Health status', + progress: 'Progress', + status: 'Status', + requirement_legacy: 'Requirement legacy', + test_reports: 'Test reports' + } + + widgets_for_type = { + 'Issue' => [ + :assignees, + :labels, + :description, + :hierarchy, + :start_and_due_date, + :milestone, + :notes, + # EE widgets + :iteration, + :weight, + :health_status + ], + 'Incident' => [ + :description, + :hierarchy, + :notes + ], + 'Test Case' => [ + :description, + :notes + ], + 'Requirement' => [ + :description, + :notes, + :status, + :requirement_legacy, + :test_reports + ], + 'Task' => [ + :assignees, + :labels, + :description, + :hierarchy, + :start_and_due_date, + :milestone, + :notes, + :iteration, + :weight + ], + 'Objective' => [ + :assignees, + :labels, + :description, + :hierarchy, + :milestone, + :notes, + :health_status, + :progress + ], + 'Key Result' => [ + :assignees, + :labels, + :description, + :hierarchy, + :start_and_due_date, + :notes, + :health_status, + :progress + ] + } + + widgets_enum = { + assignees: 0, + description: 1, + hierarchy: 2, + labels: 3, + milestone: 4, + notes: 5, + start_and_due_date: 6, + health_status: 7, # EE-only + weight: 8, # EE-only + iteration: 9, # EE-only + progress: 10, # EE-only + status: 11, # EE-only + requirement_legacy: 12, # EE-only + test_reports: 13 + } + + widgets = [] + widgets_for_type.each do |type_name, widget_syms| + type = WorkItemType.find_by_name_and_namespace_id(type_name, nil) + + unless type + Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widgets") + + next + end + + widgets += widget_syms.map do |widget_sym| + { + work_item_type_id: type.id, + name: widget_names[widget_sym], + widget_type: widgets_enum[widget_sym] + } + end + end + + return if widgets.empty? + + WidgetDefinition.upsert_all( + widgets, + unique_by: :index_work_item_widget_definitions_on_default_witype_and_name + ) + end + + def down + WidgetDefinition.delete_all + end +end diff --git a/db/migrate/20210608072312_initialize_conversion_of_ci_stages_to_bigint.rb b/db/migrate/20230130104819_initialize_conversion_of_ci_build_needs_to_bigint.rb index 490a7f2e960..680ad570391 100644 --- a/db/migrate/20210608072312_initialize_conversion_of_ci_stages_to_bigint.rb +++ b/db/migrate/20230130104819_initialize_conversion_of_ci_build_needs_to_bigint.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -class InitializeConversionOfCiStagesToBigint < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers +class InitializeConversionOfCiBuildNeedsToBigint < Gitlab::Database::Migration[2.1] + TABLE = :ci_build_needs + COLUMNS = %i[id] - TABLE = :ci_stages - COLUMNS = %i(id) + enable_lock_retries! def up initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) diff --git a/db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb b/db/migrate/20230130110855_backfill_ci_build_needs_for_big_int_conversion.rb index 4a52600d4c7..ae7ad3b52c2 100644 --- a/db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb +++ b/db/migrate/20230130110855_backfill_ci_build_needs_for_big_int_conversion.rb @@ -1,12 +1,10 @@ # frozen_string_literal: true -class BackfillCiStagesForBigintConversion < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers +class BackfillCiBuildNeedsForBigIntConversion < Gitlab::Database::Migration[2.1] + TABLE = :ci_build_needs + COLUMNS = %i[id] - disable_ddl_transaction! - - TABLE = :ci_stages - COLUMNS = %i(id) + restrict_gitlab_migration gitlab_schema: :gitlab_ci def up backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) diff --git a/db/migrate/20230130125541_add_attempts_and_last_error_to_postgres_async_indexes.rb b/db/migrate/20230130125541_add_attempts_and_last_error_to_postgres_async_indexes.rb new file mode 100644 index 00000000000..31d09e5ee8a --- /dev/null +++ b/db/migrate/20230130125541_add_attempts_and_last_error_to_postgres_async_indexes.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddAttemptsAndLastErrorToPostgresAsyncIndexes < Gitlab::Database::Migration[2.1] + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230130130624_add_text_limit_to_postgres_async_indexes_last_error.rb + def change + add_column :postgres_async_indexes, :attempts, :integer, null: false, default: 0 + add_column :postgres_async_indexes, :last_error, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230130130624_add_text_limit_to_postgres_async_indexes_last_error.rb b/db/migrate/20230130130624_add_text_limit_to_postgres_async_indexes_last_error.rb new file mode 100644 index 00000000000..1cd51453fd2 --- /dev/null +++ b/db/migrate/20230130130624_add_text_limit_to_postgres_async_indexes_last_error.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToPostgresAsyncIndexesLastError < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :postgres_async_indexes, :last_error, 10_000 + end + + def down + remove_text_limit :postgres_async_indexes, :last_error + end +end diff --git a/db/migrate/20230130175512_initialize_conversion_of_sent_notifications_to_bigint.rb b/db/migrate/20230130175512_initialize_conversion_of_sent_notifications_to_bigint.rb new file mode 100644 index 00000000000..4e588ab2197 --- /dev/null +++ b/db/migrate/20230130175512_initialize_conversion_of_sent_notifications_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfSentNotificationsToBigint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE = :sent_notifications + COLUMNS = %i[id] + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230130204743_remove_protected_environment_default_access_level.rb b/db/migrate/20230130204743_remove_protected_environment_default_access_level.rb new file mode 100644 index 00000000000..d01fd6b90f3 --- /dev/null +++ b/db/migrate/20230130204743_remove_protected_environment_default_access_level.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class RemoveProtectedEnvironmentDefaultAccessLevel < Gitlab::Database::Migration[2.1] + def change + change_column_default :protected_environment_deploy_access_levels, :access_level, from: 40, to: nil + end +end diff --git a/db/migrate/20230131004948_initialize_conversion_of_notes_id_to_bigint.rb b/db/migrate/20230131004948_initialize_conversion_of_notes_id_to_bigint.rb new file mode 100644 index 00000000000..a376ba50e87 --- /dev/null +++ b/db/migrate/20230131004948_initialize_conversion_of_notes_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfNotesIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :notes + COLUMNS = %i[id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230131090842_add_global_group_approvers_enabled_to_application_settings.rb b/db/migrate/20230131090842_add_global_group_approvers_enabled_to_application_settings.rb new file mode 100644 index 00000000000..cb3c747d351 --- /dev/null +++ b/db/migrate/20230131090842_add_global_group_approvers_enabled_to_application_settings.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddGlobalGroupApproversEnabledToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, + :security_policy_global_group_approvers_enabled, + :boolean, + default: true, + null: false + end +end diff --git a/db/migrate/20230131123923_raise_ci_variables_default_limits.rb b/db/migrate/20230131123923_raise_ci_variables_default_limits.rb new file mode 100644 index 00000000000..ebe59c13e18 --- /dev/null +++ b/db/migrate/20230131123923_raise_ci_variables_default_limits.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class RaiseCiVariablesDefaultLimits < Gitlab::Database::Migration[2.1] + def change + change_column_default(:plan_limits, :project_ci_variables, from: 200, to: 8000) + change_column_default(:plan_limits, :group_ci_variables, from: 200, to: 30000) + end +end diff --git a/db/migrate/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages.rb b/db/migrate/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages.rb new file mode 100644 index 00000000000..88ff29769b1 --- /dev/null +++ b/db/migrate/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddProjectIdNameIdVersionIndexToInstallableNpmPackages < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'idx_packages_on_project_id_name_id_version_when_installable_npm' + PACKAGE_TYPE_NPM = 2 + + def up + add_concurrent_index( + :packages_packages, + [:project_id, :name, :id, :version], + name: INDEX_NAME, + where: "package_type = #{PACKAGE_TYPE_NPM} AND status IN (0, 1)" + ) + end + + def down + remove_concurrent_index_by_name(:packages_packages, INDEX_NAME) + end +end diff --git a/db/migrate/20230201012727_initialize_conversion_of_todos_note_id_to_bigint.rb b/db/migrate/20230201012727_initialize_conversion_of_todos_note_id_to_bigint.rb new file mode 100644 index 00000000000..06ddcacba42 --- /dev/null +++ b/db/migrate/20230201012727_initialize_conversion_of_todos_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfTodosNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :todos + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230201014223_initialize_conversion_of_system_note_metadata_note_id_to_bigint.rb b/db/migrate/20230201014223_initialize_conversion_of_system_note_metadata_note_id_to_bigint.rb new file mode 100644 index 00000000000..ec84f1cb946 --- /dev/null +++ b/db/migrate/20230201014223_initialize_conversion_of_system_note_metadata_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfSystemNoteMetadataNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :system_note_metadata + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230202002616_initialize_conversion_of_epic_user_mentions_note_id_to_bigint.rb b/db/migrate/20230202002616_initialize_conversion_of_epic_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..8e0c4e0b106 --- /dev/null +++ b/db/migrate/20230202002616_initialize_conversion_of_epic_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfEpicUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :epic_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230202023208_initialize_conversion_of_suggestions_note_id_to_bigint.rb b/db/migrate/20230202023208_initialize_conversion_of_suggestions_note_id_to_bigint.rb new file mode 100644 index 00000000000..9b271089801 --- /dev/null +++ b/db/migrate/20230202023208_initialize_conversion_of_suggestions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfSuggestionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :suggestions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230202032248_initialize_conversion_of_issue_user_mentions_note_id_to_bigint.rb b/db/migrate/20230202032248_initialize_conversion_of_issue_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..3df255b3d6d --- /dev/null +++ b/db/migrate/20230202032248_initialize_conversion_of_issue_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfIssueUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :issue_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230202153926_add_scan_result_policy_id_to_approval_rules.rb b/db/migrate/20230202153926_add_scan_result_policy_id_to_approval_rules.rb new file mode 100644 index 00000000000..b72405ccf30 --- /dev/null +++ b/db/migrate/20230202153926_add_scan_result_policy_id_to_approval_rules.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddScanResultPolicyIdToApprovalRules < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :approval_project_rules, :scan_result_policy_id, :bigint + add_column :approval_merge_request_rules, :scan_result_policy_id, :bigint + end +end diff --git a/db/migrate/20230203011359_create_automation_rules.rb b/db/migrate/20230203011359_create_automation_rules.rb new file mode 100644 index 00000000000..d247799bee8 --- /dev/null +++ b/db/migrate/20230203011359_create_automation_rules.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class CreateAutomationRules < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def up + create_table :automation_rules do |t| + t.references :namespace, null: false, index: false, foreign_key: { on_delete: :cascade } + t.boolean :issues_events, default: false, null: false + t.boolean :merge_requests_events, default: false, null: false + t.boolean :permanently_disabled, default: false, null: false + t.text :name, null: false, limit: 255 + t.text :rule, null: false, limit: 2048 + t.timestamps_with_timezone null: false + + t.index 'namespace_id, LOWER(name)', + name: 'index_automation_rules_namespace_id_name', + unique: true + + t.index [:namespace_id, :permanently_disabled], + name: 'index_automation_rules_namespace_id_permanently_disabled' + end + end + + def down + drop_table :automation_rules + end +end diff --git a/db/migrate/20230203145514_allow_null_pipeline_id_to_dast_pre_scan_verification.rb b/db/migrate/20230203145514_allow_null_pipeline_id_to_dast_pre_scan_verification.rb new file mode 100644 index 00000000000..11e8a856c11 --- /dev/null +++ b/db/migrate/20230203145514_allow_null_pipeline_id_to_dast_pre_scan_verification.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AllowNullPipelineIdToDastPreScanVerification < Gitlab::Database::Migration[2.1] + def up + change_column_null :dast_pre_scan_verifications, :ci_pipeline_id, true + end + + def down + # There may now be nulls in the table, so we cannot re-add the constraint here. + end +end diff --git a/db/migrate/20230206143851_create_postgres_async_foreign_key_validations.rb b/db/migrate/20230206143851_create_postgres_async_foreign_key_validations.rb new file mode 100644 index 00000000000..b9c32f83411 --- /dev/null +++ b/db/migrate/20230206143851_create_postgres_async_foreign_key_validations.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CreatePostgresAsyncForeignKeyValidations < Gitlab::Database::Migration[2.1] + def change + create_table :postgres_async_foreign_key_validations, if_not_exists: true do |t| + t.timestamps_with_timezone null: false + + t.text :name, null: false, limit: 63 + t.text :table_name, null: false, limit: 63 + t.text :last_error, limit: 10_000 + + t.integer :attempts, null: false, default: 0 + + t.index :name, unique: true + end + end +end diff --git a/db/migrate/20230206172702_add_match_on_inclusion_to_scan_result_policy.rb b/db/migrate/20230206172702_add_match_on_inclusion_to_scan_result_policy.rb new file mode 100644 index 00000000000..bec3dfeca76 --- /dev/null +++ b/db/migrate/20230206172702_add_match_on_inclusion_to_scan_result_policy.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddMatchOnInclusionToScanResultPolicy < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :scan_result_policies, :match_on_inclusion, :boolean + end +end diff --git a/db/migrate/20230207003737_initialize_conversion_of_note_diff_files_diff_note_id_to_bigint.rb b/db/migrate/20230207003737_initialize_conversion_of_note_diff_files_diff_note_id_to_bigint.rb new file mode 100644 index 00000000000..22c7d252dc3 --- /dev/null +++ b/db/migrate/20230207003737_initialize_conversion_of_note_diff_files_diff_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfNoteDiffFilesDiffNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :note_diff_files + COLUMNS = %i[diff_note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230207005549_initialize_conversion_of_snippet_user_mentions_note_id_to_bigint.rb b/db/migrate/20230207005549_initialize_conversion_of_snippet_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..3f994a0e40f --- /dev/null +++ b/db/migrate/20230207005549_initialize_conversion_of_snippet_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfSnippetUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :snippet_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230207011344_initialize_conversion_of_design_user_mentions_note_id_to_bigint.rb b/db/migrate/20230207011344_initialize_conversion_of_design_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..6f192bf402c --- /dev/null +++ b/db/migrate/20230207011344_initialize_conversion_of_design_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfDesignUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :design_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230207012217_initialize_conversion_of_vulnerability_user_mentions_note_id_to_bigint.rb b/db/migrate/20230207012217_initialize_conversion_of_vulnerability_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..feaf705a770 --- /dev/null +++ b/db/migrate/20230207012217_initialize_conversion_of_vulnerability_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfVulnerabilityUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :vulnerability_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230207015819_initialize_conversion_of_commit_user_mentions_note_id_to_bigint.rb b/db/migrate/20230207015819_initialize_conversion_of_commit_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..bede8624c2b --- /dev/null +++ b/db/migrate/20230207015819_initialize_conversion_of_commit_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfCommitUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :commit_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230207025259_initialize_conversion_of_merge_request_user_mentions_note_id_to_bigint.rb b/db/migrate/20230207025259_initialize_conversion_of_merge_request_user_mentions_note_id_to_bigint.rb new file mode 100644 index 00000000000..ef8b2a27393 --- /dev/null +++ b/db/migrate/20230207025259_initialize_conversion_of_merge_request_user_mentions_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfMergeRequestUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :merge_request_user_mentions + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230207030244_initialize_conversion_of_timelogs_note_id_to_bigint.rb b/db/migrate/20230207030244_initialize_conversion_of_timelogs_note_id_to_bigint.rb new file mode 100644 index 00000000000..85e218f8e64 --- /dev/null +++ b/db/migrate/20230207030244_initialize_conversion_of_timelogs_note_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfTimelogsNoteIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :timelogs + COLUMNS = %i[note_id] + + enable_lock_retries! + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20230208103640_rename_runner_machine_xid.rb b/db/migrate/20230208103640_rename_runner_machine_xid.rb new file mode 100644 index 00000000000..c9c9ffd324f --- /dev/null +++ b/db/migrate/20230208103640_rename_runner_machine_xid.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RenameRunnerMachineXid < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + rename_column_concurrently :ci_runner_machines, :machine_xid, :system_xid + end + + def down + undo_rename_column_concurrently :ci_runner_machines, :machine_xid, :system_xid + end +end diff --git a/db/migrate/20230210181214_add_allow_deploy_tokens_and_keys_with_external_authn_to_application_settings.rb b/db/migrate/20230210181214_add_allow_deploy_tokens_and_keys_with_external_authn_to_application_settings.rb new file mode 100644 index 00000000000..d65fbca1975 --- /dev/null +++ b/db/migrate/20230210181214_add_allow_deploy_tokens_and_keys_with_external_authn_to_application_settings.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddAllowDeployTokensAndKeysWithExternalAuthnToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column(:application_settings, :allow_deploy_tokens_and_keys_with_external_authn, :boolean, + default: false, null: false) + end +end diff --git a/db/migrate/20230214142447_remove_text_limit_from_ci_job_artifacts_original_filename.rb b/db/migrate/20230214142447_remove_text_limit_from_ci_job_artifacts_original_filename.rb new file mode 100644 index 00000000000..68552839a54 --- /dev/null +++ b/db/migrate/20230214142447_remove_text_limit_from_ci_job_artifacts_original_filename.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveTextLimitFromCiJobArtifactsOriginalFilename < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + # In preparation for 20230214142813_remove_ci_job_artifacts_original_filename.rb + # We first remove the text limit before removing the column. + # This is to properly reverse the 2-step migration to add a text column with limit + # https://docs.gitlab.com/ee/development/database/strings_and_the_text_data_type.html#add-a-text-column-to-an-existing-table + remove_text_limit :ci_job_artifacts, :original_filename + end + + def down + add_text_limit :ci_job_artifacts, :original_filename, 512 + end +end diff --git a/db/migrate/20230214142813_remove_ci_job_artifacts_original_filename.rb b/db/migrate/20230214142813_remove_ci_job_artifacts_original_filename.rb new file mode 100644 index 00000000000..fed09fb113d --- /dev/null +++ b/db/migrate/20230214142813_remove_ci_job_artifacts_original_filename.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class RemoveCiJobArtifactsOriginalFilename < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def up + # This column has never been used and has always been under ignore_column since it was added. + # We're doing the removal of the ignore_column in the same MR with this migration and this + # is why we are not doing this in post migrate. + remove_column :ci_job_artifacts, :original_filename, :text # rubocop:disable Migration/RemoveColumn + end + + def down + add_column :ci_job_artifacts, :original_filename, :text + end +end |