diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-20 14:43:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-20 14:43:17 +0300 |
commit | dfc94207fec2d84314b1a5410cface22e8b369bd (patch) | |
tree | c54022f61ced104305889a64de080998a0dc773b /db/migrate | |
parent | b874efeff674f6bf0355d5d242ecf81c6f7155df (diff) |
Add latest changes from gitlab-org/gitlab@15-11-stable-eev15.11.0-rc42
Diffstat (limited to 'db/migrate')
402 files changed, 1445 insertions, 5258 deletions
diff --git a/db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb b/db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb deleted file mode 100644 index bc515bc061c..00000000000 --- a/db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddThrottleAuthenticatedGitLfsColumns < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :application_settings, :throttle_authenticated_git_lfs_requests_per_period, :integer, default: 1000, null: false - add_column :application_settings, :throttle_authenticated_git_lfs_period_in_seconds, :integer, default: 60, null: false - add_column :application_settings, :throttle_authenticated_git_lfs_enabled, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :application_settings, :throttle_authenticated_git_lfs_requests_per_period - remove_column :application_settings, :throttle_authenticated_git_lfs_period_in_seconds - remove_column :application_settings, :throttle_authenticated_git_lfs_enabled, :boolean - end - end -end diff --git a/db/migrate/20210830140524_add_state_to_member.rb b/db/migrate/20210830140524_add_state_to_member.rb deleted file mode 100644 index 6009376badb..00000000000 --- a/db/migrate/20210830140524_add_state_to_member.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddStateToMember < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - def up - unless column_exists?(:members, :state) - with_lock_retries do - add_column :members, :state, :integer, limit: 2, default: 0 - end - end - end - - def down - if column_exists?(:members, :state) - with_lock_retries do - remove_column :members, :state - end - end - end -end diff --git a/db/migrate/20210830154358_add_yaml_limit_constraints.rb b/db/migrate/20210830154358_add_yaml_limit_constraints.rb deleted file mode 100644 index 74236993fff..00000000000 --- a/db/migrate/20210830154358_add_yaml_limit_constraints.rb +++ /dev/null @@ -1,25 +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 AddYamlLimitConstraints < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - SIZE_CONSTRAINT_NAME = 'app_settings_yaml_max_size_positive' - DEPTH_CONSTRAINT_NAME = 'app_settings_yaml_max_depth_positive' - - disable_ddl_transaction! - - def up - add_check_constraint :application_settings, 'max_yaml_size_bytes > 0', SIZE_CONSTRAINT_NAME - add_check_constraint :application_settings, 'max_yaml_depth > 0', DEPTH_CONSTRAINT_NAME - end - - def down - remove_check_constraint :application_settings, SIZE_CONSTRAINT_NAME - remove_check_constraint :application_settings, DEPTH_CONSTRAINT_NAME - end -end diff --git a/db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb b/db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb deleted file mode 100644 index a3366bd9ddb..00000000000 --- a/db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddPackageFileIdChannelIdxToPackagesHelmFileMetadata < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_helm_file_metadata_on_pf_id_and_channel' - - def up - add_concurrent_index :packages_helm_file_metadata, [:package_file_id, :channel], name: INDEX_NAME - end - - def down - remove_concurrent_index :packages_helm_file_metadata, [:package_file_id, :channel], name: INDEX_NAME - end -end diff --git a/db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb b/db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb deleted file mode 100644 index 5e65b5c0fe1..00000000000 --- a/db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddInstallableHelmPkgsIdxToPackages < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'idx_installable_helm_pkgs_on_project_id_id' - - def up - add_concurrent_index :packages_packages, [:project_id, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index :packages_packages, [:project_id, :id], name: INDEX_NAME - end -end diff --git a/db/migrate/20210831203408_upsert_base_work_item_types.rb b/db/migrate/20210831203408_upsert_base_work_item_types.rb deleted file mode 100644 index 9a556bd6c2c..00000000000 --- a/db/migrate/20210831203408_upsert_base_work_item_types.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class UpsertBaseWorkItemTypes < ActiveRecord::Migration[6.1] - module WorkItem - class Type < ActiveRecord::Base - self.table_name = 'work_item_types' - - enum base_type: { - issue: 0, - incident: 1, - test_case: 2, - requirement: 3 - } - end - end - - def up - # upsert default types - WorkItem::Type.find_or_create_by(name: 'Issue', namespace_id: nil, base_type: :issue, icon_name: 'issue-type-issue') - WorkItem::Type.find_or_create_by(name: 'Incident', namespace_id: nil, base_type: :incident, icon_name: 'issue-type-incident') - WorkItem::Type.find_or_create_by(name: 'Test Case', namespace_id: nil, base_type: :test_case, icon_name: 'issue-type-test-case') - WorkItem::Type.find_or_create_by(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/20210901065504_add_index_on_name_and_id_to_public_groups.rb b/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb deleted file mode 100644 index e0c9d932b38..00000000000 --- a/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnNameAndIdToPublicGroups < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_namespaces_public_groups_name_id' - PUBLIC_VISIBILITY_LEVEL = 20 - - disable_ddl_transaction! - - def up - add_concurrent_index :namespaces, [:name, :id], - name: INDEX_NAME, - where: "type = 'Group' AND visibility_level = #{PUBLIC_VISIBILITY_LEVEL}" - end - - def down - remove_concurrent_index_by_name :namespaces, INDEX_NAME - end -end diff --git a/db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb b/db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb deleted file mode 100644 index 3c022cbaf5e..00000000000 --- a/db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddLatestColumnIntoTheSecurityScansTable < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :security_scans, :latest, :boolean, default: true, null: false - end - - def down - remove_column :security_scans, :latest - end -end diff --git a/db/migrate/20210902171808_set_default_job_token_scope_false.rb b/db/migrate/20210902171808_set_default_job_token_scope_false.rb deleted file mode 100644 index 0680382094f..00000000000 --- a/db/migrate/20210902171808_set_default_job_token_scope_false.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class SetDefaultJobTokenScopeFalse < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - 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/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb b/db/migrate/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb deleted file mode 100644 index 4638637331d..00000000000 --- a/db/migrate/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddExpireAccessTokensToDoorkeeperApplication < Gitlab::Database::Migration[1.0] - def change - add_column :oauth_applications, :expire_access_tokens, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb b/db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb deleted file mode 100644 index 6c5d23d8703..00000000000 --- a/db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -class RecreateStageIssueEventsTableWithBigints < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - def up - drop_table :analytics_cycle_analytics_issue_stage_events # rubocop:disable Migration/DropTable - - execute <<~SQL - CREATE TABLE analytics_cycle_analytics_issue_stage_events ( - stage_event_hash_id bigint NOT NULL, - issue_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, 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 - - 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 -end diff --git a/db/migrate/20210906100021_delete_project_namespace_trigger.rb b/db/migrate/20210906100021_delete_project_namespace_trigger.rb deleted file mode 100644 index ce68cf7d6d4..00000000000 --- a/db/migrate/20210906100021_delete_project_namespace_trigger.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class DeleteProjectNamespaceTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - TRIGGER_NAME = "trigger_delete_project_namespace_on_project_delete" - FUNCTION_NAME = 'delete_associated_project_namespace' - - def up - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - DELETE FROM namespaces - WHERE namespaces.id = OLD.project_namespace_id AND - namespaces.type = 'Project'; - RETURN NULL; - SQL - end - - execute(<<~SQL.squish) - CREATE TRIGGER #{TRIGGER_NAME} - AFTER DELETE ON projects FOR EACH ROW - WHEN (OLD.project_namespace_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:projects, TRIGGER_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb b/db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb deleted file mode 100644 index 540344bd761..00000000000 --- a/db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddGroupIdFkeyForUserGroupCallout < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :user_group_callouts, :namespaces, column: :group_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :user_group_callouts, column: :group_id - end - end -end diff --git a/db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb b/db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb deleted file mode 100644 index 37b73335933..00000000000 --- a/db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUserIdFkeyForUserGroupCallout < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :user_group_callouts, :users, column: :user_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :user_group_callouts, column: :user_id - end - end -end diff --git a/db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb b/db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb deleted file mode 100644 index 85c7522d006..00000000000 --- a/db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDastSchedulesToPlanLimits < Gitlab::Database::Migration[1.0] - def change - add_column(:plan_limits, :dast_profile_schedules, :integer, default: 1, null: false) - end -end diff --git a/db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb b/db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb deleted file mode 100644 index b9980f65c98..00000000000 --- a/db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class InsertDastProfileSchedulesPlanLimits < Gitlab::Database::Migration[1.0] - def up - create_or_update_plan_limit('dast_profile_schedules', 'default', 0) - create_or_update_plan_limit('dast_profile_schedules', 'free', 1) - create_or_update_plan_limit('dast_profile_schedules', 'bronze', 1) - create_or_update_plan_limit('dast_profile_schedules', 'silver', 1) - create_or_update_plan_limit('dast_profile_schedules', 'premium', 1) - create_or_update_plan_limit('dast_profile_schedules', 'premium_trial', 1) - create_or_update_plan_limit('dast_profile_schedules', 'gold', 20) - create_or_update_plan_limit('dast_profile_schedules', 'ultimate', 20) - create_or_update_plan_limit('dast_profile_schedules', 'ultimate_trial', 20) - end - - def down - create_or_update_plan_limit('dast_profile_schedules', 'default', 0) - create_or_update_plan_limit('dast_profile_schedules', 'free', 0) - create_or_update_plan_limit('dast_profile_schedules', 'bronze', 0) - create_or_update_plan_limit('dast_profile_schedules', 'silver', 0) - create_or_update_plan_limit('dast_profile_schedules', 'premium', 0) - create_or_update_plan_limit('dast_profile_schedules', 'premium_trial', 0) - create_or_update_plan_limit('dast_profile_schedules', 'gold', 0) - create_or_update_plan_limit('dast_profile_schedules', 'ultimate', 0) - create_or_update_plan_limit('dast_profile_schedules', 'ultimate_trial', 0) - end -end diff --git a/db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb b/db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb deleted file mode 100644 index 81a76ecb10a..00000000000 --- a/db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddJobsPerStagePageSizeToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, :jobs_per_stage_page_size, :integer, default: 200, null: false - end -end diff --git a/db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb b/db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb deleted file mode 100644 index dd0796a1c86..00000000000 --- a/db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddSidekiqLimitsToApplicationSettings < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! # needed for now to avoid subtransactions - - def up - with_lock_retries do - add_column :application_settings, :sidekiq_job_limiter_mode, :smallint, default: 1, null: false - add_column :application_settings, :sidekiq_job_limiter_compression_threshold_bytes, :integer, default: 100_000, null: false - add_column :application_settings, :sidekiq_job_limiter_limit_bytes, :integer, default: 0, null: false - end - end - - def down - with_lock_retries do - remove_column :application_settings, :sidekiq_job_limiter_mode - remove_column :application_settings, :sidekiq_job_limiter_compression_threshold_bytes - remove_column :application_settings, :sidekiq_job_limiter_limit_bytes - end - end -end diff --git a/db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb b/db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb deleted file mode 100644 index b8e7c7af144..00000000000 --- a/db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToDependencyProxyManifests < Gitlab::Database::Migration[1.0] - def change - add_column :dependency_proxy_manifests, :status, :smallint, default: 0, null: false - end -end diff --git a/db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb b/db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb deleted file mode 100644 index 4fbdcad33cd..00000000000 --- a/db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToDependencyProxyBlobs < Gitlab::Database::Migration[1.0] - def change - add_column :dependency_proxy_blobs, :status, :smallint, default: 0, null: false - end -end diff --git a/db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb b/db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb deleted file mode 100644 index 447508d3d5b..00000000000 --- a/db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDataToVulnerabilityFindingEvidence < Gitlab::Database::Migration[1.0] - def change - add_column :vulnerability_finding_evidences, :data, :jsonb, default: {}, null: false - end -end diff --git a/db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb b/db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb deleted file mode 100644 index 38d9c4b5dd9..00000000000 --- a/db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexPackageIdIdOnPackageFiles < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_package_files_on_package_id_id' - - def up - disable_statement_timeout do - execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON packages_package_files (package_id, id)" unless index_exists_by_name?(:package_package_files, INDEX_NAME) - end - end - - def down - remove_concurrent_index_by_name :packages_package_files, INDEX_NAME - end -end diff --git a/db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb b/db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb deleted file mode 100644 index 52fab5a63ee..00000000000 --- a/db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddDependencyProxyTtlGroupPolicyWorkerCapacityToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, - :dependency_proxy_ttl_group_policy_worker_capacity, - :smallint, - default: 2, - null: false - end -end diff --git a/db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb b/db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb deleted file mode 100644 index 9b522f2874f..00000000000 --- a/db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddAppSettingsDepProxyTtlWorkerCapacityCheckConstraint < Gitlab::Database::Migration[1.0] - CONSTRAINT_NAME = 'app_settings_dep_proxy_ttl_policies_worker_capacity_positive' - - disable_ddl_transaction! - - def up - add_check_constraint :application_settings, 'dependency_proxy_ttl_group_policy_worker_capacity >= 0', CONSTRAINT_NAME - end - - def down - remove_check_constraint :application_settings, CONSTRAINT_NAME - end -end diff --git a/db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb b/db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb deleted file mode 100644 index ebb0de53d6a..00000000000 --- a/db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ChangeCiMinutesAdditionalPackTextLimit < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - remove_text_limit :ci_minutes_additional_packs, :purchase_xid - add_text_limit :ci_minutes_additional_packs, :purchase_xid, 50 - end - - def down - remove_text_limit :ci_minutes_additional_packs, :purchase_xid - add_text_limit :ci_minutes_additional_packs, :purchase_xid, 32, validate: false - end -end diff --git a/db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb b/db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb deleted file mode 100644 index 4b147034657..00000000000 --- a/db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddReportTypeIntoApprovalProjectRules < Gitlab::Database::Migration[1.0] - def up - add_column :approval_project_rules, :report_type, :integer, limit: 2 - end - - def down - remove_column :approval_project_rules, :report_type - end -end diff --git a/db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb b/db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb deleted file mode 100644 index 83eddf2fb0d..00000000000 --- a/db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddRunnerFeaturesToCiBuildsMetadata < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :ci_builds_metadata, :runner_features, :jsonb, default: {}, null: false - end -end diff --git a/db/migrate/20210913010411_create_agent_project_authorizations.rb b/db/migrate/20210913010411_create_agent_project_authorizations.rb deleted file mode 100644 index 02b6ac677e0..00000000000 --- a/db/migrate/20210913010411_create_agent_project_authorizations.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class CreateAgentProjectAuthorizations < Gitlab::Database::Migration[1.0] - def change - create_table :agent_project_authorizations do |t| - t.bigint :project_id, null: false - t.bigint :agent_id, null: false - t.jsonb :config, null: false - - t.index :project_id - t.index [:agent_id, :project_id], unique: true - end - end -end diff --git a/db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb b/db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb deleted file mode 100644 index 545fc125950..00000000000 --- a/db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddAgentProjectAuthorizationsForeignKeys < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :agent_project_authorizations, :projects, column: :project_id - add_concurrent_foreign_key :agent_project_authorizations, :cluster_agents, column: :agent_id - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :agent_project_authorizations, column: :project_id - end - - with_lock_retries do - remove_foreign_key_if_exists :agent_project_authorizations, column: :agent_id - end - end -end diff --git a/db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb b/db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb deleted file mode 100644 index 9dd420604f4..00000000000 --- a/db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddNamespaceTraversalIdsToCiPendingBuilds < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :ci_pending_builds, :namespace_traversal_ids, :integer, array: true, default: [] - end -end diff --git a/db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb b/db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb deleted file mode 100644 index 845697c28b5..00000000000 --- a/db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class UpdateDependencyProxyManifestsUniquenessConstraint < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'index_dep_prox_manifests_on_group_id_file_name_and_status' - OLD_INDEX_NAME = 'index_dependency_proxy_manifests_on_group_id_and_file_name' - - def up - add_concurrent_index :dependency_proxy_manifests, [:group_id, :file_name, :status], unique: true, name: NEW_INDEX_NAME - remove_concurrent_index_by_name :dependency_proxy_manifests, OLD_INDEX_NAME - end - - def down - add_concurrent_index :dependency_proxy_manifests, [:group_id, :file_name], unique: true, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :dependency_proxy_manifests, NEW_INDEX_NAME - end -end diff --git a/db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb b/db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb deleted file mode 100644 index 6e57429bca8..00000000000 --- a/db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddThrottleDeprecatedApiColumns < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, :throttle_unauthenticated_deprecated_api_requests_per_period, :integer, default: 3600, null: false - add_column :application_settings, :throttle_unauthenticated_deprecated_api_period_in_seconds, :integer, default: 3600, null: false - add_column :application_settings, :throttle_unauthenticated_deprecated_api_enabled, :boolean, default: false, null: false - - add_column :application_settings, :throttle_authenticated_deprecated_api_requests_per_period, :integer, default: 3600, null: false - add_column :application_settings, :throttle_authenticated_deprecated_api_period_in_seconds, :integer, default: 1800, null: false - add_column :application_settings, :throttle_authenticated_deprecated_api_enabled, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb b/db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb deleted file mode 100644 index 9b593fbe540..00000000000 --- a/db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddStatusIndexToDependencyProxyTables < Gitlab::Database::Migration[1.0] - MANIFEST_INDEX_NAME = 'index_dependency_proxy_manifests_on_status' - BLOB_INDEX_NAME = 'index_dependency_proxy_blobs_on_status' - - disable_ddl_transaction! - - def up - add_concurrent_index :dependency_proxy_manifests, :status, name: MANIFEST_INDEX_NAME - add_concurrent_index :dependency_proxy_blobs, :status, name: BLOB_INDEX_NAME - end - - def down - remove_concurrent_index_by_name :dependency_proxy_manifests, MANIFEST_INDEX_NAME - remove_concurrent_index_by_name :dependency_proxy_blobs, BLOB_INDEX_NAME - end -end diff --git a/db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb b/db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb deleted file mode 100644 index 35cd18c1da9..00000000000 --- a/db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnClustersIntegrationPrometheusEnabled < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_clusters_integration_prometheus_enabled' - - def up - add_concurrent_index(:clusters_integration_prometheus, [:enabled, :created_at, :cluster_id], name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:clusters_integration_prometheus, INDEX_NAME) - end -end diff --git a/db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb b/db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb deleted file mode 100644 index bdaa84f27fe..00000000000 --- a/db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnClustersIntegrationElasticStackEnabled < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_clusters_integration_elasticstack_enabled' - - def up - add_concurrent_index(:clusters_integration_elasticstack, [:enabled, :created_at, :cluster_id], name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:clusters_integration_elasticstack, INDEX_NAME) - end -end diff --git a/db/migrate/20210915070423_add_avatar_and_description_to_topic.rb b/db/migrate/20210915070423_add_avatar_and_description_to_topic.rb deleted file mode 100644 index 2ceeb53cd1e..00000000000 --- a/db/migrate/20210915070423_add_avatar_and_description_to_topic.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddAvatarAndDescriptionToTopic < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - def up - add_column :topics, :avatar, :text - add_column :topics, :description, :text - end - # rubocop:enable Migration/AddLimitToTextColumns - - def down - remove_column :topics, :avatar - remove_column :topics, :description - end -end diff --git a/db/migrate/20210916132547_add_process_mode_to_resource_groups.rb b/db/migrate/20210916132547_add_process_mode_to_resource_groups.rb deleted file mode 100644 index 6bac264fcf4..00000000000 --- a/db/migrate/20210916132547_add_process_mode_to_resource_groups.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddProcessModeToResourceGroups < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - PROCESS_MODE_UNORDERED = 0 - - def up - add_column :ci_resource_groups, :process_mode, :integer, default: PROCESS_MODE_UNORDERED, null: false, limit: 2 - end - - def down - remove_column :ci_resource_groups, :process_mode - end -end diff --git a/db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb b/db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb deleted file mode 100644 index ac4821b8007..00000000000 --- a/db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveTemporaryIndexForProjectTopicsOnTaggings < Gitlab::Database::Migration[1.0] - MIGRATION = 'ExtractProjectTopicsIntoSeparateTable' - INDEX_NAME = 'tmp_index_taggings_on_id_where_taggable_type_project' - INDEX_CONDITION = "taggable_type = 'Project'" - - disable_ddl_transaction! - - def up - # Ensure that no background jobs of 20210730104800_schedule_extract_project_topics_into_separate_table remain - finalize_background_migration MIGRATION - # this index was used in 20210730104800_schedule_extract_project_topics_into_separate_table - remove_concurrent_index_by_name :taggings, INDEX_NAME - end - - def down - add_concurrent_index :taggings, :id, where: INDEX_CONDITION, name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation - end -end diff --git a/db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb b/db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb deleted file mode 100644 index 456788de521..00000000000 --- a/db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemovePipelineFkFromPackagesBuildInfos < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(:packages_build_infos, :ci_pipelines) - end - end - - def down - add_concurrent_foreign_key(:packages_build_infos, :ci_pipelines, column: :pipeline_id, on_delete: :nullify) - end -end diff --git a/db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb b/db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb deleted file mode 100644 index 187ddc8a088..00000000000 --- a/db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemovePipelineFkFromPackagesPackageFileBuildInfos < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(:packages_package_file_build_infos, :ci_pipelines) - end - end - - def down - add_concurrent_foreign_key(:packages_package_file_build_infos, :ci_pipelines, column: :pipeline_id, on_delete: :nullify) - end -end diff --git a/db/migrate/20210917224419_add_registration_objective_to_user_detail.rb b/db/migrate/20210917224419_add_registration_objective_to_user_detail.rb deleted file mode 100644 index ee7a474928e..00000000000 --- a/db/migrate/20210917224419_add_registration_objective_to_user_detail.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddRegistrationObjectiveToUserDetail < Gitlab::Database::Migration[1.0] - def change - add_column :user_details, :registration_objective, :smallint - end -end diff --git a/db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb b/db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb deleted file mode 100644 index 83ceaa58ff4..00000000000 --- a/db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToTopicsDescriptionAndAvatar < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :topics, :description, 1024 - add_text_limit :topics, :avatar, 255 - end - - def down - remove_text_limit :topics, :avatar - remove_text_limit :topics, :description - end -end diff --git a/db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb b/db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb deleted file mode 100644 index 5ac12eccc7d..00000000000 --- a/db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddSuggestPipelineEnabledToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, :suggest_pipeline_enabled, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb b/db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb deleted file mode 100644 index 67975636488..00000000000 --- a/db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -class IndexLabelsUsingVarcharPatternOps < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - NEW_TITLE_INDEX_NAME = 'index_labels_on_title_varchar' - NEW_PROJECT_ID_TITLE_INDEX_NAME = 'index_labels_on_project_id_and_title_varchar_unique' - NEW_GROUP_ID_TITLE_INDEX_NAME = 'index_labels_on_group_id_and_title_varchar_unique' - NEW_GROUP_ID_INDEX_NAME = 'index_labels_on_group_id' - - OLD_TITLE_INDEX_NAME = 'index_labels_on_title' - OLD_PROJECT_ID_TITLE_INDEX_NAME = 'index_labels_on_project_id_and_title_unique' - OLD_GROUP_ID_TITLE_INDEX_NAME = 'index_labels_on_group_id_and_title_unique' - OLD_GROUP_ID_PROJECT_ID_TITLE_INDEX_NAME = 'index_labels_on_group_id_and_project_id_and_title' - - def up - add_concurrent_index :labels, :title, order: { title: :varchar_pattern_ops }, name: NEW_TITLE_INDEX_NAME - add_concurrent_index :labels, [:project_id, :title], where: "labels.group_id IS NULL", unique: true, order: { title: :varchar_pattern_ops }, name: NEW_PROJECT_ID_TITLE_INDEX_NAME - add_concurrent_index :labels, [:group_id, :title], where: "labels.project_id IS NULL", unique: true, order: { title: :varchar_pattern_ops }, name: NEW_GROUP_ID_TITLE_INDEX_NAME - add_concurrent_index :labels, :group_id, name: NEW_GROUP_ID_INDEX_NAME - - remove_concurrent_index_by_name :labels, OLD_TITLE_INDEX_NAME - remove_concurrent_index_by_name :labels, OLD_PROJECT_ID_TITLE_INDEX_NAME - remove_concurrent_index_by_name :labels, OLD_GROUP_ID_TITLE_INDEX_NAME - remove_concurrent_index_by_name :labels, OLD_GROUP_ID_PROJECT_ID_TITLE_INDEX_NAME - end - - def down - add_concurrent_index :labels, :title, name: OLD_TITLE_INDEX_NAME - add_concurrent_index :labels, [:project_id, :title], where: "labels.group_id IS NULL", unique: true, name: OLD_PROJECT_ID_TITLE_INDEX_NAME - add_concurrent_index :labels, [:group_id, :title], where: "labels.project_id IS NULL", unique: true, name: OLD_GROUP_ID_TITLE_INDEX_NAME - add_concurrent_index :labels, [:group_id, :project_id, :title], unique: true, name: OLD_GROUP_ID_PROJECT_ID_TITLE_INDEX_NAME - - remove_concurrent_index_by_name :labels, NEW_TITLE_INDEX_NAME - remove_concurrent_index_by_name :labels, NEW_PROJECT_ID_TITLE_INDEX_NAME - remove_concurrent_index_by_name :labels, NEW_GROUP_ID_TITLE_INDEX_NAME - remove_concurrent_index_by_name :labels, NEW_GROUP_ID_INDEX_NAME - end -end diff --git a/db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb b/db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb deleted file mode 100644 index c03c463b9bb..00000000000 --- a/db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddReportTypeIndexIntoApprovalProjectRules < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_approval_project_rules_report_type' - - def up - add_concurrent_index :approval_project_rules, :report_type, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :approval_project_rules, name: INDEX_NAME - end -end diff --git a/db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb b/db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb deleted file mode 100644 index 6cbbe582ff6..00000000000 --- a/db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueNamespacesIndexOnNameParentIdAndType < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_namespaces_name_parent_id_type' - - disable_ddl_transaction! - - def up - add_concurrent_index :namespaces, [:name, :parent_id, :type], unique: true, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :namespaces, INDEX_NAME - end -end diff --git a/db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb b/db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb deleted file mode 100644 index 001f3a6964b..00000000000 --- a/db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropUniqueNamespacesIndexOnNameAndParentId < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_namespaces_on_name_and_parent_id' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :namespaces, INDEX_NAME - end - - def down - add_concurrent_index :namespaces, [:name, :parent_id], unique: true, name: INDEX_NAME - end -end diff --git a/db/migrate/20210922215740_create_issue_customer_relations_contacts.rb b/db/migrate/20210922215740_create_issue_customer_relations_contacts.rb deleted file mode 100644 index 2d89d295608..00000000000 --- a/db/migrate/20210922215740_create_issue_customer_relations_contacts.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class CreateIssueCustomerRelationsContacts < Gitlab::Database::Migration[1.0] - def change - create_table :issue_customer_relations_contacts do |t| - t.bigint :issue_id, null: false - t.bigint :contact_id, null: false - t.timestamps_with_timezone null: false - - t.index :contact_id - t.index [:issue_id, :contact_id], unique: true, name: :index_issue_crm_contacts_on_issue_id_and_contact_id - end - end -end diff --git a/db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb b/db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb deleted file mode 100644 index 7be465ca31a..00000000000 --- a/db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddIssueCustomerRelationsContactsForeignKeys < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :issue_customer_relations_contacts, :issues, column: :issue_id - add_concurrent_foreign_key :issue_customer_relations_contacts, :customer_relations_contacts, column: :contact_id - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :issue_customer_relations_contacts, column: :issue_id - end - - with_lock_retries do - remove_foreign_key_if_exists :issue_customer_relations_contacts, column: :contact_id - end - end -end diff --git a/db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb b/db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb deleted file mode 100644 index 2958285e7a5..00000000000 --- a/db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddMetaDataToUserCreditCardValidations < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - def change - change_table :user_credit_card_validations do |t| - t.date :expiration_date - t.integer :last_digits, limit: 2 # last 4 digits - t.text :holder_name - end - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb b/db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb deleted file mode 100644 index 11d436093b7..00000000000 --- a/db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class LimitHolderNameOnUserCreditCardValidations < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :user_credit_card_validations, :holder_name, 26 # ISO IEC 7813 - - add_check_constraint(:user_credit_card_validations, 'last_digits BETWEEN 0 AND 9999', constraint_name) - end - - def down - remove_text_limit :user_credit_card_validations, :holder_name - - remove_check_constraint(:user_credit_card_validations, constraint_name) - end - - private - - def constraint_name - check_constraint_name(:user_credit_card_validations, :last_digits, 'range') - end -end diff --git a/db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb b/db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb deleted file mode 100644 index cc4f4d35f09..00000000000 --- a/db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class IndexMetaDataOnUserCreditCardValidations < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_user_credit_card_validations_meta_data_full_match' - - def up - add_concurrent_index :user_credit_card_validations, - [:holder_name, :expiration_date, :last_digits, :credit_card_validated_at], - name: INDEX_NAME - end - - def down - remove_concurrent_index :user_credit_card_validations, - [:holder_name, :expiration_date, :last_digits, :credit_card_validated_at], - name: INDEX_NAME - end -end diff --git a/db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb b/db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb deleted file mode 100644 index fc4cc1945f3..00000000000 --- a/db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class ChangeDefaultForIntegratedErrorTracking < Gitlab::Database::Migration[1.0] - def up - change_column_default :project_error_tracking_settings, :integrated, from: false, to: true - end - - def down - change_column_default :project_error_tracking_settings, :integrated, from: true, to: false - end -end diff --git a/db/migrate/20210928155022_improve_index_for_error_tracking.rb b/db/migrate/20210928155022_improve_index_for_error_tracking.rb deleted file mode 100644 index ec8427670d7..00000000000 --- a/db/migrate/20210928155022_improve_index_for_error_tracking.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ImproveIndexForErrorTracking < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_index :error_tracking_errors, %i(project_id status last_seen_at id), - order: { last_seen_at: :desc, id: :desc }, - name: 'index_et_errors_on_project_id_and_status_last_seen_at_id_desc' - - add_concurrent_index :error_tracking_errors, %i(project_id status first_seen_at id), - order: { first_seen_at: :desc, id: :desc }, - name: 'index_et_errors_on_project_id_and_status_first_seen_at_id_desc' - - add_concurrent_index :error_tracking_errors, %i(project_id status events_count id), - order: { events_count: :desc, id: :desc }, - name: 'index_et_errors_on_project_id_and_status_events_count_id_desc' - - 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' - end - - def down - 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' - - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :last_seen_at, :id], name: 'index_et_errors_on_project_id_and_status_last_seen_at_id_desc' - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :first_seen_at, :id], name: 'index_et_errors_on_project_id_and_status_first_seen_at_id_desc' - remove_concurrent_index :error_tracking_errors, [:project_id, :status, :events_count, :id], name: 'index_et_errors_on_project_id_and_status_events_count_id_desc' - end -end diff --git a/db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb b/db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb deleted file mode 100644 index ef437641f2c..00000000000 --- a/db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddGroupIdStatusIdIndexToDependencyProxyTables < Gitlab::Database::Migration[1.0] - MANIFEST_INDEX_NAME = 'index_dependency_proxy_manifests_on_group_id_status_and_id' - BLOB_INDEX_NAME = 'index_dependency_proxy_blobs_on_group_id_status_and_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :dependency_proxy_manifests, [:group_id, :status, :id], name: MANIFEST_INDEX_NAME - add_concurrent_index :dependency_proxy_blobs, [:group_id, :status, :id], name: BLOB_INDEX_NAME - end - - def down - remove_concurrent_index_by_name :dependency_proxy_manifests, MANIFEST_INDEX_NAME - remove_concurrent_index_by_name :dependency_proxy_blobs, BLOB_INDEX_NAME - end -end diff --git a/db/migrate/20210929025600_add_phone_to_user_details.rb b/db/migrate/20210929025600_add_phone_to_user_details.rb deleted file mode 100644 index 9bcfd4ab7e3..00000000000 --- a/db/migrate/20210929025600_add_phone_to_user_details.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddPhoneToUserDetails < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - # rubocop:disable Migration/AddLimitToTextColumns - def up - add_column :user_details, :phone, :text, comment: 'JiHu-specific column' - end - # rubocop:enable Migration/AddLimitToTextColumns - - def down - remove_column :user_details, :phone - end -end diff --git a/db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb b/db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb deleted file mode 100644 index f250aad3253..00000000000 --- a/db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToUserDetailsPhone < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :user_details, :phone, 32 - end - - def down - remove_text_limit :user_details, :phone - end -end diff --git a/db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb b/db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb deleted file mode 100644 index e0cf7aa8a44..00000000000 --- a/db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexPhoneOnUserDetails < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_user_details_on_phone' - - def up - add_concurrent_index :user_details, :phone, unique: true, where: 'phone IS NOT NULL', name: INDEX_NAME, comment: 'JiHu-specific index' - end - - def down - remove_concurrent_index_by_name :user_details, INDEX_NAME - end -end diff --git a/db/migrate/20210929032555_create_verification_codes.rb b/db/migrate/20210929032555_create_verification_codes.rb deleted file mode 100644 index ad743641b9c..00000000000 --- a/db/migrate/20210929032555_create_verification_codes.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class CreateVerificationCodes < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - def up - constraint_visitor_id_code = check_constraint_name('verification_codes', 'visitor_id_code', 'max_length') - constraint_code = check_constraint_name('verification_codes', 'code', 'max_length') - constraint_phone = check_constraint_name('verification_codes', 'phone', 'max_length') - - execute(<<~SQL) - CREATE TABLE verification_codes ( - created_at timestamp with time zone NOT NULL DEFAULT NOW(), - visitor_id_code text, - code text, - phone text, - PRIMARY KEY (created_at, visitor_id_code, code, phone), - CONSTRAINT #{constraint_visitor_id_code} CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT #{constraint_code} CHECK ((char_length(code) <= 8)), - CONSTRAINT #{constraint_phone} CHECK ((char_length(phone) <= 32)) - ) PARTITION BY RANGE (created_at); - COMMENT ON TABLE verification_codes IS 'JiHu-specific table'; - - CREATE UNIQUE INDEX index_verification_codes_on_phone_and_visitor_id_code ON verification_codes (visitor_id_code, phone, created_at); - COMMENT ON INDEX index_verification_codes_on_phone_and_visitor_id_code IS 'JiHu-specific index'; - SQL - - min_date = Date.today - 1.month - max_date = Date.today + 1.month - create_daterange_partitions('verification_codes', 'created_at', min_date, max_date) - end - - def down - drop_table :verification_codes - end -end diff --git a/db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb b/db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb deleted file mode 100644 index 1335c06cf1f..00000000000 --- a/db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddSecurityPolicyConfigurationsManagementProjectIdForeignKey < Gitlab::Database::Migration[1.0] - CONSTRAINT_NAME = 'fk_security_policy_configurations_management_project_id' - OLD_CONSTRAINT_NAME = 'fk_rails_42ed6c25ec' - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:security_orchestration_policy_configurations, :projects, column: :security_policy_management_project_id, on_delete: :cascade, name: CONSTRAINT_NAME) - remove_foreign_key_if_exists(:security_orchestration_policy_configurations, column: :security_policy_management_project_id, on_delete: :restrict, name: OLD_CONSTRAINT_NAME) - end - - def down - add_concurrent_foreign_key(:security_orchestration_policy_configurations, :projects, column: :security_policy_management_project_id, on_delete: :restrict, name: OLD_CONSTRAINT_NAME) - remove_foreign_key_if_exists(:security_orchestration_policy_configurations, column: :security_policy_management_project_id, on_delete: :cascade, name: CONSTRAINT_NAME) - end -end diff --git a/db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb b/db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb deleted file mode 100644 index 60ca3040d70..00000000000 --- a/db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true -class AddReleasesAuthorIdIdCreatedAtIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_releases_on_author_id_id_created_at' - - def up - add_concurrent_index :releases, [:author_id, :id, :created_at], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :releases, INDEX_NAME - end -end diff --git a/db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb b/db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb deleted file mode 100644 index 166afa13371..00000000000 --- a/db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb +++ /dev/null @@ -1,16 +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 AddWarnAboutPotentiallyUnwantedCharactersToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :project_settings, :warn_about_potentially_unwanted_characters, :boolean, null: false, default: true - end - - def down - remove_column :project_settings, :warn_about_potentially_unwanted_characters - end -end diff --git a/db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb b/db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb deleted file mode 100644 index be82b16ee8c..00000000000 --- a/db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class FixDeprecatedApiThrottleDefaults < Gitlab::Database::Migration[1.0] - def change - change_column_default :application_settings, :throttle_unauthenticated_deprecated_api_requests_per_period, from: 3600, to: 1800 - change_column_default :application_settings, :throttle_authenticated_deprecated_api_period_in_seconds, from: 1800, to: 3600 - end -end diff --git a/db/migrate/20211001001222_add_source_version_to_bulk_imports.rb b/db/migrate/20211001001222_add_source_version_to_bulk_imports.rb deleted file mode 100644 index d0eb4a32cac..00000000000 --- a/db/migrate/20211001001222_add_source_version_to_bulk_imports.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddSourceVersionToBulkImports < Gitlab::Database::Migration[1.0] - def change - add_column :bulk_imports, :source_version, :text # rubocop:disable Migration/AddLimitToTextColumns - end -end diff --git a/db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb b/db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb deleted file mode 100644 index c24883b626d..00000000000 --- a/db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateCoverageFuzzingCorpuses < Gitlab::Database::Migration[1.0] - def change - create_table :coverage_fuzzing_corpuses do |t| - t.bigint :project_id, null: false - t.bigint :user_id - t.bigint :package_id, null: false - - t.datetime_with_timezone :file_updated_at, null: false, default: -> { 'NOW()' } - t.timestamps_with_timezone null: false - - t.index :project_id - t.index :user_id - t.index :package_id - end - end -end diff --git a/db/migrate/20211004075629_add_topics_name_gin_index.rb b/db/migrate/20211004075629_add_topics_name_gin_index.rb deleted file mode 100644 index 94634a4cb2f..00000000000 --- a/db/migrate/20211004075629_add_topics_name_gin_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTopicsNameGinIndex < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_topics_on_name_trigram' - - disable_ddl_transaction! - - def up - add_concurrent_index :topics, :name, name: INDEX_NAME, using: :gin, opclass: { name: :gin_trgm_ops } - end - - def down - remove_concurrent_index_by_name :topics, INDEX_NAME - end -end diff --git a/db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb b/db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb deleted file mode 100644 index 3e44c388617..00000000000 --- a/db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddExternalEventDestinationLimitToPlanLimits < Gitlab::Database::Migration[1.0] - def change - add_column(:plan_limits, :external_audit_event_destinations, :integer, default: 5, null: false) - end -end diff --git a/db/migrate/20211004122540_create_member_tasks.rb b/db/migrate/20211004122540_create_member_tasks.rb deleted file mode 100644 index e1141873bcb..00000000000 --- a/db/migrate/20211004122540_create_member_tasks.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CreateMemberTasks < Gitlab::Database::Migration[1.0] - def change - create_table :member_tasks do |t| - t.references :member, index: true, null: false - t.references :project, index: true, null: false - t.timestamps_with_timezone null: false - t.integer :tasks, limit: 2, array: true, null: false, default: [] - t.index [:member_id, :project_id], unique: true - end - end -end diff --git a/db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb b/db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb deleted file mode 100644 index ba1fb443343..00000000000 --- a/db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCorpusesOnProject < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :coverage_fuzzing_corpuses, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :coverage_fuzzing_corpuses, column: :project_id - end - end -end diff --git a/db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb b/db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb deleted file mode 100644 index da08ab97acf..00000000000 --- a/db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCorpusesOnUser < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :coverage_fuzzing_corpuses, :users, column: :user_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :coverage_fuzzing_corpuses, column: :user_id - end - end -end diff --git a/db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb b/db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb deleted file mode 100644 index 74ba7b070d0..00000000000 --- a/db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCorpusesOnPackage < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :coverage_fuzzing_corpuses, :packages_packages, column: :package_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :coverage_fuzzing_corpuses, column: :package_id - end - end -end diff --git a/db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb b/db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb deleted file mode 100644 index 2aaf5e4cf87..00000000000 --- a/db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class DropTimeRangePartitionedLooseFk < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers - - def up - # the table is not in use - drop_table :loose_foreign_keys_deleted_records # rubocop: disable Migration/DropTable - end - - def down - 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 -end diff --git a/db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb b/db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb deleted file mode 100644 index 6f52b6ec63b..00000000000 --- a/db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class AddRangePartitionedLooseFkTable < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - def up - constraint_name = check_constraint_name('loose_foreign_keys_deleted_records', 'fully_qualified_table_name', 'max_length') - execute(<<~SQL) - CREATE TABLE loose_foreign_keys_deleted_records ( - id BIGSERIAL NOT NULL, - partition bigint NOT NULL, - primary_key_value bigint NOT NULL, - status smallint NOT NULL DEFAULT 1, - created_at timestamp with time zone NOT NULL DEFAULT NOW(), - fully_qualified_table_name text NOT NULL, - PRIMARY KEY (partition, id), - CONSTRAINT #{constraint_name} CHECK ((char_length(fully_qualified_table_name) <= 150)) - ) PARTITION BY LIST (partition); - - CREATE TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 - PARTITION OF loose_foreign_keys_deleted_records - FOR VALUES IN (1); - SQL - end - - def down - drop_table :loose_foreign_keys_deleted_records - end -end diff --git a/db/migrate/20211005100112_recreate_loose_fk_insert_function.rb b/db/migrate/20211005100112_recreate_loose_fk_insert_function.rb deleted file mode 100644 index b03ad069eba..00000000000 --- a/db/migrate/20211005100112_recreate_loose_fk_insert_function.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class RecreateLooseFkInsertFunction < Gitlab::Database::Migration[1.0] - 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 - (partition, fully_qualified_table_name, primary_key_value) - SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table - ON CONFLICT DO NOTHING; - - RETURN NULL; - END - $$ LANGUAGE PLPGSQL - SQL - end - - def down - # old function - 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 -end diff --git a/db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb b/db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb deleted file mode 100644 index f3447918ad3..00000000000 --- a/db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddMemberIdForeignKeyToMemberTasks < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :member_tasks, :members, column: :member_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :member_tasks, column: :member_id - end - end -end diff --git a/db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb b/db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb deleted file mode 100644 index ead6bb88e60..00000000000 --- a/db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddProjectIdForeignKeyToMemberTasks < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :member_tasks, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :member_tasks, column: :project_id - end - end -end diff --git a/db/migrate/20211006060254_add_topics_total_projects_count_cache.rb b/db/migrate/20211006060254_add_topics_total_projects_count_cache.rb deleted file mode 100644 index ebca4c70879..00000000000 --- a/db/migrate/20211006060254_add_topics_total_projects_count_cache.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddTopicsTotalProjectsCountCache < Gitlab::Database::Migration[1.0] - def up - add_column :topics, :total_projects_count, :bigint, null: false, default: 0 - end - - def down - remove_column :topics, :total_projects_count - end -end diff --git a/db/migrate/20211006103122_change_helm_channel_length.rb b/db/migrate/20211006103122_change_helm_channel_length.rb deleted file mode 100644 index 6579ca4053b..00000000000 --- a/db/migrate/20211006103122_change_helm_channel_length.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class ChangeHelmChannelLength < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :packages_helm_file_metadata, :channel, 255, constraint_name: check_constraint_name(:packages_helm_file_metadata, :channel, 'max_length_v2') - remove_text_limit :packages_helm_file_metadata, :channel, constraint_name: check_constraint_name(:packages_helm_file_metadata, :channel, 'max_length') - end - - def down - # no-op: Danger of failing if there are records with length(channel) > 63 - end -end diff --git a/db/migrate/20211006122010_add_topics_total_projects_count_index.rb b/db/migrate/20211006122010_add_topics_total_projects_count_index.rb deleted file mode 100644 index bd969a9ff0a..00000000000 --- a/db/migrate/20211006122010_add_topics_total_projects_count_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTopicsTotalProjectsCountIndex < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_topics_total_projects_count' - - disable_ddl_transaction! - - def up - add_concurrent_index :topics, [:total_projects_count, :id], order: { total_projects_count: :desc }, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :topics, INDEX_NAME - end -end diff --git a/db/migrate/20211007090229_create_issue_search_table.rb b/db/migrate/20211007090229_create_issue_search_table.rb deleted file mode 100644 index 1fc15d20bd0..00000000000 --- a/db/migrate/20211007090229_create_issue_search_table.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class CreateIssueSearchTable < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - def up - execute <<~SQL - CREATE TABLE issue_search_data ( - project_id bigint NOT NULL REFERENCES projects(id) ON DELETE CASCADE, - issue_id bigint NOT NULL REFERENCES issues(id) ON DELETE CASCADE, - created_at timestamp with time zone DEFAULT NOW() NOT NULL, - updated_at timestamp with time zone DEFAULT NOW() NOT NULL, - search_vector tsvector, - PRIMARY KEY (project_id, issue_id) - ) PARTITION BY HASH (project_id) - SQL - - # rubocop: disable Migration/AddIndex - add_index :issue_search_data, :issue_id - add_index :issue_search_data, :search_vector, using: :gin, name: 'index_issue_search_data_on_search_vector' - # rubocop: enable Migration/AddIndex - - create_hash_partitions :issue_search_data, 64 - end - - def down - drop_table :issue_search_data - end -end diff --git a/db/migrate/20211007113136_add_status_column_to_security_scans_table.rb b/db/migrate/20211007113136_add_status_column_to_security_scans_table.rb deleted file mode 100644 index d60171dead7..00000000000 --- a/db/migrate/20211007113136_add_status_column_to_security_scans_table.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStatusColumnToSecurityScansTable < Gitlab::Database::Migration[1.0] - def change - add_column :security_scans, :status, :integer, limit: 1, default: 0, null: false - end -end diff --git a/db/migrate/20211008043855_remove_notes_trigram_index.rb b/db/migrate/20211008043855_remove_notes_trigram_index.rb deleted file mode 100644 index a20ef1852e2..00000000000 --- a/db/migrate/20211008043855_remove_notes_trigram_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveNotesTrigramIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - NOTES_TRIGRAM_INDEX_NAME = 'index_notes_on_note_trigram' - - def up - remove_concurrent_index_by_name(:notes, NOTES_TRIGRAM_INDEX_NAME) - end - - def down - add_concurrent_index :notes, :note, name: NOTES_TRIGRAM_INDEX_NAME, using: :gin, opclass: { content: :gin_trgm_ops } - end -end diff --git a/db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb b/db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb deleted file mode 100644 index 862d1a26867..00000000000 --- a/db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddSharedRunnersDurationToCiNamespaceMonthlyUsages < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :ci_namespace_monthly_usages, :shared_runners_duration, :integer, default: 0, null: false - end -end diff --git a/db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb b/db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb deleted file mode 100644 index 76bb7356f0f..00000000000 --- a/db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddSharedRunnersDurationToCiProjectMonthlyUsages < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :ci_project_monthly_usages, :shared_runners_duration, :integer, default: 0, null: false - end -end diff --git a/db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb b/db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb deleted file mode 100644 index a69d12d4e52..00000000000 --- a/db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class AddHealthStatusColumnOnClustersIntegrationPrometheus < Gitlab::Database::Migration[1.0] - def change - # For now, health checks will only run on monitor demo projects - add_column :clusters_integration_prometheus, :health_status, :smallint, limit: 2, default: 0, null: false - end -end diff --git a/db/migrate/20211011004242_create_content_blocked_states.rb b/db/migrate/20211011004242_create_content_blocked_states.rb deleted file mode 100644 index d70717f9786..00000000000 --- a/db/migrate/20211011004242_create_content_blocked_states.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CreateContentBlockedStates < Gitlab::Database::Migration[1.0] - def change - create_table :content_blocked_states, comment: 'JiHu-specific table' do |t| - t.timestamps_with_timezone null: false - t.binary :commit_sha, null: false - t.binary :blob_sha, null: false - t.text :path, null: false, limit: 2048 - t.text :container_identifier, null: false, limit: 255 - - t.index [:container_identifier, :commit_sha, :path], name: 'index_content_blocked_states_on_container_id_commit_sha_path', unique: true - end - end -end diff --git a/db/migrate/20211011140930_create_ci_namespace_mirrors.rb b/db/migrate/20211011140930_create_ci_namespace_mirrors.rb deleted file mode 100644 index b9a708c5d7b..00000000000 --- a/db/migrate/20211011140930_create_ci_namespace_mirrors.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CreateCiNamespaceMirrors < Gitlab::Database::Migration[1.0] - TABLE_NAME = :ci_namespace_mirrors - INDEX_NAME = "index_gin_#{TABLE_NAME}_on_traversal_ids" - - def change - create_table TABLE_NAME do |t| - t.integer :namespace_id, null: false, index: { unique: true } - t.integer :traversal_ids, array: true, default: [], null: false - - t.index :traversal_ids, name: INDEX_NAME, using: :gin - end - end -end diff --git a/db/migrate/20211011140931_create_ci_project_mirrors.rb b/db/migrate/20211011140931_create_ci_project_mirrors.rb deleted file mode 100644 index 2407b7e0b84..00000000000 --- a/db/migrate/20211011140931_create_ci_project_mirrors.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class CreateCiProjectMirrors < Gitlab::Database::Migration[1.0] - TABLE_NAME = :ci_project_mirrors - - def change - create_table TABLE_NAME do |t| - t.integer :project_id, null: false, index: { unique: true } - t.integer :namespace_id, null: false, index: true - end - end -end diff --git a/db/migrate/20211011140932_create_namespaces_sync_events.rb b/db/migrate/20211011140932_create_namespaces_sync_events.rb deleted file mode 100644 index 06831423343..00000000000 --- a/db/migrate/20211011140932_create_namespaces_sync_events.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class CreateNamespacesSyncEvents < Gitlab::Database::Migration[1.0] - def change - create_table :namespaces_sync_events do |t| - t.references :namespace, null: false, index: true, foreign_key: { on_delete: :cascade } - end - end -end diff --git a/db/migrate/20211011141239_create_projects_sync_events.rb b/db/migrate/20211011141239_create_projects_sync_events.rb deleted file mode 100644 index 50fe988ac1b..00000000000 --- a/db/migrate/20211011141239_create_projects_sync_events.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class CreateProjectsSyncEvents < Gitlab::Database::Migration[1.0] - def change - create_table :projects_sync_events do |t| - t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade } - end - end -end diff --git a/db/migrate/20211011141242_create_namespaces_sync_trigger.rb b/db/migrate/20211011141242_create_namespaces_sync_trigger.rb deleted file mode 100644 index 91f64709f28..00000000000 --- a/db/migrate/20211011141242_create_namespaces_sync_trigger.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class CreateNamespacesSyncTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - enable_lock_retries! - - TABLE_NAME = 'namespaces' - EVENT_TABLE_NAME = 'namespaces_sync_events' - FUNCTION_NAME = 'insert_namespaces_sync_event' - TRIGGER_ON_INSERT = 'trigger_namespaces_parent_id_on_insert' - TRIGGER_ON_UPDATE = 'trigger_namespaces_parent_id_on_update' - - def up - create_trigger_function(FUNCTION_NAME) do - <<~SQL - INSERT INTO #{EVENT_TABLE_NAME} (namespace_id) - VALUES(COALESCE(NEW.id, OLD.id)); - RETURN NULL; - SQL - end - - create_trigger(TABLE_NAME, TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT') - - create_trigger(TABLE_NAME, TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do - <<~SQL - WHEN (OLD.parent_id IS DISTINCT FROM NEW.parent_id) - SQL - end - end - - def down - drop_trigger(TABLE_NAME, TRIGGER_ON_INSERT) - drop_trigger(TABLE_NAME, TRIGGER_ON_UPDATE) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20211011141243_create_projects_sync_trigger.rb b/db/migrate/20211011141243_create_projects_sync_trigger.rb deleted file mode 100644 index 03b31c35a3a..00000000000 --- a/db/migrate/20211011141243_create_projects_sync_trigger.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class CreateProjectsSyncTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - enable_lock_retries! - - TABLE_NAME = 'projects' - EVENT_TABLE_NAME = 'projects_sync_events' - FUNCTION_NAME = 'insert_projects_sync_event' - TRIGGER_ON_INSERT = 'trigger_projects_parent_id_on_insert' - TRIGGER_ON_UPDATE = 'trigger_projects_parent_id_on_update' - - def up - create_trigger_function(FUNCTION_NAME) do - <<~SQL - INSERT INTO #{EVENT_TABLE_NAME} (project_id) - VALUES(COALESCE(NEW.id, OLD.id)); - RETURN NULL; - SQL - end - - create_trigger(TABLE_NAME, TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT') - - create_trigger(TABLE_NAME, TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do - <<~SQL - WHEN (OLD.namespace_id IS DISTINCT FROM NEW.namespace_id) - SQL - end - end - - def down - drop_trigger(TABLE_NAME, TRIGGER_ON_INSERT) - drop_trigger(TABLE_NAME, TRIGGER_ON_UPDATE) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20211012015903_next_traversal_ids_sibling_function.rb b/db/migrate/20211012015903_next_traversal_ids_sibling_function.rb deleted file mode 100644 index f32b8fc5a65..00000000000 --- a/db/migrate/20211012015903_next_traversal_ids_sibling_function.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class NextTraversalIdsSiblingFunction < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - FUNCTION_NAME = 'next_traversal_ids_sibling' - - def up - # Given array [1,2,3,4,5], concatenate the first part of the array [1,2,3,4] - # with the last element in the array (5) after being incremented ([6]). - # - # [1,2,3,4,5] => [1,2,3,4,6] - execute(<<~SQL) - CREATE OR REPLACE FUNCTION #{FUNCTION_NAME}(traversal_ids INT[]) RETURNS INT[] - AS $$ - BEGIN - return traversal_ids[1:array_length(traversal_ids, 1)-1] || - ARRAY[traversal_ids[array_length(traversal_ids, 1)]+1]; - END; - $$ - LANGUAGE plpgsql - IMMUTABLE - RETURNS NULL ON NULL INPUT; - SQL - end - - def down - execute("DROP FUNCTION #{FUNCTION_NAME}(traversal_ids INT[])") - end -end diff --git a/db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb b/db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb deleted file mode 100644 index 9b4fca9a98c..00000000000 --- a/db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToBulkImportsSourceVersion < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :bulk_imports, :source_version, 63 - end - - def down - remove_text_limit :bulk_imports, :source_version - end -end diff --git a/db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb b/db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb deleted file mode 100644 index 443dbe37c0b..00000000000 --- a/db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class CleanUpMigrateMergeRequestDiffCommitUsers < Gitlab::Database::Migration[1.0] - def up - jobs = Gitlab::Database::BackgroundMigrationJob - .for_migration_class('MigrateMergeRequestDiffCommitUsers') - .pending - .to_a - - return if jobs.empty? - - say("#{jobs.length} MigrateMergeRequestDiffCommitUsers are still pending") - - # Normally we don't process background migrations in a regular migration, as - # this could take a while to complete and thus block a deployment. - # - # In this case the jobs have all been processed for GitLab.com at the time - # of writing. In addition, it's been a few releases since this migration was - # introduced. As a result, self-hosted instances should have their - # migrations finished a long time ago. - # - # For these reasons we clean up any pending jobs (just in case) before - # deploying the code. This also allows us to immediately start using the new - # setup only, instead of having to support both the old and new approach for - # at least one more release. - jobs.each do |job| - Gitlab::BackgroundMigration::MigrateMergeRequestDiffCommitUsers - .new - .perform(*job.arguments) - end - end - - def down - end -end diff --git a/db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb b/db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb deleted file mode 100644 index 9a79fdca192..00000000000 --- a/db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddContentValidationEndpointToApplicationSettings < Gitlab::Database::Migration[1.0] - def up - # rubocop:disable Migration/AddLimitToTextColumns - add_column :application_settings, :content_validation_endpoint_url, :text, comment: 'JiHu-specific column' - # rubocop:disable Migration/AddLimitToTextColumns - - add_column :application_settings, :encrypted_content_validation_api_key, :binary, comment: 'JiHu-specific column' - add_column :application_settings, :encrypted_content_validation_api_key_iv, :binary, comment: 'JiHu-specific column' - add_column :application_settings, :content_validation_endpoint_enabled, :boolean, null: false, default: false, comment: 'JiHu-specific column' - end - - def down - remove_column :application_settings, :content_validation_endpoint_url - remove_column :application_settings, :encrypted_content_validation_api_key - remove_column :application_settings, :encrypted_content_validation_api_key_iv - remove_column :application_settings, :content_validation_endpoint_enabled - end -end diff --git a/db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb b/db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb deleted file mode 100644 index eee4cbad796..00000000000 --- a/db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddNetworkToUserCreditCardValidations < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - def change - add_column :user_credit_card_validations, :network, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb b/db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb deleted file mode 100644 index 38a019e718d..00000000000 --- a/db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class LimitNetworkOnUserCreditCardValidations < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :user_credit_card_validations, :network, 32 - end - - def down - remove_text_limit :user_credit_card_validations, :network - end -end diff --git a/db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb b/db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb deleted file mode 100644 index 849dbab77db..00000000000 --- a/db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class IndexIncludeNetworkOnUserCreditCardValidations < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_user_credit_card_validations_meta_data_partial_match' - - def up - add_concurrent_index :user_credit_card_validations, - [:expiration_date, :last_digits, :network, :credit_card_validated_at], - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :user_credit_card_validations, INDEX_NAME - end -end diff --git a/db/migrate/20211013192749_add_states_into_approval_project_rules.rb b/db/migrate/20211013192749_add_states_into_approval_project_rules.rb deleted file mode 100644 index 98fefbab12c..00000000000 --- a/db/migrate/20211013192749_add_states_into_approval_project_rules.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddStatesIntoApprovalProjectRules < Gitlab::Database::Migration[1.0] - def up - add_column :approval_project_rules, :vulnerability_states, :text, array: true, null: false, default: ['newly_detected'] - end - - def down - remove_column :approval_project_rules, :vulnerability_states - end -end diff --git a/db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb b/db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb deleted file mode 100644 index adf2fdb2da7..00000000000 --- a/db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddMergeCommitTemplateToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :project_settings, :merge_commit_template, :text # rubocop:disable Migration/AddLimitToTextColumns - end -end diff --git a/db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb b/db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb deleted file mode 100644 index 972872b8d2a..00000000000 --- a/db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddMergeCommitTemplateLimitToProjectSettings < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :project_settings, :merge_commit_template, 500 - end - - def down - remove_text_limit :project_settings, :merge_commit_template - end -end diff --git a/db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb b/db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb deleted file mode 100644 index cc73cb5047b..00000000000 --- a/db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddTmpProjectIdColumnToNamespaces < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - # this is a temporary column to be able to batch insert records into namespaces table and then be able to link these - # to projects table. - add_column :namespaces, :tmp_project_id, :integer # rubocop: disable Migration/AddColumnsToWideTables - end -end diff --git a/db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb b/db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb deleted file mode 100644 index 574f54bc60e..00000000000 --- a/db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -class FixDoubleEntriesInPostgresIndexView < Gitlab::Database::Migration[1.0] - 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 AND pg_namespace.nspname = pg_indexes.schemaname - 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) || 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 -end diff --git a/db/migrate/20211019153615_add_state_to_merge_request_assignees.rb b/db/migrate/20211019153615_add_state_to_merge_request_assignees.rb deleted file mode 100644 index 0eb8d0989a5..00000000000 --- a/db/migrate/20211019153615_add_state_to_merge_request_assignees.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true -class AddStateToMergeRequestAssignees < Gitlab::Database::Migration[1.0] - REVIEW_DEFAULT_STATE = 0 - - def change - add_column :merge_request_assignees, :state, :smallint, default: REVIEW_DEFAULT_STATE, null: false - end -end diff --git a/db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb b/db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb deleted file mode 100644 index 970c018df46..00000000000 --- a/db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddRuntimeRunnerFeaturesToCiBuildsMetadata < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :ci_builds_metadata, :runtime_runner_features, :jsonb, default: {}, null: false - end -end diff --git a/db/migrate/20211020095357_add_group_traversal_id_index.rb b/db/migrate/20211020095357_add_group_traversal_id_index.rb deleted file mode 100644 index e4739ff217e..00000000000 --- a/db/migrate/20211020095357_add_group_traversal_id_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddGroupTraversalIdIndex < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_namespaces_on_traversal_ids_for_groups' - - disable_ddl_transaction! - - def up - add_concurrent_index :namespaces, :traversal_ids, using: :gin, where: "type='Group'", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :namespaces, INDEX_NAME - end -end diff --git a/db/migrate/20211021115409_add_color_to_epics.rb b/db/migrate/20211021115409_add_color_to_epics.rb deleted file mode 100644 index 14b38209f30..00000000000 --- a/db/migrate/20211021115409_add_color_to_epics.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddColorToEpics < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20211021124715_add_text_limit_to_epics_color - def change - add_column :epics, :color, :text, default: '#1068bf' - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20211021124715_add_text_limit_to_epics_color.rb b/db/migrate/20211021124715_add_text_limit_to_epics_color.rb deleted file mode 100644 index 7844575c521..00000000000 --- a/db/migrate/20211021124715_add_text_limit_to_epics_color.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToEpicsColor < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :epics, :color, 7 - end - - def down - remove_text_limit :epics, :color - end -end diff --git a/db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb b/db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb deleted file mode 100644 index d8b40893b47..00000000000 --- a/db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class AddSentrySettingsToApplicationSettings < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - def change - add_column :application_settings, :sentry_enabled, :boolean, default: false, null: false - add_column :application_settings, :sentry_dsn, :text - add_column :application_settings, :sentry_clientside_dsn, :text - add_column :application_settings, :sentry_environment, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb b/db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb deleted file mode 100644 index 34d18741788..00000000000 --- a/db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddLimitsToSentrySettingsOnApplicationSettings < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :application_settings, :sentry_dsn, 255 - add_text_limit :application_settings, :sentry_clientside_dsn, 255 - add_text_limit :application_settings, :sentry_environment, 255 - end - - def down - remove_text_limit :application_settings, :sentry_dsn - remove_text_limit :application_settings, :sentry_clientside_dsn - remove_text_limit :application_settings, :sentry_environment - end -end diff --git a/db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb b/db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb deleted file mode 100644 index 345cd1785ea..00000000000 --- a/db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStateIdToVsaIssueStageEvents < Gitlab::Database::Migration[1.0] - def change - add_column :analytics_cycle_analytics_issue_stage_events, :state_id, :smallint, default: 1, null: false - end -end diff --git a/db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb b/db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb deleted file mode 100644 index be28d56e19d..00000000000 --- a/db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStateIdToVsaMergeRequestStageEvents < Gitlab::Database::Migration[1.0] - def change - add_column :analytics_cycle_analytics_merge_request_stage_events, :state_id, :smallint, default: 1, null: false - end -end diff --git a/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb b/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb deleted file mode 100644 index 90e68f6a0ac..00000000000 --- a/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddArchiveTraceEventsToIntegrations < Gitlab::Database::Migration[1.0] - def change - add_column :integrations, :archive_trace_events, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20211026143238_remove_index_releases_on_author_id.rb b/db/migrate/20211026143238_remove_index_releases_on_author_id.rb deleted file mode 100644 index 7cd086dbf7d..00000000000 --- a/db/migrate/20211026143238_remove_index_releases_on_author_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexReleasesOnAuthorId < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_releases_on_author_id' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :releases, INDEX_NAME - end - - def down - add_concurrent_index :releases, [:author_id], name: INDEX_NAME - end -end diff --git a/db/migrate/20211027203950_add_updated_index_for_dormant_users.rb b/db/migrate/20211027203950_add_updated_index_for_dormant_users.rb deleted file mode 100644 index 8b004af06c0..00000000000 --- a/db/migrate/20211027203950_add_updated_index_for_dormant_users.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddUpdatedIndexForDormantUsers < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_users_on_id_and_last_activity_on_for_active_human_service' - - disable_ddl_transaction! - - def up - index_condition = "state = 'active' AND (users.user_type IS NULL OR users.user_type = 4)" - - add_concurrent_index :users, [:id, :last_activity_on], where: index_condition, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :users, INDEX_NAME - end -end diff --git a/db/migrate/20211028132247_create_packages_npm_metadata.rb b/db/migrate/20211028132247_create_packages_npm_metadata.rb deleted file mode 100644 index cbe5429fca1..00000000000 --- a/db/migrate/20211028132247_create_packages_npm_metadata.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class CreatePackagesNpmMetadata < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - with_lock_retries do - create_table :packages_npm_metadata, id: false do |t| - t.references :package, primary_key: true, default: nil, index: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint - t.jsonb :package_json, default: {}, null: false - - t.check_constraint 'char_length(package_json::text) < 20000' - end - end - end - - def down - with_lock_retries do - drop_table :packages_npm_metadata - end - end -end diff --git a/db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb b/db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb deleted file mode 100644 index d9949863a92..00000000000 --- a/db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDefaultToPersonalAccessTokensPrefix < Gitlab::Database::Migration[1.0] - def change - change_column_default(:application_settings, :personal_access_token_prefix, from: nil, to: 'glpat-') - end -end diff --git a/db/migrate/20211101132310_add_reindexing_queue.rb b/db/migrate/20211101132310_add_reindexing_queue.rb deleted file mode 100644 index d9d1f9dce89..00000000000 --- a/db/migrate/20211101132310_add_reindexing_queue.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddReindexingQueue < Gitlab::Database::Migration[1.0] - def change - create_table :postgres_reindex_queued_actions do |t| - t.text :index_identifier, null: false, limit: 255 - t.integer :state, limit: 2, null: false, default: 0 - t.timestamps_with_timezone null: false - - t.index :state - end - - change_column_default :postgres_reindex_queued_actions, :created_at, from: nil, to: -> { 'NOW()' } - change_column_default :postgres_reindex_queued_actions, :updated_at, from: nil, to: -> { 'NOW()' } - end -end diff --git a/db/migrate/20211101165656_create_upload_states.rb b/db/migrate/20211101165656_create_upload_states.rb deleted file mode 100644 index 64873f4c9a2..00000000000 --- a/db/migrate/20211101165656_create_upload_states.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class CreateUploadStates < Gitlab::Database::Migration[1.0] - VERIFICATION_STATE_INDEX_NAME = "index_upload_states_on_verification_state" - PENDING_VERIFICATION_INDEX_NAME = "index_upload_states_pending_verification" - FAILED_VERIFICATION_INDEX_NAME = "index_upload_states_failed_verification" - NEEDS_VERIFICATION_INDEX_NAME = "index_upload_states_needs_verification" - - disable_ddl_transaction! - - def up - create_table :upload_states, id: false do |t| - t.datetime_with_timezone :verification_started_at - t.datetime_with_timezone :verification_retry_at - t.datetime_with_timezone :verified_at - t.references :upload, primary_key: true, null: false, foreign_key: { on_delete: :cascade } - t.integer :verification_state, default: 0, limit: 2, null: false - t.integer :verification_retry_count, limit: 2 - t.binary :verification_checksum, using: 'verification_checksum::bytea' - t.text :verification_failure, limit: 255 - - t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME - t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME - t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME - t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME - end - end - - def down - drop_table :upload_states - end -end diff --git a/db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb b/db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb deleted file mode 100644 index 43cd7afbf06..00000000000 --- a/db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddWithHighestRoleMinimalAccessToUsersStatistics < Gitlab::Database::Migration[1.0] - def change - add_column :users_statistics, :with_highest_role_minimal_access, :integer, null: false, default: 0 - end -end diff --git a/db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb b/db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb deleted file mode 100644 index 4062fd1be01..00000000000 --- a/db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToApplicationSettingsContentValidationEndpointUrl < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :application_settings, :content_validation_endpoint_url, 255 - end - - def down - remove_text_limit :application_settings, :content_validation_endpoint_url - end -end diff --git a/db/migrate/20211105010101_add_archived_column_to_deployments.rb b/db/migrate/20211105010101_add_archived_column_to_deployments.rb deleted file mode 100644 index f9ac81915b4..00000000000 --- a/db/migrate/20211105010101_add_archived_column_to_deployments.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddArchivedColumnToDeployments < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :deployments, :archived, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb b/db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb deleted file mode 100644 index a594674f470..00000000000 --- a/db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddReadAtToDependencyProxyManifests < Gitlab::Database::Migration[1.0] - def change - add_column :dependency_proxy_manifests, :read_at, :datetime_with_timezone, null: false, default: -> { 'NOW()' } - end -end diff --git a/db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb b/db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb deleted file mode 100644 index 1808a541498..00000000000 --- a/db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddReadAtToDependencyProxyBlobs < Gitlab::Database::Migration[1.0] - def change - add_column :dependency_proxy_blobs, :read_at, :datetime_with_timezone, null: false, default: -> { 'NOW()' } - end -end diff --git a/db/migrate/20211105160316_create_dotenv_application_limits.rb b/db/migrate/20211105160316_create_dotenv_application_limits.rb deleted file mode 100644 index 3ea94fd60fc..00000000000 --- a/db/migrate/20211105160316_create_dotenv_application_limits.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class CreateDotenvApplicationLimits < Gitlab::Database::Migration[1.0] - def change - add_column(:plan_limits, :dotenv_variables, :integer, default: 20, null: false) - add_column(:plan_limits, :dotenv_size, :integer, default: 5.kilobytes, null: false) - end -end diff --git a/db/migrate/20211105161404_insert_dotenv_application_limits.rb b/db/migrate/20211105161404_insert_dotenv_application_limits.rb deleted file mode 100644 index 2749cf4a019..00000000000 --- a/db/migrate/20211105161404_insert_dotenv_application_limits.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class InsertDotenvApplicationLimits < Gitlab::Database::Migration[1.0] - def up - create_or_update_plan_limit('dotenv_variables', 'default', 150) - create_or_update_plan_limit('dotenv_variables', 'free', 50) - create_or_update_plan_limit('dotenv_variables', 'opensource', 150) - create_or_update_plan_limit('dotenv_variables', 'premium', 100) - create_or_update_plan_limit('dotenv_variables', 'premium_trial', 100) - create_or_update_plan_limit('dotenv_variables', 'ultimate', 150) - create_or_update_plan_limit('dotenv_variables', 'ultimate_trial', 150) - - create_or_update_plan_limit('dotenv_size', 'default', 5.kilobytes) - end - - def down - create_or_update_plan_limit('dotenv_variables', 'default', 20) - create_or_update_plan_limit('dotenv_variables', 'free', 20) - create_or_update_plan_limit('dotenv_variables', 'opensource', 20) - create_or_update_plan_limit('dotenv_variables', 'premium', 20) - create_or_update_plan_limit('dotenv_variables', 'premium_trial', 20) - create_or_update_plan_limit('dotenv_variables', 'ultimate', 20) - create_or_update_plan_limit('dotenv_variables', 'ultimate_trial', 20) - - create_or_update_plan_limit('dotenv_size', 'default', 5.kilobytes) - end -end diff --git a/db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb b/db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb deleted file mode 100644 index 38671c75e0c..00000000000 --- a/db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class CreatePipelineTriggersApplicationLimits < Gitlab::Database::Migration[1.0] - def change - add_column(:plan_limits, :pipeline_triggers, :integer, default: 25_000, null: false) - end -end diff --git a/db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb b/db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb deleted file mode 100644 index c1341fad729..00000000000 --- a/db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class InsertPipelineTriggersApplicationLimits < Gitlab::Database::Migration[1.0] - def up - create_or_update_plan_limit('pipeline_triggers', 'default', 0) - create_or_update_plan_limit('pipeline_triggers', 'free', 25_000) - create_or_update_plan_limit('pipeline_triggers', 'opensource', 0) - create_or_update_plan_limit('pipeline_triggers', 'premium', 0) - create_or_update_plan_limit('pipeline_triggers', 'premium_trial', 0) - create_or_update_plan_limit('pipeline_triggers', 'ultimate', 0) - create_or_update_plan_limit('pipeline_triggers', 'ultimate_trial', 0) - end - - def down - create_or_update_plan_limit('pipeline_triggers', 'default', 0) - create_or_update_plan_limit('pipeline_triggers', 'free', 0) - create_or_update_plan_limit('pipeline_triggers', 'opensource', 0) - create_or_update_plan_limit('pipeline_triggers', 'premium', 0) - create_or_update_plan_limit('pipeline_triggers', 'premium_trial', 0) - create_or_update_plan_limit('pipeline_triggers', 'ultimate', 0) - create_or_update_plan_limit('pipeline_triggers', 'ultimate_trial', 0) - end -end diff --git a/db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb b/db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb deleted file mode 100644 index ac0f0ddca17..00000000000 --- a/db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class UpdateDependencyProxyIndexesWithReadAt < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - NEW_BLOB_INDEX = 'index_dependency_proxy_blobs_on_group_id_status_read_at_id' - OLD_BLOB_INDEX = 'index_dependency_proxy_blobs_on_group_id_status_and_id' - - NEW_MANIFEST_INDEX = 'index_dependency_proxy_manifests_on_group_id_status_read_at_id' - OLD_MANIFEST_INDEX = 'index_dependency_proxy_manifests_on_group_id_status_and_id' - - def up - add_concurrent_index :dependency_proxy_blobs, [:group_id, :status, :read_at, :id], name: NEW_BLOB_INDEX - add_concurrent_index :dependency_proxy_manifests, [:group_id, :status, :read_at, :id], name: NEW_MANIFEST_INDEX - - remove_concurrent_index_by_name :dependency_proxy_blobs, OLD_BLOB_INDEX - remove_concurrent_index_by_name :dependency_proxy_manifests, OLD_MANIFEST_INDEX - end - - def down - add_concurrent_index :dependency_proxy_blobs, [:group_id, :status, :id], name: OLD_BLOB_INDEX - add_concurrent_index :dependency_proxy_manifests, [:group_id, :status, :id], name: OLD_MANIFEST_INDEX - - remove_concurrent_index_by_name :dependency_proxy_blobs, NEW_BLOB_INDEX - remove_concurrent_index_by_name :dependency_proxy_manifests, NEW_MANIFEST_INDEX - end -end diff --git a/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb b/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb deleted file mode 100644 index 90e5fa34817..00000000000 --- a/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddPolicyIdxToApprovalProjectRule < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :approval_project_rules, :orchestration_policy_idx, :integer, limit: 2 - end -end diff --git a/db/migrate/20211108211434_remove_index_for_resource_group.rb b/db/migrate/20211108211434_remove_index_for_resource_group.rb deleted file mode 100644 index 8b03f12d08b..00000000000 --- a/db/migrate/20211108211434_remove_index_for_resource_group.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexForResourceGroup < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_for_resource_group' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :ci_builds, INDEX_NAME - end - - def down - # rubocop:disable Migration/PreventIndexCreation - add_concurrent_index :ci_builds, [:resource_group_id, :id], where: 'resource_group_id IS NOT NULL', name: INDEX_NAME - # rubocop:enable Migration/PreventIndexCreation - end -end diff --git a/db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb b/db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb deleted file mode 100644 index 6b8e8c0d4f3..00000000000 --- a/db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddConsumeAfterToLooseFkDeletedRecords < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :loose_foreign_keys_deleted_records, :consume_after, :datetime_with_timezone, default: -> { 'NOW()' } - end - - def down - remove_column :loose_foreign_keys_deleted_records, :consume_after - end -end diff --git a/db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb b/db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb deleted file mode 100644 index fccb1fc5cac..00000000000 --- a/db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class SupportPartitionQueryInLooseFkTable < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_loose_foreign_keys_deleted_records_for_partitioned_query' - - def up - add_concurrent_partitioned_index :loose_foreign_keys_deleted_records, - %I[partition fully_qualified_table_name consume_after id], - where: 'status = 1', - name: INDEX_NAME - end - - def down - remove_concurrent_partitioned_index_by_name :loose_foreign_keys_deleted_records, INDEX_NAME - end -end diff --git a/db/migrate/20211110010101_add_index_on_unarchived_deployments.rb b/db/migrate/20211110010101_add_index_on_unarchived_deployments.rb deleted file mode 100644 index 0bfafb94d0b..00000000000 --- a/db/migrate/20211110010101_add_index_on_unarchived_deployments.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnUnarchivedDeployments < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_deployments_on_archived_project_id_iid' - - disable_ddl_transaction! - - def up - add_concurrent_index :deployments, %i[archived project_id iid], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :deployments, INDEX_NAME - end -end diff --git a/db/migrate/20211110014701_create_agent_activity_events.rb b/db/migrate/20211110014701_create_agent_activity_events.rb deleted file mode 100644 index 11b9c6d03b3..00000000000 --- a/db/migrate/20211110014701_create_agent_activity_events.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class CreateAgentActivityEvents < Gitlab::Database::Migration[1.0] - def change - create_table :agent_activity_events do |t| - t.bigint :agent_id, null: false - t.bigint :user_id, index: { where: 'user_id IS NOT NULL' } - t.bigint :project_id, index: { where: 'project_id IS NOT NULL' } - t.bigint :merge_request_id, index: { where: 'merge_request_id IS NOT NULL' } - t.bigint :agent_token_id, index: { where: 'agent_token_id IS NOT NULL' } - - t.datetime_with_timezone :recorded_at, null: false - t.integer :kind, limit: 2, null: false - t.integer :level, limit: 2, null: false - - t.binary :sha - t.text :detail, limit: 255 - - t.index [:agent_id, :recorded_at, :id] - end - end -end diff --git a/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb b/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb deleted file mode 100644 index fcbafcccb06..00000000000 --- a/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class AddAgentActivityEventsForeignKeys < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :agent_activity_events, :cluster_agents, column: :agent_id, on_delete: :cascade - add_concurrent_foreign_key :agent_activity_events, :users, column: :user_id, on_delete: :nullify - add_concurrent_foreign_key :agent_activity_events, :projects, column: :project_id, on_delete: :nullify - add_concurrent_foreign_key :agent_activity_events, :merge_requests, column: :merge_request_id, on_delete: :nullify - add_concurrent_foreign_key :agent_activity_events, :cluster_agent_tokens, column: :agent_token_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :agent_activity_events, column: :agent_id - end - - with_lock_retries do - remove_foreign_key_if_exists :agent_activity_events, column: :user_id - end - - with_lock_retries do - remove_foreign_key_if_exists :agent_activity_events, column: :project_id - end - - with_lock_retries do - remove_foreign_key_if_exists :agent_activity_events, column: :merge_request_id - end - - with_lock_retries do - remove_foreign_key_if_exists :agent_activity_events, column: :agent_token_id - end - end -end diff --git a/db/migrate/20211110092710_create_issue_emails.rb b/db/migrate/20211110092710_create_issue_emails.rb deleted file mode 100644 index 5f6104fa2c3..00000000000 --- a/db/migrate/20211110092710_create_issue_emails.rb +++ /dev/null @@ -1,21 +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 CreateIssueEmails < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - create_table :issue_emails do |t| - t.references :issue, index: true, null: false, unique: true, foreign_key: { on_delete: :cascade } - t.text :email_message_id, null: false, limit: 1000 - - t.index :email_message_id - end - end - - def down - drop_table :issue_emails - end -end diff --git a/db/migrate/20211110100050_add_has_shimo_to_project_settings.rb b/db/migrate/20211110100050_add_has_shimo_to_project_settings.rb deleted file mode 100644 index 01507908e0f..00000000000 --- a/db/migrate/20211110100050_add_has_shimo_to_project_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddHasShimoToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :project_settings, :has_shimo, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb b/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb deleted file mode 100644 index 064dc38f5b3..00000000000 --- a/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CreateMergeRequestsComplianceViolations < Gitlab::Database::Migration[1.0] - def change - create_table :merge_requests_compliance_violations do |t| - t.bigint :violating_user_id, null: false - t.bigint :merge_request_id, null: false - t.integer :reason, limit: 2, null: false - t.index :violating_user_id - t.index [:merge_request_id, :violating_user_id, :reason], unique: true, name: 'index_merge_requests_compliance_violations_unique_columns' - end - end -end diff --git a/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb b/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb deleted file mode 100644 index b280c35433b..00000000000 --- a/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddFkComplianceViolationsMergeRequest < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :merge_requests_compliance_violations, - :merge_requests, - column: :merge_request_id, - on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :merge_requests_compliance_violations, column: :merge_request_id - end - end -end diff --git a/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb b/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb deleted file mode 100644 index af1cd6f07ed..00000000000 --- a/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddFkComplianceViolationsViolatingUser < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :merge_requests_compliance_violations, - :users, - column: :violating_user_id, - on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :merge_requests_compliance_violations, column: :violating_user_id - end - end -end diff --git a/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb b/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb deleted file mode 100644 index 6120a6ed0b4..00000000000 --- a/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddSquashCommitTemplateToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :project_settings, :squash_commit_template, :text # rubocop:disable Migration/AddLimitToTextColumns - end -end diff --git a/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb b/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb deleted file mode 100644 index 578d2271d60..00000000000 --- a/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddSquashCommitTemplateLimitToProjectSettings < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :project_settings, :squash_commit_template, 500 - end - - def down - remove_text_limit :project_settings, :squash_commit_template - end -end diff --git a/db/migrate/20211112073413_change_package_index_on_corpus.rb b/db/migrate/20211112073413_change_package_index_on_corpus.rb deleted file mode 100644 index 6e8222f853c..00000000000 --- a/db/migrate/20211112073413_change_package_index_on_corpus.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class ChangePackageIndexOnCorpus < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_coverage_fuzzing_corpuses_on_package_id' - - disable_ddl_transaction! - - # Changing this index is safe. - # The table does not have any data in it as it's behind a feature flag. - def up - remove_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME - add_concurrent_index :coverage_fuzzing_corpuses, :package_id, unique: true, name: INDEX_NAME - end - - def down - remove_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME - add_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME - end -end diff --git a/db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb b/db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb deleted file mode 100644 index 8dd23e1a72e..00000000000 --- a/db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class PopulateDefaultValueForPersonalAccessTokensPrefix < Gitlab::Database::Migration[1.0] - def up - execute( - <<-SQL - UPDATE - application_settings - SET - personal_access_token_prefix = default - WHERE - personal_access_token_prefix IS NULL - SQL - ) - end - - def down - # no-op - end -end diff --git a/db/migrate/20211115132613_create_incident_management_timeline_events.rb b/db/migrate/20211115132613_create_incident_management_timeline_events.rb deleted file mode 100644 index 217dcd27b4c..00000000000 --- a/db/migrate/20211115132613_create_incident_management_timeline_events.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class CreateIncidentManagementTimelineEvents < Gitlab::Database::Migration[1.0] - def up - create_table :incident_management_timeline_events do |t| - t.timestamps_with_timezone null: false - t.datetime_with_timezone :occurred_at, null: false - t.bigint :project_id, null: false - t.bigint :author_id - t.bigint :issue_id, null: false - t.bigint :updated_by_user_id - t.bigint :promoted_from_note_id - t.integer :cached_markdown_version - t.boolean :editable, null: false, default: false - t.text :note, limit: 10_000, null: false - t.text :note_html, limit: 10_000, null: false - t.text :action, limit: 128, null: false - - t.index :project_id, name: 'index_im_timeline_events_project_id' - t.index :author_id, name: 'index_im_timeline_events_author_id' - t.index :issue_id, name: 'index_im_timeline_events_issue_id' - t.index :updated_by_user_id, name: 'index_im_timeline_events_updated_by_user_id' - t.index :promoted_from_note_id, name: 'index_im_timeline_events_promoted_from_note_id' - end - end - - def down - drop_table :incident_management_timeline_events - end -end diff --git a/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb b/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb deleted file mode 100644 index 893043cc1ab..00000000000 --- a/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToIncidentManagementTimelineEventsOnProject < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :incident_management_timeline_events, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :incident_management_timeline_events, column: :project_id - end - end -end diff --git a/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb b/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb deleted file mode 100644 index 0f5886eb5ed..00000000000 --- a/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToIncidentManagementTimelineEventsOnUser < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :author_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :incident_management_timeline_events, column: :author_id - end - end -end diff --git a/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb b/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb deleted file mode 100644 index bdcf7f389d1..00000000000 --- a/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToIncidentManagementTimelineEventsOnIssue < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :incident_management_timeline_events, :issues, column: :issue_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :incident_management_timeline_events, column: :issue_id - end - end -end diff --git a/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb b/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb deleted file mode 100644 index e0e2bec72ad..00000000000 --- a/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddCreatedAtToNamespaceMonthlyUsages < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :ci_namespace_monthly_usages, :created_at, :datetime_with_timezone - end - end - - def down - with_lock_retries do - remove_column :ci_namespace_monthly_usages, :created_at - end - end -end diff --git a/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb b/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb deleted file mode 100644 index eb0cd448da3..00000000000 --- a/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddCreatedAtToProjectMonthlyUsage < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :ci_project_monthly_usages, :created_at, :datetime_with_timezone - end - end - - def down - with_lock_retries do - remove_column :ci_project_monthly_usages, :created_at - end - end -end diff --git a/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb b/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb deleted file mode 100644 index a35020699fc..00000000000 --- a/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToIncidentManagementTimelineEventsOnUpdatedByUser < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :updated_by_user_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :incident_management_timeline_events, column: :updated_by_user_id - end - end -end diff --git a/db/migrate/20211117174209_create_vulnerability_reads.rb b/db/migrate/20211117174209_create_vulnerability_reads.rb deleted file mode 100644 index b9e32bfd0fa..00000000000 --- a/db/migrate/20211117174209_create_vulnerability_reads.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class CreateVulnerabilityReads < Gitlab::Database::Migration[1.0] - def change - create_table :vulnerability_reads do |t| - t.bigint :vulnerability_id, null: false - t.bigint :project_id, null: false - t.bigint :scanner_id, null: false - t.integer :report_type, limit: 2, null: false - t.integer :severity, limit: 2, null: false - t.integer :state, limit: 2, null: false - t.boolean :has_issues, default: false, null: false - t.boolean :resolved_on_default_branch, default: false, null: false - t.uuid :uuid, null: false - t.text :location_image, limit: 2048 - - t.index :vulnerability_id, unique: true - t.index :scanner_id - t.index :uuid, unique: true - t.index [:project_id, :state, :severity, :vulnerability_id], name: :index_vuln_reads_on_project_id_state_severity_and_vuln_id, order: { vulnerability_id: :desc } - t.index :location_image, where: "report_type IN (2, 7)", name: :index_vulnerability_reads_on_location_image - end - end -end diff --git a/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb b/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb deleted file mode 100644 index 185178d8025..00000000000 --- a/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class ChangeDefaultValueOfLooseFkDeletedRecordsPartition < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - change_column_default(:loose_foreign_keys_deleted_records, :partition, from: nil, to: 1) - end -end diff --git a/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb b/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb deleted file mode 100644 index 33159167b19..00000000000 --- a/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class RemoveHardcodedPartitionFromLooseFkTriggerFunction < Gitlab::Database::Migration[1.0] - include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers - - enable_lock_retries! - - def up - execute(<<~SQL) - CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}() - RETURNS TRIGGER AS - $$ - BEGIN - INSERT INTO loose_foreign_keys_deleted_records - (fully_qualified_table_name, primary_key_value) - SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table; - - RETURN NULL; - END - $$ LANGUAGE PLPGSQL - SQL - end - - def down - execute(<<~SQL) - CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}() - RETURNS TRIGGER AS - $$ - BEGIN - INSERT INTO loose_foreign_keys_deleted_records - (partition, fully_qualified_table_name, primary_key_value) - SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table - ON CONFLICT DO NOTHING; - - RETURN NULL; - END - $$ LANGUAGE PLPGSQL - SQL - end -end diff --git a/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb b/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb deleted file mode 100644 index 1b0d2104c91..00000000000 --- a/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddMaxSshKeyLifetimeToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, :max_ssh_key_lifetime, :integer - end -end diff --git a/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb b/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb deleted file mode 100644 index dd5b0bdc028..00000000000 --- a/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToVulnerabilityReadsOnVulnerability < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :vulnerability_reads, :vulnerabilities, column: :vulnerability_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :vulnerability_reads, column: :vulnerability_id - end - end -end diff --git a/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb b/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb deleted file mode 100644 index 14dde371e3d..00000000000 --- a/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToVulnerabilityReadsOnProject < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :vulnerability_reads, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :vulnerability_reads, column: :project_id - end - end -end diff --git a/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb b/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb deleted file mode 100644 index 923e62a4beb..00000000000 --- a/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToVulnerabilityReadsOnScanner < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :vulnerability_reads, :vulnerability_scanners, column: :scanner_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :vulnerability_reads, column: :scanner_id - end - end -end diff --git a/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb b/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb deleted file mode 100644 index f52bc346d16..00000000000 --- a/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddOrignalFilenameToCiJobArtifact < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20211119085036_add_text_limit_to_job_artifact_original_filename.rb - def up - add_column :ci_job_artifacts, :original_filename, :text - end - # rubocop:enable Migration/AddLimitToTextColumns - - def down - remove_column :ci_job_artifacts, :original_filename, :text - end -end diff --git a/db/migrate/20211119111006_create_job_artifact_states.rb b/db/migrate/20211119111006_create_job_artifact_states.rb deleted file mode 100644 index 44dffed58ee..00000000000 --- a/db/migrate/20211119111006_create_job_artifact_states.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class CreateJobArtifactStates < Gitlab::Database::Migration[1.0] - VERIFICATION_STATE_INDEX_NAME = "index_job_artifact_states_on_verification_state" - PENDING_VERIFICATION_INDEX_NAME = "index_job_artifact_states_pending_verification" - FAILED_VERIFICATION_INDEX_NAME = "index_job_artifact_states_failed_verification" - NEEDS_VERIFICATION_INDEX_NAME = "index_job_artifact_states_needs_verification" - - enable_lock_retries! - - def up - create_table :ci_job_artifact_states, id: false do |t| - t.datetime_with_timezone :verification_started_at - t.datetime_with_timezone :verification_retry_at - t.datetime_with_timezone :verified_at - t.references :job_artifact, primary_key: true, null: false, foreign_key: { on_delete: :cascade, to_table: :ci_job_artifacts } - 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 :ci_job_artifact_states - end -end diff --git a/db/migrate/20211119154221_create_pages_deployment_states.rb b/db/migrate/20211119154221_create_pages_deployment_states.rb deleted file mode 100644 index 283f6c7d0d7..00000000000 --- a/db/migrate/20211119154221_create_pages_deployment_states.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -class CreatePagesDeploymentStates < Gitlab::Database::Migration[1.0] - VERIFICATION_STATE_INDEX_NAME = "index_pages_deployment_states_on_verification_state" - PENDING_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_pending_verification" - FAILED_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_failed_verification" - NEEDS_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_needs_verification" - - disable_ddl_transaction! - - def up - unless table_exists?(:pages_deployment_states) - with_lock_retries do - create_table :pages_deployment_states, id: false do |t| - t.references :pages_deployment, primary_key: true, null: false, foreign_key: { on_delete: :cascade } - t.integer :verification_state, default: 0, limit: 2, null: false - t.column :verification_started_at, :datetime_with_timezone - t.datetime_with_timezone :verification_retry_at - t.datetime_with_timezone :verified_at - t.integer :verification_retry_count, limit: 2 - t.binary :verification_checksum, using: 'verification_checksum::bytea' - t.text :verification_failure - - 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 - end - - add_text_limit :pages_deployment_states, :verification_failure, 255 - end - - def down - drop_table :pages_deployment_states - end -end diff --git a/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb b/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb deleted file mode 100644 index 9064242ee30..00000000000 --- a/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveTestReportRequirementIssueConstraint < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - TARGET_TABLE = :requirements_management_test_reports - CONSTRAINT_NAME = 'requirements_test_reports_requirement_id_xor_issue_id' - - def up - remove_check_constraint TARGET_TABLE, CONSTRAINT_NAME - end - - def down - add_check_constraint(TARGET_TABLE, 'num_nonnulls(requirement_id, issue_id) = 1', CONSTRAINT_NAME) - end -end diff --git a/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb b/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb deleted file mode 100644 index ca6b78efbc7..00000000000 --- a/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddRequiredApprovalCountToProtectedEnvironments < Gitlab::Database::Migration[1.0] - def change - add_column :protected_environments, :required_approval_count, :integer, default: 0, null: false - end -end diff --git a/db/migrate/20211119195201_create_deployment_approvals.rb b/db/migrate/20211119195201_create_deployment_approvals.rb deleted file mode 100644 index a238da302f9..00000000000 --- a/db/migrate/20211119195201_create_deployment_approvals.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CreateDeploymentApprovals < Gitlab::Database::Migration[1.0] - def change - create_table :deployment_approvals do |t| - t.bigint :deployment_id, null: false - t.bigint :user_id, null: false, index: true - t.timestamps_with_timezone null: false - t.integer :status, limit: 2, null: false - t.index [:deployment_id, :user_id], unique: true - end - end -end diff --git a/db/migrate/20211122103051_add_line_code_to_draft_notes.rb b/db/migrate/20211122103051_add_line_code_to_draft_notes.rb deleted file mode 100644 index c78b75f3a33..00000000000 --- a/db/migrate/20211122103051_add_line_code_to_draft_notes.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddLineCodeToDraftNotes < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb - def change - add_column :draft_notes, :line_code, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb b/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb deleted file mode 100644 index b1c7bc4d5ce..00000000000 --- a/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddPolicyIdxToApprovalMergeRequestRule < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :approval_merge_request_rules, :orchestration_policy_idx, :integer, limit: 2 - end -end diff --git a/db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb b/db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb deleted file mode 100644 index 280626c5d3b..00000000000 --- a/db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -class CreateBatchedBackgroundMigrationJobTransitionLogs < Gitlab::Database::Migration[1.0] - include Gitlab::Database::PartitioningMigrationHelpers - - def up - execute(<<~SQL) - CREATE TABLE batched_background_migration_job_transition_logs ( - id bigserial NOT NULL, - batched_background_migration_job_id bigint NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - previous_status smallint NOT NULL, - next_status smallint NOT NULL, - exception_class text, - exception_message text, - CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), - CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)), - PRIMARY KEY (id, created_at) - ) PARTITION BY RANGE (created_at); - - CREATE INDEX i_batched_background_migration_job_transition_logs_on_job_id - ON batched_background_migration_job_transition_logs USING btree (batched_background_migration_job_id); - - ALTER TABLE batched_background_migration_job_transition_logs ADD CONSTRAINT fk_rails_b7523a175b - FOREIGN KEY (batched_background_migration_job_id) REFERENCES batched_background_migration_jobs(id) ON DELETE CASCADE; - SQL - - min_date = Date.today - max_date = Date.today + 6.months - - create_daterange_partitions('batched_background_migration_job_transition_logs', 'created_at', min_date, max_date) - end - - def down - drop_table :batched_background_migration_job_transition_logs - end -end diff --git a/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb b/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb deleted file mode 100644 index da20e9a8f8e..00000000000 --- a/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUserForeignKeyToDeploymentApprovals < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :deployment_approvals, :users, column: :user_id - end - - def down - with_lock_retries do - remove_foreign_key :deployment_approvals, :users - end - end -end diff --git a/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb b/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb deleted file mode 100644 index 10a0c6ca402..00000000000 --- a/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class MakeIterationCadencesStartDateNullable < Gitlab::Database::Migration[1.0] - def change - change_column_null :iterations_cadences, :start_date, true - end -end diff --git a/db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb b/db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb deleted file mode 100644 index b3567d6b873..00000000000 --- a/db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddDraftNotesLineCodeTextLimit < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :draft_notes, :line_code, 255 - end - - def down - remove_text_limit :draft_notes, :line_code - end -end diff --git a/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb b/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb deleted file mode 100644 index 868bc4f14f2..00000000000 --- a/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddEncryptedStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0] - def up - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20211126113029_add_text_limit_for_static_objects_external_storage_auth_token - add_column :application_settings, :static_objects_external_storage_auth_token_encrypted, :text - # rubocop:enable Migration/AddLimitToTextColumns - end - - def down - remove_column :application_settings, :static_objects_external_storage_auth_token_encrypted - end -end diff --git a/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb b/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb deleted file mode 100644 index cbe5dbf99fc..00000000000 --- a/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddSequenceColumnToSprintsTable < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :sprints, :sequence, :integer - execute "ALTER TABLE sprints ADD CONSTRAINT sequence_is_unique_per_iterations_cadence_id UNIQUE (iterations_cadence_id, sequence) DEFERRABLE INITIALLY DEFERRED" - end - - def down - remove_column :sprints, :sequence - end -end diff --git a/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb b/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb deleted file mode 100644 index 45c4686e674..00000000000 --- a/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true -class AddTextLimitForStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :application_settings, :static_objects_external_storage_auth_token_encrypted, 255 - end - - def down - remove_text_limit :application_settings, :static_objects_external_storage_auth_token_encrypted - end -end diff --git a/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb b/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb deleted file mode 100644 index 92ba54d4c89..00000000000 --- a/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class EncryptStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0] - class ApplicationSetting < ActiveRecord::Base - self.table_name = 'application_settings' - - scope :encrypted_token_is_null, -> { where(static_objects_external_storage_auth_token_encrypted: nil) } - scope :encrypted_token_is_not_null, -> { where.not(static_objects_external_storage_auth_token_encrypted: nil) } - scope :plaintext_token_is_not_null, -> { where.not(static_objects_external_storage_auth_token: nil) } - end - - def up - ApplicationSetting.reset_column_information - - ApplicationSetting.encrypted_token_is_null.plaintext_token_is_not_null.find_each do |application_setting| - next if application_setting.static_objects_external_storage_auth_token.empty? - - token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(application_setting.static_objects_external_storage_auth_token) - application_setting.update!(static_objects_external_storage_auth_token_encrypted: token_encrypted) - end - end - - def down - ApplicationSetting.reset_column_information - - ApplicationSetting.encrypted_token_is_not_null.find_each do |application_setting| - token = Gitlab::CryptoHelper.aes256_gcm_decrypt(application_setting.static_objects_external_storage_auth_token_encrypted) - application_setting.update!(static_objects_external_storage_auth_token: token, static_objects_external_storage_auth_token_encrypted: nil) - end - end -end diff --git a/db/migrate/20211126142200_add_encrypted_static_object_token.rb b/db/migrate/20211126142200_add_encrypted_static_object_token.rb deleted file mode 100644 index 839354244e7..00000000000 --- a/db/migrate/20211126142200_add_encrypted_static_object_token.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddEncryptedStaticObjectToken < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20211126142354_add_text_limit_to_encrypted_static_object_token - add_column :users, :static_object_token_encrypted, :text # rubocop:disable Migration/AddColumnsToWideTables - # rubocop:enable Migration/AddLimitToTextColumns - end - - def down - remove_column :users, :static_object_token_encrypted - end -end diff --git a/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb b/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb deleted file mode 100644 index a43e7d9a741..00000000000 --- a/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToEncryptedStaticObjectToken < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :users, :static_object_token_encrypted, 255 - end - - def down - remove_text_limit :users, :static_object_token_encrypted - end -end diff --git a/db/migrate/20211126204445_add_task_to_work_item_types.rb b/db/migrate/20211126204445_add_task_to_work_item_types.rb deleted file mode 100644 index 875c2272c6d..00000000000 --- a/db/migrate/20211126204445_add_task_to_work_item_types.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class AddTaskToWorkItemTypes < Gitlab::Database::Migration[1.0] - TASK_ENUM_VALUE = 4 - - class WorkItemType < ActiveRecord::Base - self.inheritance_column = :_type_disabled - self.table_name = 'work_item_types' - - validates :name, uniqueness: { case_sensitive: false, scope: [:namespace_id] } - end - - def up - # New instances will not run this migration and add this type via fixtures - # checking if record exists mostly because migration specs will run all migrations - # and that will conflict with the preloaded base work item types - task_work_item = WorkItemType.find_by(name: 'Task', namespace_id: nil) - - if task_work_item - say('Task item record exist, skipping creation') - else - WorkItemType.create(name: 'Task', namespace_id: nil, base_type: TASK_ENUM_VALUE, icon_name: 'issue-type-task') - end - end - - def down - # There's the remote possibility that issues could already be - # using this issue type, with a tight foreign constraint. - # Therefore we will not attempt to remove any data. - end -end diff --git a/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb b/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb deleted file mode 100644 index 8c3cf82d7c7..00000000000 --- a/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddMigratedToNewStructureColumnToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0] - def change - add_column :vulnerability_occurrences, :migrated_to_new_structure, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb b/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb deleted file mode 100644 index 4cf8263f8f0..00000000000 --- a/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnVulnerabilityOccurrencesMigratedToNewStructureColumn < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_vulnerability_occurrences_on_migrated_to_new_structure' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_occurrences, [:migrated_to_new_structure, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME - end -end diff --git a/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb b/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb deleted file mode 100644 index a09409900f7..00000000000 --- a/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToIncidentManagementTimelineEventsOnNote < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :incident_management_timeline_events, :notes, column: :promoted_from_note_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :incident_management_timeline_events, column: :promoted_from_note_id - end - end -end diff --git a/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb b/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb deleted file mode 100644 index 1aca3e7e8e2..00000000000 --- a/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddUniquenessForEvidenceOccurrenceId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'finding_evidences_on_vulnerability_occurrence_id' - UNIQUE_INDEX_NAME = 'finding_evidences_on_unique_vulnerability_occurrence_id' - - def up - add_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], unique: true, name: UNIQUE_INDEX_NAME - remove_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: INDEX_NAME - end - - def down - add_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: INDEX_NAME - remove_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: UNIQUE_INDEX_NAME - end -end diff --git a/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb b/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb deleted file mode 100644 index 9cbbef42327..00000000000 --- a/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddFutureSubscriptionsToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, :future_subscriptions, :jsonb, null: false, default: [] - end -end diff --git a/db/migrate/20211201143042_create_lfs_object_states.rb b/db/migrate/20211201143042_create_lfs_object_states.rb deleted file mode 100644 index 91accbcd438..00000000000 --- a/db/migrate/20211201143042_create_lfs_object_states.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class CreateLfsObjectStates < Gitlab::Database::Migration[1.0] - VERIFICATION_STATE_INDEX_NAME = "index_lfs_object_states_on_verification_state" - PENDING_VERIFICATION_INDEX_NAME = "index_lfs_object_states_pending_verification" - FAILED_VERIFICATION_INDEX_NAME = "index_lfs_object_states_failed_verification" - NEEDS_VERIFICATION_INDEX_NAME = "index_lfs_object_states_needs_verification" - - disable_ddl_transaction! - - def up - create_table :lfs_object_states, id: false do |t| - t.datetime_with_timezone :verification_started_at - t.datetime_with_timezone :verification_retry_at - t.datetime_with_timezone :verified_at - t.references :lfs_object, primary_key: true, null: false, foreign_key: { on_delete: :cascade } - t.integer :verification_state, default: 0, limit: 2, null: false - t.integer :verification_retry_count, limit: 2 - t.binary :verification_checksum, using: 'verification_checksum::bytea' - t.text :verification_failure, limit: 255 - - t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME - t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME - t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME - t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME - end - end - - def down - drop_table :lfs_object_states - end -end diff --git a/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb b/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb deleted file mode 100644 index 60bc892d792..00000000000 --- a/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddDeploymentForeignKeyToDeploymentApprovals < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :deployment_approvals, :deployments, column: :deployment_id - end - - def down - with_lock_retries do - remove_foreign_key :deployment_approvals, :deployments - end - end -end diff --git a/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb b/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb deleted file mode 100644 index 84bc551d2b5..00000000000 --- a/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class MoveLooseFkDeletedRecordsToDynamicSchema < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - if table_exists?('gitlab_partitions_static.loose_foreign_keys_deleted_records_1') - execute 'ALTER TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 SET SCHEMA gitlab_partitions_dynamic' - end - end - - def down - if table_exists?('gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1') - execute 'ALTER TABLE gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 SET SCHEMA gitlab_partitions_static' - end - end -end diff --git a/db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb b/db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb deleted file mode 100644 index 47a155d40fa..00000000000 --- a/db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnPackagesBuildInfosPackageIdPipelineId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_build_infos_package_id_pipeline_id' - OLD_INDEX_NAME = 'idx_packages_build_infos_on_package_id' - - def up - add_concurrent_index :packages_build_infos, [:package_id, :pipeline_id], name: INDEX_NAME - remove_concurrent_index_by_name :packages_build_infos, OLD_INDEX_NAME - end - - def down - add_concurrent_index :packages_build_infos, :package_id, name: OLD_INDEX_NAME - remove_concurrent_index :packages_build_infos, [:package_id, :pipeline_id], name: INDEX_NAME - end -end diff --git a/db/migrate/20211203160952_add_updated_state_by_user_id_to_merge_request_reviewers.rb b/db/migrate/20211203160952_add_updated_state_by_user_id_to_merge_request_reviewers.rb deleted file mode 100644 index dafd2108b43..00000000000 --- a/db/migrate/20211203160952_add_updated_state_by_user_id_to_merge_request_reviewers.rb +++ /dev/null @@ -1,12 +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 AddUpdatedStateByUserIdToMergeRequestReviewers < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :merge_request_reviewers, :updated_state_by_user_id, :bigint - end -end diff --git a/db/migrate/20211203161149_add_index_to_merge_request_reviewers_updated_state_by_user_id.rb b/db/migrate/20211203161149_add_index_to_merge_request_reviewers_updated_state_by_user_id.rb deleted file mode 100644 index 6f4ee079015..00000000000 --- a/db/migrate/20211203161149_add_index_to_merge_request_reviewers_updated_state_by_user_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToMergeRequestReviewersUpdatedStateByUserId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_on_merge_request_reviewers_updated_state_by_user_id' - - def up - add_concurrent_index :merge_request_reviewers, :updated_state_by_user_id, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :merge_request_reviewers, INDEX_NAME - end -end diff --git a/db/migrate/20211203161840_add_updated_state_by_user_id_to_merge_request_assignees.rb b/db/migrate/20211203161840_add_updated_state_by_user_id_to_merge_request_assignees.rb deleted file mode 100644 index 1c9e7193630..00000000000 --- a/db/migrate/20211203161840_add_updated_state_by_user_id_to_merge_request_assignees.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddUpdatedStateByUserIdToMergeRequestAssignees < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :merge_request_assignees, :updated_state_by_user_id, :bigint - end -end diff --git a/db/migrate/20211203161942_add_index_to_merge_request_assignees_updated_state_by_user_id.rb b/db/migrate/20211203161942_add_index_to_merge_request_assignees_updated_state_by_user_id.rb deleted file mode 100644 index d052ffdf4d6..00000000000 --- a/db/migrate/20211203161942_add_index_to_merge_request_assignees_updated_state_by_user_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToMergeRequestAssigneesUpdatedStateByUserId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_on_merge_request_assignees_updated_state_by_user_id' - - def up - add_concurrent_index :merge_request_assignees, :updated_state_by_user_id, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :merge_request_assignees, INDEX_NAME - end -end diff --git a/db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb b/db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb deleted file mode 100644 index 35a3a98030a..00000000000 --- a/db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexSnippetsOnProjectIdAndTitle < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_snippets_on_project_id_and_title' - - def up - add_concurrent_index :snippets, [:project_id, :title], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :snippets, name: INDEX_NAME - end -end diff --git a/db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb b/db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb deleted file mode 100644 index da391da33ec..00000000000 --- a/db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddCiRunnersIndexOnCreatedAtWhereActiveIsFalse < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_ci_runners_on_created_at_and_id_where_inactive' - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_runners, [:created_at, :id], where: 'active = FALSE', order: { created_at: :desc, id: :desc }, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :ci_runners, INDEX_NAME - end -end diff --git a/db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb b/db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb deleted file mode 100644 index e25d3c0dffa..00000000000 --- a/db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddCiRunnersIndexOnContactedAtWhereActiveIsFalse < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_ci_runners_on_contacted_at_and_id_where_inactive' - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_runners, [:contacted_at, :id], where: 'active = FALSE', order: { contacted_at: :desc, id: :desc }, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :ci_runners, INDEX_NAME - end -end diff --git a/db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb b/db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb deleted file mode 100644 index fb1339cecfa..00000000000 --- a/db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddProtectedEnvironmentsRequiredApprovalCountCheckConstraint < Gitlab::Database::Migration[1.0] - CONSTRAINT_NAME = 'protected_environments_required_approval_count_positive' - - disable_ddl_transaction! - - def up - add_check_constraint :protected_environments, 'required_approval_count >= 0', CONSTRAINT_NAME - end - - def down - remove_check_constraint :protected_environments, CONSTRAINT_NAME - end -end diff --git a/db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb b/db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb deleted file mode 100644 index 1e1fdbdb122..00000000000 --- a/db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddExecutorTypeColumnToCiRunners < Gitlab::Database::Migration[1.0] - def change - add_column :ci_runners, :executor_type, :smallint, null: true - end -end diff --git a/db/migrate/20211209230042_add_status_to_cluster_agent_tokens.rb b/db/migrate/20211209230042_add_status_to_cluster_agent_tokens.rb deleted file mode 100644 index 596c82eb209..00000000000 --- a/db/migrate/20211209230042_add_status_to_cluster_agent_tokens.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToClusterAgentTokens < Gitlab::Database::Migration[1.0] - def change - add_column :cluster_agent_tokens, :status, :smallint, null: false, default: 0 - end -end diff --git a/db/migrate/20211210025754_alter_constraint_of_phone.rb b/db/migrate/20211210025754_alter_constraint_of_phone.rb deleted file mode 100644 index 1644fbe9000..00000000000 --- a/db/migrate/20211210025754_alter_constraint_of_phone.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AlterConstraintOfPhone < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - constraint_phone = check_constraint_name('verification_codes', 'phone', 'max_length') - remove_check_constraint(:verification_codes, constraint_phone) - add_check_constraint(:verification_codes, 'char_length(phone) <= 50', constraint_phone) - end - - def down - constraint_phone = check_constraint_name('verification_codes', 'phone', 'max_length') - remove_check_constraint(:verification_codes, constraint_phone) - add_check_constraint(:verification_codes, 'char_length(phone) <= 32', constraint_phone) - end -end diff --git a/db/migrate/20211210031721_change_user_details_phone_text_limit.rb b/db/migrate/20211210031721_change_user_details_phone_text_limit.rb deleted file mode 100644 index 5432f6d3d24..00000000000 --- a/db/migrate/20211210031721_change_user_details_phone_text_limit.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ChangeUserDetailsPhoneTextLimit < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - remove_text_limit :user_details, :phone - add_text_limit :user_details, :phone, 50 - end - - def down - remove_text_limit :user_details, :phone - add_text_limit :user_details, :phone, 32 - end -end diff --git a/db/migrate/20211213130324_update_timelogs_spent_at_default.rb b/db/migrate/20211213130324_update_timelogs_spent_at_default.rb deleted file mode 100644 index f90b19b5f68..00000000000 --- a/db/migrate/20211213130324_update_timelogs_spent_at_default.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class UpdateTimelogsSpentAtDefault < Gitlab::Database::Migration[1.0] - def change - change_column_default(:timelogs, :spent_at, from: nil, to: -> { 'NOW()' }) - end -end diff --git a/db/migrate/20211213142344_add_settings_user_email_lookup_limit.rb b/db/migrate/20211213142344_add_settings_user_email_lookup_limit.rb deleted file mode 100644 index ac7027bf082..00000000000 --- a/db/migrate/20211213142344_add_settings_user_email_lookup_limit.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddSettingsUserEmailLookupLimit < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_column :application_settings, :user_email_lookup_limit, :integer, null: false, default: 60 - end - - def down - remove_column :application_settings, :user_email_lookup_limit - end -end diff --git a/db/migrate/20211213154259_add_status_to_packages_package_files.rb b/db/migrate/20211213154259_add_status_to_packages_package_files.rb deleted file mode 100644 index 38ea069a30b..00000000000 --- a/db/migrate/20211213154259_add_status_to_packages_package_files.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToPackagesPackageFiles < Gitlab::Database::Migration[1.0] - def change - add_column :packages_package_files, :status, :smallint, default: 0, null: false - end -end diff --git a/db/migrate/20211213154704_add_status_index_to_packages_package_files.rb b/db/migrate/20211213154704_add_status_index_to_packages_package_files.rb deleted file mode 100644 index 7067e3efa6c..00000000000 --- a/db/migrate/20211213154704_add_status_index_to_packages_package_files.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddStatusIndexToPackagesPackageFiles < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_package_files_on_package_id_status_and_id' - - def up - add_concurrent_index :packages_package_files, [:package_id, :status, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_package_files, name: INDEX_NAME - end -end diff --git a/db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb b/db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb deleted file mode 100644 index 99f985d528c..00000000000 --- a/db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveTempIndexFromVulnerabilityOccurrences < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'vulnerability_occurrences_location_temp_index' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :vulnerability_occurrences, name: INDEX_NAME - end - - def down - add_concurrent_index :vulnerability_occurrences, :id, where: 'location IS NULL', name: INDEX_NAME - end -end diff --git a/db/migrate/20211215182006_update_application_settings_protected_paths.rb b/db/migrate/20211215182006_update_application_settings_protected_paths.rb deleted file mode 100644 index f1c1dde55e0..00000000000 --- a/db/migrate/20211215182006_update_application_settings_protected_paths.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -class UpdateApplicationSettingsProtectedPaths < Gitlab::Database::Migration[1.0] - REMOVE_PROTECTED_PATHS = [ - '/oauth/authorize', - '/oauth/token' - ].freeze - - NEW_DEFAULT_PROTECTED_PATHS = [ - '/users/password', - '/users/sign_in', - '/api/v3/session.json', - '/api/v3/session', - '/api/v4/session.json', - '/api/v4/session', - '/users', - '/users/confirmation', - '/unsubscribes/', - '/import/github/personal_access_token', - '/admin/session' - ].freeze - - OLD_DEFAULT_PROTECTED_PATHS = (NEW_DEFAULT_PROTECTED_PATHS + REMOVE_PROTECTED_PATHS).freeze - - class ApplicationSetting < ActiveRecord::Base - self.table_name = 'application_settings' - end - - def up - change_column_default(:application_settings, :protected_paths, NEW_DEFAULT_PROTECTED_PATHS) - - ApplicationSetting.reset_column_information - - ApplicationSetting.where.not(protected_paths: nil).each do |application_setting| - paths_to_remove = application_setting.protected_paths & REMOVE_PROTECTED_PATHS - - next if paths_to_remove.empty? - - updated_protected_paths = application_setting.protected_paths - paths_to_remove - application_setting.update!(protected_paths: updated_protected_paths) - end - end - - def down - change_column_default(:application_settings, :protected_paths, OLD_DEFAULT_PROTECTED_PATHS) - - ApplicationSetting.reset_column_information - - ApplicationSetting.where.not(protected_paths: nil).each do |application_setting| - paths_to_add = REMOVE_PROTECTED_PATHS - application_setting.protected_paths - - next if paths_to_add.empty? - - updated_protected_paths = application_setting.protected_paths + paths_to_add - application_setting.update!(protected_paths: updated_protected_paths) - end - end -end diff --git a/db/migrate/20211216133107_add_cluster_agent_id_to_vulnerability_reads.rb b/db/migrate/20211216133107_add_cluster_agent_id_to_vulnerability_reads.rb deleted file mode 100644 index 0bbd5c25df4..00000000000 --- a/db/migrate/20211216133107_add_cluster_agent_id_to_vulnerability_reads.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddClusterAgentIdToVulnerabilityReads < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20211216134134_add_text_limit_to_vulnerability_reads_cluster_agent_id.rb - def change - add_column :vulnerability_reads, :cluster_agent_id, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20211216134134_add_text_limit_to_vulnerability_reads_cluster_agent_id.rb b/db/migrate/20211216134134_add_text_limit_to_vulnerability_reads_cluster_agent_id.rb deleted file mode 100644 index f4776ff10a4..00000000000 --- a/db/migrate/20211216134134_add_text_limit_to_vulnerability_reads_cluster_agent_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToVulnerabilityReadsClusterAgentId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :vulnerability_reads, :cluster_agent_id, 10 - end - - def down - remove_text_limit :vulnerability_reads, :cluster_agent_id - end -end diff --git a/db/migrate/20211216135651_add_index_to_cluster_agent_id.rb b/db/migrate/20211216135651_add_index_to_cluster_agent_id.rb deleted file mode 100644 index 05928083823..00000000000 --- a/db/migrate/20211216135651_add_index_to_cluster_agent_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToClusterAgentId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = "index_vulnerability_reads_on_cluster_agent_id" - CLUSTER_IMAGE_SCANNING_REPORT_TYPE = 7 - - def up - add_concurrent_index :vulnerability_reads, :cluster_agent_id, where: "report_type = #{CLUSTER_IMAGE_SCANNING_REPORT_TYPE}", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/migrate/20211216220939_add_group_crm_settings.rb b/db/migrate/20211216220939_add_group_crm_settings.rb deleted file mode 100644 index e931aa3709b..00000000000 --- a/db/migrate/20211216220939_add_group_crm_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddGroupCrmSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - create_table :group_crm_settings, id: false do |t| - t.references :group, primary_key: true, foreign_key: { to_table: :namespaces, on_delete: :cascade } - t.timestamps_with_timezone - t.boolean :enabled, null: false, default: false - end - end -end diff --git a/db/migrate/20211217050753_remove_artifacts_archive_id_foreign_key_from_project_pages_metadata.rb b/db/migrate/20211217050753_remove_artifacts_archive_id_foreign_key_from_project_pages_metadata.rb deleted file mode 100644 index fa81fa512ae..00000000000 --- a/db/migrate/20211217050753_remove_artifacts_archive_id_foreign_key_from_project_pages_metadata.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class RemoveArtifactsArchiveIdForeignKeyFromProjectPagesMetadata < Gitlab::Database::Migration[1.0] - CONSTRAINT_NAME = 'fk_69366a119e' - - disable_ddl_transaction! - - def up - with_lock_retries do - execute('lock table ci_job_artifacts, project_pages_metadata in access exclusive mode') - - remove_foreign_key :project_pages_metadata, to_table: :ci_job_artifacts, column: :artifacts_archive_id, on_delete: :nullify, name: CONSTRAINT_NAME - end - end - - def down - add_concurrent_foreign_key :project_pages_metadata, :ci_job_artifacts, column: :artifacts_archive_id, on_delete: :nullify, name: CONSTRAINT_NAME - end -end diff --git a/db/migrate/20211220174504_add_secure_scanning_actions_to_onboarding_progresses.rb b/db/migrate/20211220174504_add_secure_scanning_actions_to_onboarding_progresses.rb deleted file mode 100644 index cf9f2511176..00000000000 --- a/db/migrate/20211220174504_add_secure_scanning_actions_to_onboarding_progresses.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddSecureScanningActionsToOnboardingProgresses < Gitlab::Database::Migration[1.0] - def change - change_table(:onboarding_progresses, bulk: true) do |t| - t.column :secure_dependency_scanning_run_at, :datetime_with_timezone - t.column :secure_container_scanning_run_at, :datetime_with_timezone - t.column :secure_dast_run_at, :datetime_with_timezone - t.column :secure_secret_detection_run_at, :datetime_with_timezone - t.column :secure_coverage_fuzzing_run_at, :datetime_with_timezone - t.column :secure_cluster_image_scanning_run_at, :datetime_with_timezone - t.column :secure_api_fuzzing_run_at, :datetime_with_timezone - end - end -end diff --git a/db/migrate/20211223125921_add_temp_index_to_members_state.rb b/db/migrate/20211223125921_add_temp_index_to_members_state.rb deleted file mode 100644 index 7dd2ec1a8aa..00000000000 --- a/db/migrate/20211223125921_add_temp_index_to_members_state.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddTempIndexToMembersState < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_members_on_state' - - def up - # Temporary index to be removed in 14.9 https://gitlab.com/gitlab-org/gitlab/-/issues/349960 - add_concurrent_index :members, :state, name: INDEX_NAME, where: 'state = 2' - end - - def down - remove_concurrent_index_by_name :members, INDEX_NAME - end -end diff --git a/db/migrate/20211224112937_add_packages_cleanup_package_file_worker_capacity_to_application_settings.rb b/db/migrate/20211224112937_add_packages_cleanup_package_file_worker_capacity_to_application_settings.rb deleted file mode 100644 index cb58033361f..00000000000 --- a/db/migrate/20211224112937_add_packages_cleanup_package_file_worker_capacity_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddPackagesCleanupPackageFileWorkerCapacityToApplicationSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :application_settings, - :packages_cleanup_package_file_worker_capacity, - :smallint, - default: 2, - null: false - end -end diff --git a/db/migrate/20211224114539_add_packages_cleanup_package_file_worker_capacity_check_constraint_to_app_settings.rb b/db/migrate/20211224114539_add_packages_cleanup_package_file_worker_capacity_check_constraint_to_app_settings.rb deleted file mode 100644 index 3a40540a1e1..00000000000 --- a/db/migrate/20211224114539_add_packages_cleanup_package_file_worker_capacity_check_constraint_to_app_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddPackagesCleanupPackageFileWorkerCapacityCheckConstraintToAppSettings < Gitlab::Database::Migration[1.0] - CONSTRAINT_NAME = 'app_settings_p_cleanup_package_file_worker_capacity_positive' - - disable_ddl_transaction! - - def up - add_check_constraint :application_settings, 'packages_cleanup_package_file_worker_capacity >= 0', CONSTRAINT_NAME - end - - def down - remove_check_constraint :application_settings, CONSTRAINT_NAME - end -end diff --git a/db/migrate/20220104174445_add_ci_runners_index_on_active_state.rb b/db/migrate/20220104174445_add_ci_runners_index_on_active_state.rb deleted file mode 100644 index 2cef570966b..00000000000 --- a/db/migrate/20220104174445_add_ci_runners_index_on_active_state.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddCiRunnersIndexOnActiveState < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_runners_on_active' - - def up - add_concurrent_index :ci_runners, [:active, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :ci_runners, INDEX_NAME - end -end diff --git a/db/migrate/20220105082217_add_verification_token_to_external_ae_destinations.rb b/db/migrate/20220105082217_add_verification_token_to_external_ae_destinations.rb deleted file mode 100644 index 046a628b8ae..00000000000 --- a/db/migrate/20220105082217_add_verification_token_to_external_ae_destinations.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddVerificationTokenToExternalAeDestinations < Gitlab::Database::Migration[1.0] - def up - # rubocop:disable Migration/AddLimitToTextColumns - add_column :audit_events_external_audit_event_destinations, :verification_token, :text - # rubocop:enable Migration/AddLimitToTextColumns - end - - def down - remove_column :audit_events_external_audit_event_destinations, :verification_token - end -end diff --git a/db/migrate/20220105121325_add_route_namespace_reference.rb b/db/migrate/20220105121325_add_route_namespace_reference.rb deleted file mode 100644 index 77bd0530b8a..00000000000 --- a/db/migrate/20220105121325_add_route_namespace_reference.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddRouteNamespaceReference < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :routes, :namespace_id, :bigint unless column_exists?(:routes, :namespace_id) - end - - def down - remove_column :routes, :namespace_id if column_exists?(:routes, :namespace_id) - end -end diff --git a/db/migrate/20220105152547_add_foreign_key_to_updated_state_by_user_id_to_merge_request_assignees.rb b/db/migrate/20220105152547_add_foreign_key_to_updated_state_by_user_id_to_merge_request_assignees.rb deleted file mode 100644 index 58411c1dc0f..00000000000 --- a/db/migrate/20220105152547_add_foreign_key_to_updated_state_by_user_id_to_merge_request_assignees.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToUpdatedStateByUserIdToMergeRequestAssignees < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :merge_request_assignees, :users, column: :updated_state_by_user_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :merge_request_assignees, column: :updated_state_by_user_id - end - end -end diff --git a/db/migrate/20220105153149_add_foreign_key_to_updated_state_by_user_id_to_merge_request_reviewers.rb b/db/migrate/20220105153149_add_foreign_key_to_updated_state_by_user_id_to_merge_request_reviewers.rb deleted file mode 100644 index 13e375a5b97..00000000000 --- a/db/migrate/20220105153149_add_foreign_key_to_updated_state_by_user_id_to_merge_request_reviewers.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToUpdatedStateByUserIdToMergeRequestReviewers < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :merge_request_reviewers, :users, column: :updated_state_by_user_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :merge_request_reviewers, column: :updated_state_by_user_id - end - end -end diff --git a/db/migrate/20220106111958_add_insert_or_update_vulnerability_reads_trigger.rb b/db/migrate/20220106111958_add_insert_or_update_vulnerability_reads_trigger.rb deleted file mode 100644 index 0049f4e00a2..00000000000 --- a/db/migrate/20220106111958_add_insert_or_update_vulnerability_reads_trigger.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -class AddInsertOrUpdateVulnerabilityReadsTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - FUNCTION_NAME = 'insert_or_update_vulnerability_reads' - TRIGGER_NAME = 'trigger_insert_or_update_vulnerability_reads_from_occurrences' - - def up - execute(<<~SQL) - CREATE OR REPLACE FUNCTION #{FUNCTION_NAME}() - RETURNS TRIGGER - LANGUAGE plpgsql - AS $$ - DECLARE - severity smallint; - state smallint; - report_type smallint; - resolved_on_default_branch boolean; - BEGIN - IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN - RETURN NULL; - END IF; - - IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN - RETURN NULL; - END IF; - - SELECT - vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch - INTO - severity, state, report_type, resolved_on_default_branch - FROM - vulnerabilities - WHERE - vulnerabilities.id = NEW.vulnerability_id; - - INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id) - VALUES (NEW.vulnerability_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id') - ON CONFLICT(vulnerability_id) DO NOTHING; - RETURN NULL; - END - $$; - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_NAME} - AFTER INSERT OR UPDATE ON vulnerability_occurrences - FOR EACH ROW - EXECUTE PROCEDURE #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:vulnerability_occurrences, TRIGGER_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20220106112043_add_update_vulnerability_reads_trigger.rb b/db/migrate/20220106112043_add_update_vulnerability_reads_trigger.rb deleted file mode 100644 index 940ec638924..00000000000 --- a/db/migrate/20220106112043_add_update_vulnerability_reads_trigger.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class AddUpdateVulnerabilityReadsTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - TRIGGER_NAME = 'trigger_update_vulnerability_reads_on_vulnerability_update' - FUNCTION_NAME = 'update_vulnerability_reads_from_vulnerability' - - def up - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE - vulnerability_reads - SET - severity = NEW.severity, - state = NEW.state, - resolved_on_default_branch = NEW.resolved_on_default_branch - WHERE vulnerability_id = NEW.id; - RETURN NULL; - SQL - end - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_NAME} - AFTER UPDATE ON vulnerabilities - FOR EACH ROW - WHEN ( - OLD.severity IS DISTINCT FROM NEW.severity OR - OLD.state IS DISTINCT FROM NEW.state OR - OLD.resolved_on_default_branch IS DISTINCT FROM NEW.resolved_on_default_branch - ) - EXECUTE PROCEDURE #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:vulnerabilities, TRIGGER_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20220106112085_add_update_vulnerability_reads_location_trigger.rb b/db/migrate/20220106112085_add_update_vulnerability_reads_location_trigger.rb deleted file mode 100644 index a863fe8b7b8..00000000000 --- a/db/migrate/20220106112085_add_update_vulnerability_reads_location_trigger.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -class AddUpdateVulnerabilityReadsLocationTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - TRIGGER_NAME = 'trigger_update_location_on_vulnerability_occurrences_update' - FUNCTION_NAME = 'update_location_from_vulnerability_occurrences' - - def up - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE - vulnerability_reads - SET - location_image = NEW.location->>'image', - cluster_agent_id = NEW.location->'kubernetes_resource'->>'agent_id' - WHERE - vulnerability_id = NEW.vulnerability_id; - RETURN NULL; - SQL - end - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_NAME} - AFTER UPDATE ON vulnerability_occurrences - FOR EACH ROW - WHEN ( - NEW.report_type IN (2, 7) AND ( - OLD.location->>'image' IS DISTINCT FROM NEW.location->>'image' OR - OLD.location->'kubernetes_resource'->>'agent_id' IS DISTINCT FROM NEW.location->'kubernetes_resource'->>'agent_id' - ) - ) - EXECUTE PROCEDURE #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:vulnerability_occurrences, TRIGGER_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20220106141756_remove_lock_version_indexes.rb b/db/migrate/20220106141756_remove_lock_version_indexes.rb deleted file mode 100644 index 382f20dfc73..00000000000 --- a/db/migrate/20220106141756_remove_lock_version_indexes.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class RemoveLockVersionIndexes < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEXES = { - issues: 'index_issues_on_lock_version', - merge_requests: 'index_merge_requests_on_lock_version', - epics: 'index_epics_on_lock_version' - } - - def up - INDEXES.each do |table, index_name| - remove_concurrent_index_by_name table, index_name - end - end - - def down - INDEXES.each do |table, index_name| - add_concurrent_index table, :lock_version, where: "lock_version IS NULL", name: index_name - end - end -end diff --git a/db/migrate/20220106163326_add_has_issues_on_vulnerability_reads_trigger.rb b/db/migrate/20220106163326_add_has_issues_on_vulnerability_reads_trigger.rb deleted file mode 100644 index b3023a1f915..00000000000 --- a/db/migrate/20220106163326_add_has_issues_on_vulnerability_reads_trigger.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -class AddHasIssuesOnVulnerabilityReadsTrigger < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - TRIGGER_ON_INSERT = 'trigger_update_has_issues_on_vulnerability_issue_links_update' - INSERT_FUNCTION_NAME = 'set_has_issues_on_vulnerability_reads' - - TRIGGER_ON_DELETE = 'trigger_update_has_issues_on_vulnerability_issue_links_delete' - DELETE_FUNCTION_NAME = 'unset_has_issues_on_vulnerability_reads' - - def up - create_trigger_function(INSERT_FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE - vulnerability_reads - SET - has_issues = true - WHERE - vulnerability_id = NEW.vulnerability_id AND has_issues IS FALSE; - RETURN NULL; - SQL - end - - execute(<<~SQL) - CREATE OR REPLACE FUNCTION #{DELETE_FUNCTION_NAME}() - RETURNS TRIGGER - LANGUAGE plpgsql - AS $$ - DECLARE - has_issue_links integer; - BEGIN - PERFORM 1 - FROM - vulnerability_reads - WHERE - vulnerability_id = OLD.vulnerability_id - FOR UPDATE; - - SELECT 1 INTO has_issue_links FROM vulnerability_issue_links WHERE vulnerability_id = OLD.vulnerability_id LIMIT 1; - - IF (has_issue_links = 1) THEN - RETURN NULL; - END IF; - - UPDATE - vulnerability_reads - SET - has_issues = false - WHERE - vulnerability_id = OLD.vulnerability_id; - - RETURN NULL; - END - $$; - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_INSERT} - AFTER INSERT ON vulnerability_issue_links - FOR EACH ROW - EXECUTE FUNCTION #{INSERT_FUNCTION_NAME}(); - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_DELETE} - AFTER DELETE ON vulnerability_issue_links - FOR EACH ROW - EXECUTE FUNCTION #{DELETE_FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:vulnerability_issue_links, TRIGGER_ON_INSERT) - drop_function(INSERT_FUNCTION_NAME) - drop_trigger(:vulnerability_issue_links, TRIGGER_ON_DELETE) - drop_function(DELETE_FUNCTION_NAME) - end -end diff --git a/db/migrate/20220106230629_add_registry_migration_application_settings.rb b/db/migrate/20220106230629_add_registry_migration_application_settings.rb deleted file mode 100644 index 191443de6eb..00000000000 --- a/db/migrate/20220106230629_add_registry_migration_application_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddRegistryMigrationApplicationSettings < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220118141950_add_text_limit_to_container_registry_import_target_plan.rb - def change - add_column :application_settings, :container_registry_import_max_tags_count, :integer, default: 100, null: false - add_column :application_settings, :container_registry_import_max_retries, :integer, default: 3, null: false - add_column :application_settings, :container_registry_import_start_max_retries, :integer, default: 50, null: false - add_column :application_settings, :container_registry_import_max_step_duration, :integer, default: 5.minutes, null: false - add_column :application_settings, :container_registry_import_target_plan, :text, default: 'free', null: false - add_column :application_settings, :container_registry_import_created_before, :datetime_with_timezone, default: '2022-01-23 00:00:00', null: false - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20220106230712_add_migration_columns_to_container_repositories.rb b/db/migrate/20220106230712_add_migration_columns_to_container_repositories.rb deleted file mode 100644 index 76dccbe785f..00000000000 --- a/db/migrate/20220106230712_add_migration_columns_to_container_repositories.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddMigrationColumnsToContainerRepositories < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220117225936_add_text_limits_to_container_repositories_migration_columns.rb - def change - add_column :container_repositories, :migration_pre_import_started_at, :datetime_with_timezone - add_column :container_repositories, :migration_pre_import_done_at, :datetime_with_timezone - add_column :container_repositories, :migration_import_started_at, :datetime_with_timezone - add_column :container_repositories, :migration_import_done_at, :datetime_with_timezone - add_column :container_repositories, :migration_aborted_at, :datetime_with_timezone - add_column :container_repositories, :migration_skipped_at, :datetime_with_timezone - add_column :container_repositories, :migration_retries_count, :integer, default: 0, null: false - add_column :container_repositories, :migration_skipped_reason, :smallint - add_column :container_repositories, :migration_state, :text, default: 'default', null: false - add_column :container_repositories, :migration_aborted_in_state, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20220107091629_add_route_namespace_index.rb b/db/migrate/20220107091629_add_route_namespace_index.rb deleted file mode 100644 index bc1044a24da..00000000000 --- a/db/migrate/20220107091629_add_route_namespace_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddRouteNamespaceIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - INDEX_NAME = 'index_routes_on_namespace_id' - - def up - add_concurrent_index :routes, :namespace_id, unique: true, name: INDEX_NAME - add_concurrent_foreign_key :routes, :namespaces, column: :namespace_id, on_delete: :nullify, reverse_lock_order: true - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :routes, column: :namespace_id - end - - remove_concurrent_index_by_name :routes, INDEX_NAME - end -end diff --git a/db/migrate/20220107165036_remove_note_id_index.rb b/db/migrate/20220107165036_remove_note_id_index.rb deleted file mode 100644 index 15b4a3caf78..00000000000 --- a/db/migrate/20220107165036_remove_note_id_index.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveNoteIdIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - TABLE = :suggestions - INDEX_NAME = 'index_suggestions_on_note_id' - - def up - remove_concurrent_index_by_name TABLE, INDEX_NAME - end - - def down - add_concurrent_index TABLE, :note_id, name: INDEX_NAME - end -end diff --git a/db/migrate/20220109133006_remove_ci_pipelines_lock_version_index.rb b/db/migrate/20220109133006_remove_ci_pipelines_lock_version_index.rb deleted file mode 100644 index abbd54ff19b..00000000000 --- a/db/migrate/20220109133006_remove_ci_pipelines_lock_version_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveCiPipelinesLockVersionIndex < Gitlab::Database::Migration[1.0] - TABLE = :ci_pipelines - INDEX_NAME = 'tmp_index_ci_pipelines_lock_version' - COLUMN = :id - - disable_ddl_transaction! - - def up - remove_concurrent_index TABLE, COLUMN, where: "lock_version IS NULL", name: INDEX_NAME - end - - def down - add_concurrent_index TABLE, COLUMN, where: "lock_version IS NULL", name: INDEX_NAME - end -end diff --git a/db/migrate/20220110170953_create_ci_secure_files.rb b/db/migrate/20220110170953_create_ci_secure_files.rb deleted file mode 100644 index 1498a2d0212..00000000000 --- a/db/migrate/20220110170953_create_ci_secure_files.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CreateCiSecureFiles < Gitlab::Database::Migration[1.0] - def up - create_table :ci_secure_files do |t| - t.bigint :project_id, index: true, null: false - t.timestamps_with_timezone null: false - t.integer :file_store, limit: 2, null: false, default: 1 - t.integer :permissions, null: false, default: 0, limit: 2 - t.text :name, null: false, limit: 255 - t.text :file, null: false, limit: 255 - t.binary :checksum, null: false - end - end - - def down - drop_table :ci_secure_files, if_exists: true - end -end diff --git a/db/migrate/20220111095006_add_maintainer_note_to_ci_runners.rb b/db/migrate/20220111095006_add_maintainer_note_to_ci_runners.rb deleted file mode 100644 index 969774983c4..00000000000 --- a/db/migrate/20220111095006_add_maintainer_note_to_ci_runners.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class AddMaintainerNoteToCiRunners < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220111095007_add_text_limit_to_ci_runners_maintainer_note.rb - add_column :ci_runners, :maintainer_note, :text - # rubocop:enable Migration/AddLimitToTextColumns - end -end diff --git a/db/migrate/20220111095007_add_text_limit_to_ci_runners_maintainer_note.rb b/db/migrate/20220111095007_add_text_limit_to_ci_runners_maintainer_note.rb deleted file mode 100644 index 0a0a4171306..00000000000 --- a/db/migrate/20220111095007_add_text_limit_to_ci_runners_maintainer_note.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToCiRunnersMaintainerNote < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :ci_runners, :maintainer_note, 255 - end - - def down - remove_text_limit :ci_runners, :maintainer_note - end -end diff --git a/db/migrate/20220111154950_add_token_expires_at_to_ci_runners.rb b/db/migrate/20220111154950_add_token_expires_at_to_ci_runners.rb deleted file mode 100644 index b4d7c63d24b..00000000000 --- a/db/migrate/20220111154950_add_token_expires_at_to_ci_runners.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddTokenExpiresAtToCiRunners < Gitlab::Database::Migration[1.0] - def change - add_column :ci_runners, :token_expires_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20220111154951_add_index_to_ci_runners_token_expires_at.rb b/db/migrate/20220111154951_add_index_to_ci_runners_token_expires_at.rb deleted file mode 100644 index 53623198f51..00000000000 --- a/db/migrate/20220111154951_add_index_to_ci_runners_token_expires_at.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiRunnersTokenExpiresAt < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_index :ci_runners, [:token_expires_at, :id], order: { token_expires_at: :asc, id: :desc }, name: 'index_ci_runners_on_token_expires_at_and_id_desc' - add_concurrent_index :ci_runners, [:token_expires_at, :id], order: { token_expires_at: :desc, id: :desc }, name: 'index_ci_runners_on_token_expires_at_desc_and_id_desc' - end - - def down - remove_concurrent_index_by_name :ci_runners, 'index_ci_runners_on_token_expires_at_desc_and_id_desc' - remove_concurrent_index_by_name :ci_runners, 'index_ci_runners_on_token_expires_at_and_id_desc' - end -end diff --git a/db/migrate/20220111200254_remove_index_from_merge_requests.rb b/db/migrate/20220111200254_remove_index_from_merge_requests.rb deleted file mode 100644 index 0ac6019ad5e..00000000000 --- a/db/migrate/20220111200254_remove_index_from_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexFromMergeRequests < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_merge_requests_on_title' - - def up - remove_concurrent_index :merge_requests, :title, name: INDEX_NAME - end - - def down - add_concurrent_index :merge_requests, :title, name: INDEX_NAME - end -end diff --git a/db/migrate/20220112115413_add_requires_verification_to_user_details.rb b/db/migrate/20220112115413_add_requires_verification_to_user_details.rb deleted file mode 100644 index 01fe4f1d5cf..00000000000 --- a/db/migrate/20220112115413_add_requires_verification_to_user_details.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddRequiresVerificationToUserDetails < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :user_details, :requires_credit_card_verification, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20220112205111_create_security_training_providers.rb b/db/migrate/20220112205111_create_security_training_providers.rb deleted file mode 100644 index afddec6a134..00000000000 --- a/db/migrate/20220112205111_create_security_training_providers.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class CreateSecurityTrainingProviders < Gitlab::Database::Migration[1.0] - def change - create_table :security_training_providers do |t| - t.text :name, limit: 256, null: false - t.text :description, limit: 512 - t.text :url, limit: 512, null: false - t.text :logo_url, limit: 512 - - t.timestamps_with_timezone null: false - end - end -end diff --git a/db/migrate/20220112232037_add_member_namespace_reference.rb b/db/migrate/20220112232037_add_member_namespace_reference.rb deleted file mode 100644 index d67ea09a78c..00000000000 --- a/db/migrate/20220112232037_add_member_namespace_reference.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddMemberNamespaceReference < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :members, :member_namespace_id, :bigint unless column_exists?(:members, :member_namespace_id) - end - - def down - remove_column :members, :member_namespace_id if column_exists?(:members, :member_namespace_id) - end -end diff --git a/db/migrate/20220112232605_add_member_namespace_index.rb b/db/migrate/20220112232605_add_member_namespace_index.rb deleted file mode 100644 index ba32df53ae7..00000000000 --- a/db/migrate/20220112232605_add_member_namespace_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddMemberNamespaceIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - INDEX_NAME = 'index_members_on_member_namespace_id' - - def up - add_concurrent_index :members, :member_namespace_id, unique: false, name: INDEX_NAME - add_concurrent_foreign_key :members, :namespaces, column: :member_namespace_id, on_delete: :nullify, reverse_lock_order: true - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :members, column: :member_namespace_id - end - - remove_concurrent_index_by_name :members, INDEX_NAME - end -end diff --git a/db/migrate/20220113125401_create_security_trainings.rb b/db/migrate/20220113125401_create_security_trainings.rb deleted file mode 100644 index 6924c7bd189..00000000000 --- a/db/migrate/20220113125401_create_security_trainings.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateSecurityTrainings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - create_table :security_trainings do |t| - t.references :project, null: false, foreign_key: { on_delete: :cascade } - t.references :provider, null: false, foreign_key: { to_table: :security_training_providers, on_delete: :cascade } - t.boolean :is_primary, default: false, null: false - - t.timestamps_with_timezone null: false - - # Guarantee that there will be only one primary per project - t.index :project_id, name: 'index_security_trainings_on_unique_project_id', unique: true, where: 'is_primary IS TRUE' - end - end -end diff --git a/db/migrate/20220113135449_add_package_files_limit_to_application_settings.rb b/db/migrate/20220113135449_add_package_files_limit_to_application_settings.rb deleted file mode 100644 index 6d3deacdda3..00000000000 --- a/db/migrate/20220113135449_add_package_files_limit_to_application_settings.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddPackageFilesLimitToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - add_column :application_settings, :max_package_files_for_package_destruction, :smallint, default: 100, null: false - end -end diff --git a/db/migrate/20220113135924_add_application_settings_package_files_limit_constraints.rb b/db/migrate/20220113135924_add_application_settings_package_files_limit_constraints.rb deleted file mode 100644 index 65fbccbd1ae..00000000000 --- a/db/migrate/20220113135924_add_application_settings_package_files_limit_constraints.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddApplicationSettingsPackageFilesLimitConstraints < Gitlab::Database::Migration[1.0] - CONSTRAINT_NAME = 'app_settings_max_package_files_for_package_destruction_positive' - - disable_ddl_transaction! - - def up - add_check_constraint :application_settings, 'max_package_files_for_package_destruction > 0', CONSTRAINT_NAME - end - - def down - remove_check_constraint :application_settings, CONSTRAINT_NAME - end -end diff --git a/db/migrate/20220113164801_add_diffs_colors_to_user_preferences.rb b/db/migrate/20220113164801_add_diffs_colors_to_user_preferences.rb deleted file mode 100644 index 00e8e574722..00000000000 --- a/db/migrate/20220113164801_add_diffs_colors_to_user_preferences.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddDiffsColorsToUserPreferences < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220113164901_add_text_limit_to_user_preferences_diffs_colors.rb - def change - add_column :user_preferences, :diffs_deletion_color, :text - add_column :user_preferences, :diffs_addition_color, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20220113164901_add_text_limit_to_user_preferences_diffs_colors.rb b/db/migrate/20220113164901_add_text_limit_to_user_preferences_diffs_colors.rb deleted file mode 100644 index 9ae1c875194..00000000000 --- a/db/migrate/20220113164901_add_text_limit_to_user_preferences_diffs_colors.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToUserPreferencesDiffsColors < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :user_preferences, :diffs_deletion_color, 7 - add_text_limit :user_preferences, :diffs_addition_color, 7 - end - - def down - remove_text_limit :user_preferences, :diffs_addition_color - remove_text_limit :user_preferences, :diffs_deletion_color - end -end diff --git a/db/migrate/20220114131950_add_status_only_index_to_packages_package_files.rb b/db/migrate/20220114131950_add_status_only_index_to_packages_package_files.rb deleted file mode 100644 index 948edea1138..00000000000 --- a/db/migrate/20220114131950_add_status_only_index_to_packages_package_files.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddStatusOnlyIndexToPackagesPackageFiles < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_package_files_on_status' - - def up - add_concurrent_index :packages_package_files, :status, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_package_files, name: INDEX_NAME - end -end diff --git a/db/migrate/20220117082611_add_text_limit_to_exad_verification_tokens.rb b/db/migrate/20220117082611_add_text_limit_to_exad_verification_tokens.rb deleted file mode 100644 index 9978e87a1e3..00000000000 --- a/db/migrate/20220117082611_add_text_limit_to_exad_verification_tokens.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToExadVerificationTokens < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :audit_events_external_audit_event_destinations, :verification_token, 24 - end - - def down - remove_text_limit :audit_events_external_audit_event_destinations, :verification_token - end -end diff --git a/db/migrate/20220117225936_add_text_limits_to_container_repositories_migration_columns.rb b/db/migrate/20220117225936_add_text_limits_to_container_repositories_migration_columns.rb deleted file mode 100644 index 91c0612716b..00000000000 --- a/db/migrate/20220117225936_add_text_limits_to_container_repositories_migration_columns.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitsToContainerRepositoriesMigrationColumns < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :container_repositories, :migration_state, 255 - add_text_limit :container_repositories, :migration_aborted_in_state, 255 - end - - def down - remove_text_limit :container_repositories, :migration_state - remove_text_limit :container_repositories, :migration_aborted_in_state - end -end diff --git a/db/migrate/20220118015633_add_url_text_to_issuable_metric_images.rb b/db/migrate/20220118015633_add_url_text_to_issuable_metric_images.rb deleted file mode 100644 index 55d820c1256..00000000000 --- a/db/migrate/20220118015633_add_url_text_to_issuable_metric_images.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddUrlTextToIssuableMetricImages < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220118020026_add_url_text_limit_to_issuable_metric_images - def change - add_column :issuable_metric_images, :url_text, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20220118020026_add_url_text_limit_to_issuable_metric_images.rb b/db/migrate/20220118020026_add_url_text_limit_to_issuable_metric_images.rb deleted file mode 100644 index 2f0f27681cd..00000000000 --- a/db/migrate/20220118020026_add_url_text_limit_to_issuable_metric_images.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddUrlTextLimitToIssuableMetricImages < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :issuable_metric_images, :url_text, 128 - end - - def down - remove_text_limit :issuable_metric_images, :url_text - end -end diff --git a/db/migrate/20220118141950_add_text_limit_to_container_registry_import_target_plan.rb b/db/migrate/20220118141950_add_text_limit_to_container_registry_import_target_plan.rb deleted file mode 100644 index c7247d03423..00000000000 --- a/db/migrate/20220118141950_add_text_limit_to_container_registry_import_target_plan.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToContainerRegistryImportTargetPlan < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :application_settings, :container_registry_import_target_plan, 255 - end - - def down - remove_text_limit :application_settings, :container_registry_import_target_plan - end -end diff --git a/db/migrate/20220118155846_add_runner_token_expiration_interval_settings_to_application_settings.rb b/db/migrate/20220118155846_add_runner_token_expiration_interval_settings_to_application_settings.rb deleted file mode 100644 index 32ca8a5fb12..00000000000 --- a/db/migrate/20220118155846_add_runner_token_expiration_interval_settings_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddRunnerTokenExpirationIntervalSettingsToApplicationSettings < Gitlab::Database::Migration[1.0] - def change - [:runner_token_expiration_interval, :group_runner_token_expiration_interval, :project_runner_token_expiration_interval].each do |field| - add_column :application_settings, field, :integer - end - end -end diff --git a/db/migrate/20220118155847_add_runner_token_expiration_interval_settings_to_namespace_settings.rb b/db/migrate/20220118155847_add_runner_token_expiration_interval_settings_to_namespace_settings.rb deleted file mode 100644 index 7b83cb2dd55..00000000000 --- a/db/migrate/20220118155847_add_runner_token_expiration_interval_settings_to_namespace_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddRunnerTokenExpirationIntervalSettingsToNamespaceSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - [:runner_token_expiration_interval, :subgroup_runner_token_expiration_interval, :project_runner_token_expiration_interval].each do |field| - add_column :namespace_settings, field, :integer - end - end -end diff --git a/db/migrate/20220118155848_add_runner_token_expiration_interval_settings_to_project_settings.rb b/db/migrate/20220118155848_add_runner_token_expiration_interval_settings_to_project_settings.rb deleted file mode 100644 index ef959171828..00000000000 --- a/db/migrate/20220118155848_add_runner_token_expiration_interval_settings_to_project_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddRunnerTokenExpirationIntervalSettingsToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :project_ci_cd_settings, :runner_token_expiration_interval, :integer - end -end diff --git a/db/migrate/20220119094023_add_unique_index_to_aed_verification_token.rb b/db/migrate/20220119094023_add_unique_index_to_aed_verification_token.rb deleted file mode 100644 index bd40fe2203e..00000000000 --- a/db/migrate/20220119094023_add_unique_index_to_aed_verification_token.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexToAedVerificationToken < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_audit_events_external_audit_on_verification_token' - - def up - add_concurrent_index :audit_events_external_audit_event_destinations, :verification_token, unique: true, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :audit_events_external_audit_event_destinations, INDEX_NAME - end -end diff --git a/db/migrate/20220119141407_add_dependency_proxy_size_to_namespace_statistics.rb b/db/migrate/20220119141407_add_dependency_proxy_size_to_namespace_statistics.rb deleted file mode 100644 index d8107ad8e21..00000000000 --- a/db/migrate/20220119141407_add_dependency_proxy_size_to_namespace_statistics.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDependencyProxySizeToNamespaceStatistics < Gitlab::Database::Migration[1.0] - def change - add_column :namespace_statistics, :dependency_proxy_size, :bigint, default: 0, null: false - end -end diff --git a/db/migrate/20220119144253_add_dependency_proxy_size_to_namespace_root_storage_statistics.rb b/db/migrate/20220119144253_add_dependency_proxy_size_to_namespace_root_storage_statistics.rb deleted file mode 100644 index 8218f869ce6..00000000000 --- a/db/migrate/20220119144253_add_dependency_proxy_size_to_namespace_root_storage_statistics.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddDependencyProxySizeToNamespaceRootStorageStatistics < Gitlab::Database::Migration[1.0] - def change - add_column :namespace_root_storage_statistics, :dependency_proxy_size, :bigint, default: 0, null: false - end -end diff --git a/db/migrate/20220119170426_remove_temporary_vulnerability_occurrences_deduplication_index.rb b/db/migrate/20220119170426_remove_temporary_vulnerability_occurrences_deduplication_index.rb deleted file mode 100644 index 26859beb671..00000000000 --- a/db/migrate/20220119170426_remove_temporary_vulnerability_occurrences_deduplication_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveTemporaryVulnerabilityOccurrencesDeduplicationIndex < Gitlab::Database::Migration[1.0] - MIGRATION = 'RecalculateVulnerabilitiesOccurrencesUuid' - INDEX_NAME = 'tmp_idx_deduplicate_vulnerability_occurrences' - - disable_ddl_transaction! - - def up - finalize_background_migration(MIGRATION) - - remove_concurrent_index_by_name(:vulnerability_occurrences, INDEX_NAME) - end - - def down - add_concurrent_index :vulnerability_occurrences, - %i[project_id report_type location_fingerprint primary_identifier_id id], - name: INDEX_NAME - end -end diff --git a/db/migrate/20220119220620_add_scan_method_to_dast_site_profile.rb b/db/migrate/20220119220620_add_scan_method_to_dast_site_profile.rb deleted file mode 100644 index f7b7580d673..00000000000 --- a/db/migrate/20220119220620_add_scan_method_to_dast_site_profile.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddScanMethodToDastSiteProfile < Gitlab::Database::Migration[1.0] - def up - add_column :dast_site_profiles, :scan_method, :integer, limit: 2, default: 0, null: false - end - - def down - remove_column :dast_site_profiles, :scan_method - end -end diff --git a/db/migrate/20220120033115_create_alert_management_alert_metric_images.rb b/db/migrate/20220120033115_create_alert_management_alert_metric_images.rb deleted file mode 100644 index e98392190f4..00000000000 --- a/db/migrate/20220120033115_create_alert_management_alert_metric_images.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateAlertManagementAlertMetricImages < Gitlab::Database::Migration[1.0] - def up - create_table :alert_management_alert_metric_images do |t| - t.references :alert, null: false, index: true, foreign_key: { to_table: :alert_management_alerts, on_delete: :cascade } - t.timestamps_with_timezone - t.integer :file_store, limit: 2 - t.text :file, limit: 255, null: false - t.text :url, limit: 255 - t.text :url_text, limit: 128 - end - end - - def down - drop_table :alert_management_alert_metric_images, if_exists: true - end -end diff --git a/db/migrate/20220120085655_add_ci_runner_project_index_to_runner_id_and_project_id.rb b/db/migrate/20220120085655_add_ci_runner_project_index_to_runner_id_and_project_id.rb deleted file mode 100644 index bcf32d2abd0..00000000000 --- a/db/migrate/20220120085655_add_ci_runner_project_index_to_runner_id_and_project_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddCiRunnerProjectIndexToRunnerIdAndProjectId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - OLD_INDEX_NAME = 'index_ci_runner_projects_on_runner_id' - NEW_INDEX_NAME = 'index_ci_runner_projects_on_runner_id_and_project_id' - TABLE_NAME = :ci_runner_projects - - def up - add_concurrent_index(TABLE_NAME, [:runner_id, :project_id], name: NEW_INDEX_NAME) - remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME) - end - - def down - add_concurrent_index(TABLE_NAME, :runner_id, name: OLD_INDEX_NAME) - remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME) - end -end diff --git a/db/migrate/20220120160625_remove_temp_index_on_id_from_vulnerability_occurrences.rb b/db/migrate/20220120160625_remove_temp_index_on_id_from_vulnerability_occurrences.rb deleted file mode 100644 index 747cabcd865..00000000000 --- a/db/migrate/20220120160625_remove_temp_index_on_id_from_vulnerability_occurrences.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveTempIndexOnIdFromVulnerabilityOccurrences < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'tmp_idx_vulnerability_occurrences_on_id_where_report_type_7_99' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :vulnerability_occurrences, name: INDEX_NAME - end - - def down - add_concurrent_index :vulnerability_occurrences, :id, where: 'report_type IN (7, 99)', name: INDEX_NAME - end -end diff --git a/db/migrate/20220120211831_temp_index_for_group_namespace_member_backfill.rb b/db/migrate/20220120211831_temp_index_for_group_namespace_member_backfill.rb deleted file mode 100644 index 527d8783a0f..00000000000 --- a/db/migrate/20220120211831_temp_index_for_group_namespace_member_backfill.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class TempIndexForGroupNamespaceMemberBackfill < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'tmp_index_for_namespace_id_migration_on_group_members' - - disable_ddl_transaction! - - def up - # Temporary index to be removed in 14.10 - # https://gitlab.com/gitlab-org/gitlab/-/issues/353538 - add_concurrent_index :members, :id, where: "members.member_namespace_id IS NULL and members.type = 'GroupMember'", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :members, INDEX_NAME - end -end diff --git a/db/migrate/20220124200927_add_index_to_issues.rb b/db/migrate/20220124200927_add_index_to_issues.rb deleted file mode 100644 index 03cdc3ade2c..00000000000 --- a/db/migrate/20220124200927_add_index_to_issues.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToIssues < Gitlab::Database::Migration[1.0] - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_id_and_weight' - - def up - add_concurrent_index :issues, [:id, :weight], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/migrate/20220125084127_add_cleanup_attempts_to_loose_foreign_keys_deleted_records.rb b/db/migrate/20220125084127_add_cleanup_attempts_to_loose_foreign_keys_deleted_records.rb deleted file mode 100644 index e0c80ad79e5..00000000000 --- a/db/migrate/20220125084127_add_cleanup_attempts_to_loose_foreign_keys_deleted_records.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddCleanupAttemptsToLooseForeignKeysDeletedRecords < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :loose_foreign_keys_deleted_records, :cleanup_attempts, :smallint, default: 0 - end - - def down - remove_column :loose_foreign_keys_deleted_records, :cleanup_attempts - end -end diff --git a/db/migrate/20220125122228_add_topics_non_private_projects_count.rb b/db/migrate/20220125122228_add_topics_non_private_projects_count.rb deleted file mode 100644 index 8c7b750d5ff..00000000000 --- a/db/migrate/20220125122228_add_topics_non_private_projects_count.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddTopicsNonPrivateProjectsCount < Gitlab::Database::Migration[1.0] - def up - add_column :topics, :non_private_projects_count, :bigint, null: false, default: 0 - end - - def down - remove_column :topics, :non_private_projects_count - end -end diff --git a/db/migrate/20220125122725_add_topics_non_private_projects_count_index.rb b/db/migrate/20220125122725_add_topics_non_private_projects_count_index.rb deleted file mode 100644 index 46b4d298a2e..00000000000 --- a/db/migrate/20220125122725_add_topics_non_private_projects_count_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTopicsNonPrivateProjectsCountIndex < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_topics_non_private_projects_count' - - disable_ddl_transaction! - - def up - add_concurrent_index :topics, [:non_private_projects_count, :id], order: { non_private_projects_count: :desc }, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :topics, INDEX_NAME - end -end diff --git a/db/migrate/20220125230538_add_compound_index_on_project_id_and_id_for_vulnerabilities.rb b/db/migrate/20220125230538_add_compound_index_on_project_id_and_id_for_vulnerabilities.rb deleted file mode 100644 index c745fa51328..00000000000 --- a/db/migrate/20220125230538_add_compound_index_on_project_id_and_id_for_vulnerabilities.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddCompoundIndexOnProjectIdAndIdForVulnerabilities < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerabilities, [:project_id, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index :vulnerabilities, [:project_id, :id], name: INDEX_NAME - end -end diff --git a/db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb b/db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb deleted file mode 100644 index eab02663e26..00000000000 --- a/db/migrate/20220126191624_add_scan_file_path_to_dast_site_profile.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddScanFilePathToDastSiteProfile < Gitlab::Database::Migration[2.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20221012135524_add_scan_file_path_limit_for_dast_site_profile - def up - add_column :dast_site_profiles, :scan_file_path, :text - end - # rubocop:enable Migration/AddLimitToTextColumns - - def down - remove_column :dast_site_profiles, :scan_file_path, :text - end -end diff --git a/db/migrate/20220128093756_add_ecdsa_sk_and_ed25519_sk_key_restrictions_to_application_settings.rb b/db/migrate/20220128093756_add_ecdsa_sk_and_ed25519_sk_key_restrictions_to_application_settings.rb deleted file mode 100644 index 1acd9599da4..00000000000 --- a/db/migrate/20220128093756_add_ecdsa_sk_and_ed25519_sk_key_restrictions_to_application_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddEcdsaSkAndEd25519SkKeyRestrictionsToApplicationSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :application_settings, :ecdsa_sk_key_restriction, :integer, default: 0, null: false - add_column :application_settings, :ed25519_sk_key_restriction, :integer, default: 0, null: false - end -end diff --git a/db/migrate/20220128194722_add_index_on_migration_state_and_import_done_at_to_container_repositories.rb b/db/migrate/20220128194722_add_index_on_migration_state_and_import_done_at_to_container_repositories.rb deleted file mode 100644 index 6c9fb20bbbd..00000000000 --- a/db/migrate/20220128194722_add_index_on_migration_state_and_import_done_at_to_container_repositories.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnMigrationStateAndImportDoneAtToContainerRepositories < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_container_repositories_on_migration_state_import_done_at' - disable_ddl_transaction! - - def up - add_concurrent_index :container_repositories, [:migration_state, :migration_import_done_at], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :container_repositories, INDEX_NAME - end -end diff --git a/db/migrate/20220131135725_add_severity_level_to_merge_requests_compliance_violations.rb b/db/migrate/20220131135725_add_severity_level_to_merge_requests_compliance_violations.rb deleted file mode 100644 index 50aa0121055..00000000000 --- a/db/migrate/20220131135725_add_severity_level_to_merge_requests_compliance_violations.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddSeverityLevelToMergeRequestsComplianceViolations < Gitlab::Database::Migration[1.0] - def change - add_column :merge_requests_compliance_violations, :severity_level, :integer, limit: 2, null: false, default: 0 - end -end diff --git a/db/migrate/20220131192643_add_show_diff_preview_in_email_to_project_settings.rb b/db/migrate/20220131192643_add_show_diff_preview_in_email_to_project_settings.rb deleted file mode 100644 index 1811bf04ee4..00000000000 --- a/db/migrate/20220131192643_add_show_diff_preview_in_email_to_project_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddShowDiffPreviewInEmailToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :project_settings, :show_diff_preview_in_email, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20220201205300_remove_index_for_vulnerability_occurrences.rb b/db/migrate/20220201205300_remove_index_for_vulnerability_occurrences.rb deleted file mode 100644 index 89591d14aae..00000000000 --- a/db/migrate/20220201205300_remove_index_for_vulnerability_occurrences.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexForVulnerabilityOccurrences < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_vulnerability_occurrences_on_unique_keys' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME - end - - def down - # no-op - - # The index is UNIQUE so we cannot add it back again - end -end diff --git a/db/migrate/20220202034409_add_tmp_index_on_id_and_migration_state_to_container_repositories.rb b/db/migrate/20220202034409_add_tmp_index_on_id_and_migration_state_to_container_repositories.rb deleted file mode 100644 index b999c871a3e..00000000000 --- a/db/migrate/20220202034409_add_tmp_index_on_id_and_migration_state_to_container_repositories.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexOnIdAndMigrationStateToContainerRepositories < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'tmp_index_container_repositories_on_id_migration_state' - - disable_ddl_transaction! - - # Temporary index to be removed https://gitlab.com/gitlab-org/gitlab/-/issues/351783 - def up - add_concurrent_index :container_repositories, [:id, :migration_state], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :container_repositories, INDEX_NAME - end -end diff --git a/db/migrate/20220202115350_add_migration_indexes_to_container_repositories.rb b/db/migrate/20220202115350_add_migration_indexes_to_container_repositories.rb deleted file mode 100644 index 673d066e3c0..00000000000 --- a/db/migrate/20220202115350_add_migration_indexes_to_container_repositories.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddMigrationIndexesToContainerRepositories < Gitlab::Database::Migration[1.0] - PRE_IMPORTING_INDEX = 'idx_container_repos_on_pre_import_started_at_when_pre_importing' - PRE_IMPORT_DONE_INDEX = 'idx_container_repos_on_pre_import_done_at_when_pre_import_done' - IMPORTING_INDEX = 'idx_container_repos_on_import_started_at_when_importing' - - disable_ddl_transaction! - - def up - add_concurrent_index :container_repositories, :migration_pre_import_started_at, name: PRE_IMPORTING_INDEX, where: "migration_state = 'pre_importing'" - add_concurrent_index :container_repositories, :migration_pre_import_done_at, name: PRE_IMPORT_DONE_INDEX, where: "migration_state = 'pre_import_done'" - add_concurrent_index :container_repositories, :migration_import_started_at, name: IMPORTING_INDEX, where: "migration_state = 'importing'" - end - - def down - remove_concurrent_index_by_name :container_repositories, IMPORTING_INDEX - remove_concurrent_index_by_name :container_repositories, PRE_IMPORT_DONE_INDEX - remove_concurrent_index_by_name :container_repositories, PRE_IMPORTING_INDEX - end -end diff --git a/db/migrate/20220203074916_add_topics_lower_name_index.rb b/db/migrate/20220203074916_add_topics_lower_name_index.rb deleted file mode 100644 index 721abf66c67..00000000000 --- a/db/migrate/20220203074916_add_topics_lower_name_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTopicsLowerNameIndex < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_topics_on_lower_name' - - disable_ddl_transaction! - - def up - add_concurrent_index :topics, 'lower(name)', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :topics, INDEX_NAME - end -end diff --git a/db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb b/db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb deleted file mode 100644 index c30d8de23db..00000000000 --- a/db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class FixUniquePackagesIndexExcludingPendingDestructionStatus < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - GO_UNIQUE_INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_golang' - GENERIC_UNIQUE_INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_generic' - HELM_UNIQUE_INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_helm' - - NEW_GO_UNIQUE_INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_golang' - NEW_GENERIC_UNIQUE_INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_generic' - NEW_HELM_UNIQUE_INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_helm' - - def up - add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, name: NEW_GO_UNIQUE_INDEX_NAME, where: 'package_type = 8 AND status != 4' - add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, name: NEW_GENERIC_UNIQUE_INDEX_NAME, where: 'package_type = 7 AND status != 4' - add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, name: NEW_HELM_UNIQUE_INDEX_NAME, where: 'package_type = 11 AND status != 4' - - remove_concurrent_index_by_name :packages_packages, GO_UNIQUE_INDEX_NAME - remove_concurrent_index_by_name :packages_packages, GENERIC_UNIQUE_INDEX_NAME - remove_concurrent_index_by_name :packages_packages, HELM_UNIQUE_INDEX_NAME - end - - def down - # no-op - # We can't guarantee that the old index can be recreated since it targets a set larger that the new index. - end -end diff --git a/db/migrate/20220203123333_add_batched_migration_max_batch.rb b/db/migrate/20220203123333_add_batched_migration_max_batch.rb deleted file mode 100644 index d16c6dd4110..00000000000 --- a/db/migrate/20220203123333_add_batched_migration_max_batch.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddBatchedMigrationMaxBatch < Gitlab::Database::Migration[1.0] - def change - add_column :batched_background_migrations, :max_batch_size, :integer - end -end diff --git a/db/migrate/20220203133652_add_legacy_open_source_license_available_to_project_settings.rb b/db/migrate/20220203133652_add_legacy_open_source_license_available_to_project_settings.rb deleted file mode 100644 index 47f92fae496..00000000000 --- a/db/migrate/20220203133652_add_legacy_open_source_license_available_to_project_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddLegacyOpenSourceLicenseAvailableToProjectSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def change - add_column :project_settings, :legacy_open_source_license_available, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20220203134942_add_hidden_to_projects.rb b/db/migrate/20220203134942_add_hidden_to_projects.rb deleted file mode 100644 index 7046d641289..00000000000 --- a/db/migrate/20220203134942_add_hidden_to_projects.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddHiddenToProjects < Gitlab::Database::Migration[1.0] - DOWNTIME = false - - enable_lock_retries! - - def change - add_column :projects, :hidden, :boolean, default: false, null: false # rubocop: disable Migration/AddColumnsToWideTables - end -end diff --git a/db/migrate/20220204093120_create_analytics_cycle_analytics_aggregations.rb b/db/migrate/20220204093120_create_analytics_cycle_analytics_aggregations.rb deleted file mode 100644 index 0339e16a85b..00000000000 --- a/db/migrate/20220204093120_create_analytics_cycle_analytics_aggregations.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true -class CreateAnalyticsCycleAnalyticsAggregations < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - create_table :analytics_cycle_analytics_aggregations, id: false do |t| - t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade } - t.integer :incremental_runtimes_in_seconds, array: true, default: [], null: false - t.integer :incremental_processed_records, array: true, default: [], null: false - t.integer :last_full_run_runtimes_in_seconds, array: true, default: [], null: false - t.integer :last_full_run_processed_records, array: true, default: [], null: false - t.integer :last_incremental_issues_id - t.integer :last_incremental_merge_requests_id - t.integer :last_full_run_issues_id - t.integer :last_full_run_merge_requests_id - - t.datetime_with_timezone :last_incremental_run_at - t.datetime_with_timezone :last_incremental_issues_updated_at - t.datetime_with_timezone :last_incremental_merge_requests_updated_at - t.datetime_with_timezone :last_full_run_at - t.datetime_with_timezone :last_full_run_issues_updated_at - t.datetime_with_timezone :last_full_run_mrs_updated_at - t.datetime_with_timezone :last_consistency_check_updated_at - - t.boolean :enabled, default: true, null: false - - t.index :last_incremental_run_at, where: 'enabled IS TRUE', name: 'ca_aggregations_last_incremental_run_at', order: { last_incremental_run_at: 'ASC NULLS FIRST' } - t.index :last_full_run_at, where: 'enabled IS TRUE', name: 'ca_aggregations_last_full_run_at', order: { last_full_run_at: 'ASC NULLS FIRST' } - t.index :last_consistency_check_updated_at, where: 'enabled IS TRUE', name: 'ca_aggregations_last_consistency_check_updated_at', order: { last_consistency_check_updated_at: 'ASC NULLS FIRST' } - - t.check_constraint 'CARDINALITY(incremental_runtimes_in_seconds) <= 10' - t.check_constraint 'CARDINALITY(incremental_processed_records) <= 10' - t.check_constraint 'CARDINALITY(last_full_run_runtimes_in_seconds) <= 10' - t.check_constraint 'CARDINALITY(last_full_run_processed_records) <= 10' - end - - execute("ALTER TABLE analytics_cycle_analytics_aggregations ADD PRIMARY KEY (group_id)") - end - - def down - drop_table :analytics_cycle_analytics_aggregations - end -end diff --git a/db/migrate/20220204154220_add_index_on_greatest_done_at_to_container_repositories.rb b/db/migrate/20220204154220_add_index_on_greatest_done_at_to_container_repositories.rb deleted file mode 100644 index 455a8478cc4..00000000000 --- a/db/migrate/20220204154220_add_index_on_greatest_done_at_to_container_repositories.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnGreatestDoneAtToContainerRepositories < Gitlab::Database::Migration[1.0] - INDEX_NAME = 'index_container_repositories_on_greatest_done_at' - disable_ddl_transaction! - - def up - add_concurrent_index :container_repositories, - 'GREATEST(migration_pre_import_done_at, migration_import_done_at, migration_aborted_at)', - where: "migration_state IN ('import_done', 'pre_import_done', 'import_aborted')", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :container_repositories, INDEX_NAME - end -end diff --git a/db/migrate/20220204193000_add_integrations_encrypted_properties.rb b/db/migrate/20220204193000_add_integrations_encrypted_properties.rb deleted file mode 100644 index 7df88b68657..00000000000 --- a/db/migrate/20220204193000_add_integrations_encrypted_properties.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class AddIntegrationsEncryptedProperties < Gitlab::Database::Migration[1.0] - def change - add_column :integrations, :encrypted_properties, :binary - add_column :integrations, :encrypted_properties_iv, :binary - end -end diff --git a/db/migrate/20220207083129_add_users_get_by_id_limit_to_application_setting.rb b/db/migrate/20220207083129_add_users_get_by_id_limit_to_application_setting.rb deleted file mode 100644 index cdf2aced213..00000000000 --- a/db/migrate/20220207083129_add_users_get_by_id_limit_to_application_setting.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUsersGetByIdLimitToApplicationSetting < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :application_settings, :users_get_by_id_limit, :integer, null: false, default: 300 - add_column :application_settings, :users_get_by_id_limit_allowlist, :text, array: true, limit: 255, null: false, default: [] - end - - def down - remove_column :application_settings, :users_get_by_id_limit - remove_column :application_settings, :users_get_by_id_limit_allowlist - end -end diff --git a/db/migrate/20220208170445_add_not_valid_foreign_key_to_ci_builds_runner_id.rb b/db/migrate/20220208170445_add_not_valid_foreign_key_to_ci_builds_runner_id.rb deleted file mode 100644 index 9b2ba17e068..00000000000 --- a/db/migrate/20220208170445_add_not_valid_foreign_key_to_ci_builds_runner_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddNotValidForeignKeyToCiBuildsRunnerId < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :ci_builds, :ci_runners, column: :runner_id, on_delete: :nullify, validate: false - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :ci_builds, column: :runner_id - end - end -end diff --git a/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb b/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb deleted file mode 100644 index b01dbe642e2..00000000000 --- a/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.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 UpdateDefaultScanMethodOfDastSiteProfile < Gitlab::Database::Migration[1.0] - BATCH_SIZE = 500 - - disable_ddl_transaction! - - def up - each_batch_range('dast_site_profiles', scope: ->(table) { table.where(target_type: 1) }, of: BATCH_SIZE) do |min, max| - execute <<~SQL - UPDATE dast_site_profiles - SET scan_method = 1 - WHERE id BETWEEN #{min} AND #{max} - SQL - end - end - - def down - # noop - end -end diff --git a/db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb b/db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb deleted file mode 100644 index 5ab8feb2195..00000000000 --- a/db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CleanupPopulateTopicsNonPrivateProjectsCount < Gitlab::Database::Migration[1.0] - MIGRATION = 'PopulateTopicsNonPrivateProjectsCount' - - disable_ddl_transaction! - - def up - finalize_background_migration(MIGRATION) - end - - def down - # no-op - end -end diff --git a/db/migrate/20220211125954_create_related_epic_links.rb b/db/migrate/20220211125954_create_related_epic_links.rb deleted file mode 100644 index c06a68a9dd2..00000000000 --- a/db/migrate/20220211125954_create_related_epic_links.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class CreateRelatedEpicLinks < Gitlab::Database::Migration[1.0] - def up - create_table :related_epic_links do |t| - t.references :source, index: true, foreign_key: { to_table: :epics, on_delete: :cascade }, null: false - t.references :target, index: true, foreign_key: { to_table: :epics, on_delete: :cascade }, null: false - t.timestamps_with_timezone null: false - t.integer :link_type, null: false, default: 0, limit: 2 - - t.index [:source_id, :target_id], unique: true - end - end - - def down - drop_table :related_epic_links - end -end diff --git a/db/migrate/20220211214605_update_integrations_trigger_type_new_on_insert_null_safe.rb b/db/migrate/20220211214605_update_integrations_trigger_type_new_on_insert_null_safe.rb deleted file mode 100644 index 7a60ea48f40..00000000000 --- a/db/migrate/20220211214605_update_integrations_trigger_type_new_on_insert_null_safe.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class UpdateIntegrationsTriggerTypeNewOnInsertNullSafe < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - FUNCTION_NAME = 'integrations_set_type_new' - - def up - # Update `type_new` dynamically based on `type`, if `type_new` is null - # and `type` dynamically based on `type_new`, if `type` is null. - # - # The old class names are in the format `AbcService`, and the new ones `Integrations::Abc`. - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL.squish - UPDATE integrations - SET type_new = COALESCE(NEW.type_new, regexp_replace(NEW.type, '\\A(.+)Service\\Z', 'Integrations::\\1')) - , type = COALESCE(NEW.type, regexp_replace(NEW.type_new, '\\AIntegrations::(.+)\\Z', '\\1Service')) - WHERE integrations.id = NEW.id; - RETURN NULL; - SQL - end - end - - def down - # 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 -end diff --git a/db/migrate/20220213100000_remove_integration_type_triggers.rb b/db/migrate/20220213100000_remove_integration_type_triggers.rb deleted file mode 100644 index 137e5648125..00000000000 --- a/db/migrate/20220213100000_remove_integration_type_triggers.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class RemoveIntegrationTypeTriggers < Gitlab::Database::Migration[1.0] - include Gitlab::Database::SchemaHelpers - - FUNCTION_NAME = 'integrations_set_type_new' - TRIGGER_ON_INSERT_NAME = 'trigger_type_new_on_insert' - - def up - drop_trigger(:integrations, TRIGGER_ON_INSERT_NAME) - drop_function(FUNCTION_NAME) - end - - def down - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL.squish - UPDATE integrations - SET type_new = COALESCE(NEW.type_new, regexp_replace(NEW.type, '\\A(.+)Service\\Z', 'Integrations::\\1')) - , type = COALESCE(NEW.type, regexp_replace(NEW.type_new, '\\AIntegrations::(.+)\\Z', '\\1Service')) - WHERE integrations.id = NEW.id; - 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 -end diff --git a/db/migrate/20220215164709_update_application_settings_container_registry_exp_pol_worker_capacity_default.rb b/db/migrate/20220215164709_update_application_settings_container_registry_exp_pol_worker_capacity_default.rb deleted file mode 100644 index 4b743f84c4d..00000000000 --- a/db/migrate/20220215164709_update_application_settings_container_registry_exp_pol_worker_capacity_default.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true -class UpdateApplicationSettingsContainerRegistryExpPolWorkerCapacityDefault < Gitlab::Database::Migration[1.0] - class Settings < ActiveRecord::Base - self.table_name = 'application_settings' - end - - def up - change_column_default(:application_settings, :container_registry_expiration_policies_worker_capacity, from: 0, to: 4) - - current_settings = Settings.first - - if current_settings&.container_registry_expiration_policies_worker_capacity == 0 - current_settings.update!(container_registry_expiration_policies_worker_capacity: 4) - end - end - - def down - change_column_default(:application_settings, :container_registry_expiration_policies_worker_capacity, from: 4, to: 0) - end -end diff --git a/db/migrate/20220216110023_create_saved_replies.rb b/db/migrate/20220216110023_create_saved_replies.rb deleted file mode 100644 index e4b6c039dee..00000000000 --- a/db/migrate/20220216110023_create_saved_replies.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class CreateSavedReplies < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - create_table :saved_replies do |t| - t.references :user, index: false, null: false, foreign_key: { on_delete: :cascade } - t.timestamps_with_timezone null: false - t.text :name, null: false, limit: 255 - t.text :content, null: false, limit: 10000 - - t.index [:user_id, :name], name: 'index_saved_replies_on_name_text_pattern_ops', unique: true, opclass: { name: :text_pattern_ops } - end - end - - def down - drop_table :saved_replies, if_exists: true - end -end diff --git a/db/migrate/20220217100008_add_container_registry_expiration_policies_caching_to_application_settings.rb b/db/migrate/20220217100008_add_container_registry_expiration_policies_caching_to_application_settings.rb deleted file mode 100644 index bd5b13ffa1c..00000000000 --- a/db/migrate/20220217100008_add_container_registry_expiration_policies_caching_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddContainerRegistryExpirationPoliciesCachingToApplicationSettings < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - add_column :application_settings, :container_registry_expiration_policies_caching, :boolean, null: false, default: true - end - - def down - remove_column :application_settings, :container_registry_expiration_policies_caching - end -end diff --git a/db/migrate/20220217113058_add_status_to_status_check_responses.rb b/db/migrate/20220217113058_add_status_to_status_check_responses.rb deleted file mode 100644 index 2f118677883..00000000000 --- a/db/migrate/20220217113058_add_status_to_status_check_responses.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToStatusCheckResponses < Gitlab::Database::Migration[1.0] - def change - add_column :status_check_responses, :status, :integer, default: 0, null: false, limit: 2 - end -end diff --git a/db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb b/db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb deleted file mode 100644 index a3d71a060b8..00000000000 --- a/db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class ChangeMaintainerNoteLimitInCiRunner < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit( - :ci_runners, - :maintainer_note, - 1024, - constraint_name: check_constraint_name(:ci_runners, :maintainer_note, 'max_length_1MB') - ) - - remove_text_limit( - :ci_runners, - :maintainer_note, - constraint_name: check_constraint_name(:ci_runners, :maintainer_note, 'max_length') - ) - end - - def down - # no-op: Danger of failing if there are records with length(maintainer_note) > 255 - end -end diff --git a/db/migrate/20220222072536_add_target_access_levels_to_broadcast_messages.rb b/db/migrate/20220222072536_add_target_access_levels_to_broadcast_messages.rb deleted file mode 100644 index fd353843878..00000000000 --- a/db/migrate/20220222072536_add_target_access_levels_to_broadcast_messages.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddTargetAccessLevelsToBroadcastMessages < Gitlab::Database::Migration[1.0] - def up - add_column :broadcast_messages, :target_access_levels, :integer, if_not_exists: true, array: true, null: false, default: [] - end - - def down - remove_column :broadcast_messages, :target_access_levels, if_exists: true - end -end diff --git a/db/migrate/20220301002101_add_security_orchestration_policy_configuration_namespace_reference.rb b/db/migrate/20220301002101_add_security_orchestration_policy_configuration_namespace_reference.rb deleted file mode 100644 index 42828086310..00000000000 --- a/db/migrate/20220301002101_add_security_orchestration_policy_configuration_namespace_reference.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddSecurityOrchestrationPolicyConfigurationNamespaceReference < Gitlab::Database::Migration[1.0] - def up - add_column :security_orchestration_policy_configurations, :namespace_id, :bigint - end - - def down - remove_column :security_orchestration_policy_configurations, :namespace_id - end -end diff --git a/db/migrate/20220301003502_add_security_orchestration_policy_configuration_namespace_index.rb b/db/migrate/20220301003502_add_security_orchestration_policy_configuration_namespace_index.rb deleted file mode 100644 index de6b36faa65..00000000000 --- a/db/migrate/20220301003502_add_security_orchestration_policy_configuration_namespace_index.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class AddSecurityOrchestrationPolicyConfigurationNamespaceIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - INDEX_NAME = 'partial_index_sop_configs_on_namespace_id' - - def up - add_concurrent_index :security_orchestration_policy_configurations, :namespace_id, unique: true, name: INDEX_NAME, where: 'namespace_id IS NOT NULL' - add_concurrent_foreign_key :security_orchestration_policy_configurations, :namespaces, column: :namespace_id, on_delete: :cascade, reverse_lock_order: true - - add_check_constraint :security_orchestration_policy_configurations, - "((project_id IS NULL) != (namespace_id IS NULL))", - :cop_configs_project_or_namespace_existence - end - - def down - exec_query 'DELETE FROM security_orchestration_policy_configurations WHERE namespace_id IS NOT NULL' - - remove_check_constraint :security_orchestration_policy_configurations, :cop_configs_project_or_namespace_existence - - with_lock_retries do - remove_foreign_key_if_exists :security_orchestration_policy_configurations, column: :namespace_id - end - - remove_concurrent_index_by_name :security_orchestration_policy_configurations, INDEX_NAME - end -end diff --git a/db/migrate/20220301091503_add_not_null_constraint_to_security_policy_configurations.rb b/db/migrate/20220301091503_add_not_null_constraint_to_security_policy_configurations.rb deleted file mode 100644 index 79ffcb2cbb3..00000000000 --- a/db/migrate/20220301091503_add_not_null_constraint_to_security_policy_configurations.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullConstraintToSecurityPolicyConfigurations < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - change_column_null :security_orchestration_policy_configurations, :project_id, true - end - - def down - exec_query 'DELETE FROM security_orchestration_policy_configurations WHERE project_id IS NULL' - change_column_null :security_orchestration_policy_configurations, :project_id, false - end -end diff --git a/db/migrate/20220301175104_change_security_orchestration_policy_configuration_project_index.rb b/db/migrate/20220301175104_change_security_orchestration_policy_configuration_project_index.rb deleted file mode 100644 index 53706d46979..00000000000 --- a/db/migrate/20220301175104_change_security_orchestration_policy_configuration_project_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ChangeSecurityOrchestrationPolicyConfigurationProjectIndex < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - OLD_INDEX_NAME = 'index_sop_configs_on_project_id' - NEW_INDEX_NAME = 'partial_index_sop_configs_on_project_id' - - def up - add_concurrent_index :security_orchestration_policy_configurations, :project_id, unique: true, name: NEW_INDEX_NAME, where: 'project_id IS NOT NULL' - remove_concurrent_index_by_name :security_orchestration_policy_configurations, OLD_INDEX_NAME - end - - def down - add_concurrent_index :security_orchestration_policy_configurations, :project_id, unique: true, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :security_orchestration_policy_configurations, NEW_INDEX_NAME - end -end diff --git a/db/migrate/20220301175426_create_project_build_artifacts_size_refresh.rb b/db/migrate/20220301175426_create_project_build_artifacts_size_refresh.rb deleted file mode 100644 index fd01437d045..00000000000 --- a/db/migrate/20220301175426_create_project_build_artifacts_size_refresh.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class CreateProjectBuildArtifactsSizeRefresh < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - CREATED_STATE = 1 - - def change - create_table :project_build_artifacts_size_refreshes do |t| - t.references :project, index: { unique: true }, foreign_key: { on_delete: :cascade }, null: false - t.bigint :last_job_artifact_id, null: true - t.integer :state, null: false, default: CREATED_STATE, limit: 1 - t.datetime_with_timezone :refresh_started_at, null: true - t.timestamps_with_timezone null: false - - # We will use this index for 2 purposes: - # - for finding rows with state = :waiting - # - for finding rows with state = :running and updated_at < x.days.ago - # which we can use to find jobs that were not able to complete and considered - # stale so we can retry - t.index [:state, :updated_at], name: 'idx_build_artifacts_size_refreshes_state_updated_at' - end - end -end diff --git a/db/migrate/20220302110724_add_group_features_table.rb b/db/migrate/20220302110724_add_group_features_table.rb deleted file mode 100644 index 9d9204afec2..00000000000 --- a/db/migrate/20220302110724_add_group_features_table.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddGroupFeaturesTable < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - create_table :group_features, id: false do |t| - t.references :group, index: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }, null: false - t.timestamps_with_timezone null: false - t.integer :wiki_access_level, default: Featurable::ENABLED, null: false, limit: 2 - end - - execute('ALTER TABLE group_features ADD PRIMARY KEY (group_id)') - end - - def down - drop_table :group_features - end -end diff --git a/db/migrate/20220303190555_add_comment_to_deployment_approvals.rb b/db/migrate/20220303190555_add_comment_to_deployment_approvals.rb deleted file mode 100644 index 56b873c009a..00000000000 --- a/db/migrate/20220303190555_add_comment_to_deployment_approvals.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddCommentToDeploymentApprovals < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220303191047_add_text_limit_to_deployment_approvals_comment - def change - add_column :deployment_approvals, :comment, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20220303191047_add_text_limit_to_deployment_approvals_comment.rb b/db/migrate/20220303191047_add_text_limit_to_deployment_approvals_comment.rb deleted file mode 100644 index 70c7f5f3a7b..00000000000 --- a/db/migrate/20220303191047_add_text_limit_to_deployment_approvals_comment.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToDeploymentApprovalsComment < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :deployment_approvals, :comment, 255 - end - - def down - remove_text_limit :deployment_approvals, :comment - end -end diff --git a/db/migrate/20220304052335_remove_not_null_contraint_on_title_from_sprints.rb b/db/migrate/20220304052335_remove_not_null_contraint_on_title_from_sprints.rb deleted file mode 100644 index f429303ab83..00000000000 --- a/db/migrate/20220304052335_remove_not_null_contraint_on_title_from_sprints.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveNotNullContraintOnTitleFromSprints < Gitlab::Database::Migration[1.0] - enable_lock_retries! - - def up - change_column_null :sprints, :title, true - end - - def down - execute <<~SQL - UPDATE sprints SET title = id WHERE title IS NULL - SQL - - change_column_null :sprints, :title, false - end -end diff --git a/db/migrate/20220304061631_remove_unique_index_for_sprints_on_iterations_cadence_id_and_title.rb b/db/migrate/20220304061631_remove_unique_index_for_sprints_on_iterations_cadence_id_and_title.rb deleted file mode 100644 index 8c223bbce01..00000000000 --- a/db/migrate/20220304061631_remove_unique_index_for_sprints_on_iterations_cadence_id_and_title.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveUniqueIndexForSprintsOnIterationsCadenceIdAndTitle < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_sprints_on_iterations_cadence_id_and_title' - - def up - remove_concurrent_index_by_name :sprints, INDEX_NAME - end - - def down - add_concurrent_index :sprints, [:iterations_cadence_id, :title], name: INDEX_NAME, unique: true - end -end diff --git a/db/migrate/20220304062107_remove_unique_index_for_sprints_on_project_id_and_title.rb b/db/migrate/20220304062107_remove_unique_index_for_sprints_on_project_id_and_title.rb deleted file mode 100644 index 34a357bdc5c..00000000000 --- a/db/migrate/20220304062107_remove_unique_index_for_sprints_on_project_id_and_title.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveUniqueIndexForSprintsOnProjectIdAndTitle < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_sprints_on_project_id_and_title' - - def up - remove_concurrent_index_by_name :sprints, INDEX_NAME - end - - def down - add_concurrent_index :sprints, [:project_id, :title], where: "project_id IS NOT NULL", name: INDEX_NAME, unique: true - end -end diff --git a/db/migrate/20220304152729_add_default_to_required_python_on_packages_pypi_metadata.rb b/db/migrate/20220304152729_add_default_to_required_python_on_packages_pypi_metadata.rb deleted file mode 100644 index 56297565cb4..00000000000 --- a/db/migrate/20220304152729_add_default_to_required_python_on_packages_pypi_metadata.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddDefaultToRequiredPythonOnPackagesPypiMetadata < Gitlab::Database::Migration[1.0] - def up - change_column_default(:packages_pypi_metadata, :required_python, '') - end - - def down - change_column_default(:packages_pypi_metadata, :required_python, nil) - end -end diff --git a/db/migrate/20220307203458_rename_user_email_lookup_limit_setting_to_search_settings.rb b/db/migrate/20220307203458_rename_user_email_lookup_limit_setting_to_search_settings.rb deleted file mode 100644 index 62fe55b22f2..00000000000 --- a/db/migrate/20220307203458_rename_user_email_lookup_limit_setting_to_search_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class RenameUserEmailLookupLimitSettingToSearchSettings < Gitlab::Database::Migration[1.0] - def up - add_column :application_settings, :search_rate_limit, :integer, null: false, default: 30 - add_column :application_settings, :search_rate_limit_unauthenticated, :integer, null: false, default: 10 - end - - def down - remove_column :application_settings, :search_rate_limit - remove_column :application_settings, :search_rate_limit_unauthenticated - end -end diff --git a/db/migrate/20220309100648_add_time_to_restore_service_dora_metric.rb b/db/migrate/20220309100648_add_time_to_restore_service_dora_metric.rb deleted file mode 100644 index 5cb49a9899a..00000000000 --- a/db/migrate/20220309100648_add_time_to_restore_service_dora_metric.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddTimeToRestoreServiceDoraMetric < Gitlab::Database::Migration[1.0] - def change - add_column :dora_daily_metrics, :time_to_restore_service_in_seconds, :integer - end -end diff --git a/db/migrate/20220310011530_add_database_grafana_config_to_application_settings.rb b/db/migrate/20220310011530_add_database_grafana_config_to_application_settings.rb deleted file mode 100644 index 7752fbba12f..00000000000 --- a/db/migrate/20220310011530_add_database_grafana_config_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddDatabaseGrafanaConfigToApplicationSettings < Gitlab::Database::Migration[1.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20220307002607_add_text_limit_to_db_reindexing_grafana_application_settings - def change - add_column :application_settings, :encrypted_database_grafana_api_key, :binary - add_column :application_settings, :encrypted_database_grafana_api_key_iv, :binary - add_column :application_settings, :database_grafana_api_url, :text - add_column :application_settings, :database_grafana_tag, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20220310011613_add_text_limit_to_database_grafana_application_settings.rb b/db/migrate/20220310011613_add_text_limit_to_database_grafana_application_settings.rb deleted file mode 100644 index 72bcf493d6e..00000000000 --- a/db/migrate/20220310011613_add_text_limit_to_database_grafana_application_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToDatabaseGrafanaApplicationSettings < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :application_settings, :database_grafana_api_url, 255 - add_text_limit :application_settings, :database_grafana_tag, 255 - end - - def down - remove_text_limit :application_settings, :database_grafana_tag - remove_text_limit :application_settings, :database_grafana_api_url - end -end diff --git a/db/migrate/20220310101118_update_holder_name_limit.rb b/db/migrate/20220310101118_update_holder_name_limit.rb deleted file mode 100644 index 55eb8f75d70..00000000000 --- a/db/migrate/20220310101118_update_holder_name_limit.rb +++ /dev/null @@ -1,28 +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 UpdateHolderNameLimit < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - def up - add_text_limit :user_credit_card_validations, :holder_name, 50, constraint_name: new_constraint_name - remove_text_limit :user_credit_card_validations, :holder_name, constraint_name: old_constraint_name - end - - def down - add_text_limit :user_credit_card_validations, :holder_name, 26, validate: false, constraint_name: old_constraint_name - remove_text_limit :user_credit_card_validations, :holder_name, constraint_name: new_constraint_name - end - - private - - def old_constraint_name - check_constraint_name(:user_credit_card_validations, :holder_name, 'max_length') - end - - def new_constraint_name - check_constraint_name(:user_credit_card_validations, :holder_name, 'max_length_50') - end -end diff --git a/db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb b/db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb deleted file mode 100644 index 4effdfa6a5e..00000000000 --- a/db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddPackageRegistryAccessLevelIntoProjectFeatures < Gitlab::Database::Migration[1.0] - DISABLED = 0 # ProjectFeature::DISABLED - - def up - add_column :project_features, :package_registry_access_level, :integer, default: DISABLED, null: false - end - - def down - remove_column :project_features, :package_registry_access_level - end -end diff --git a/db/migrate/20220314184009_create_protected_environment_approval_rules.rb b/db/migrate/20220314184009_create_protected_environment_approval_rules.rb deleted file mode 100644 index f0db2c004ed..00000000000 --- a/db/migrate/20220314184009_create_protected_environment_approval_rules.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class CreateProtectedEnvironmentApprovalRules < Gitlab::Database::Migration[1.0] - def up - create_table :protected_environment_approval_rules do |t| - t.references :protected_environment, - index: { name: :index_approval_rule_on_protected_environment_id }, - foreign_key: { to_table: :protected_environments, on_delete: :cascade }, - null: false - - t.bigint :user_id - t.bigint :group_id - t.timestamps_with_timezone null: false - t.integer :access_level, limit: 2 - t.integer :required_approvals, null: false, limit: 2 - - t.index :user_id - t.index :group_id - - t.check_constraint "((access_level IS NOT NULL) AND (group_id IS NULL) AND (user_id IS NULL)) OR " \ - "((user_id IS NOT NULL) AND (access_level IS NULL) AND (group_id IS NULL)) OR " \ - "((group_id IS NOT NULL) AND (user_id IS NULL) AND (access_level IS NULL))" - t.check_constraint "required_approvals > 0" - end - end - - def down - drop_table :protected_environment_approval_rules - end -end diff --git a/db/migrate/20210826171758_init_schema.rb b/db/migrate/20220314184009_init_schema.rb index 971a3e0e2db..97027f8a9e4 100644 --- a/db/migrate/20210826171758_init_schema.rb +++ b/db/migrate/20220314184009_init_schema.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class InitSchema < ActiveRecord::Migration[6.0] +class InitSchema < Gitlab::Database::Migration[1.0] DOWNTIME = false def up diff --git a/db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb b/db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb new file mode 100644 index 00000000000..0e403dac24f --- /dev/null +++ b/db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddRunnerRegistrationEnabledToProjectSettings < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :project_settings, :runner_registration_enabled, :boolean, default: true + end +end diff --git a/db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb b/db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb new file mode 100644 index 00000000000..70c4962d02d --- /dev/null +++ b/db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddDatabaseApdexSettingsToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :database_apdex_settings, :jsonb + end +end diff --git a/db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb b/db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb new file mode 100644 index 00000000000..5d6f4961baf --- /dev/null +++ b/db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddProjectGroupLinkOnDeleteCascadeFk < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key( + :project_group_links, + :namespaces, + column: :group_id, + on_delete: :cascade, + validate: false + ) + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :project_group_links, column: :group_id + end + end +end diff --git a/db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb b/db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb new file mode 100644 index 00000000000..c9668c311a3 --- /dev/null +++ b/db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddCustomJiraRegexToJiraTrackerData < Gitlab::Database::Migration[2.1] + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230222161954_add_text_limit_to_custom_jira_regex_fields.rb + enable_lock_retries! + def change + add_column :jira_tracker_data, :jira_issue_prefix, :text + add_column :jira_tracker_data, :jira_issue_regex, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb b/db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb new file mode 100644 index 00000000000..625655fda9d --- /dev/null +++ b/db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddTextLimitToCustomJiraRegexFields < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :jira_tracker_data, :jira_issue_prefix, 255 + add_text_limit :jira_tracker_data, :jira_issue_regex, 255 + end + + def down + remove_text_limit :jira_tracker_data, :jira_issue_regex + remove_text_limit :jira_tracker_data, :jira_issue_regex + end +end diff --git a/db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb b/db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb new file mode 100644 index 00000000000..5fe2a497077 --- /dev/null +++ b/db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +class AddPartitioningInfoToPostgresForeignKeys < Gitlab::Database::Migration[2.1] + def up + execute <<~SQL + DROP VIEW IF EXISTS postgres_foreign_keys; + CREATE 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, + pg_constraint.convalidated as is_valid, + partitioned_parent_oids.parent_oid as parent_oid + 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) + LEFT JOIN LATERAL ( + SELECT refobjid as parent_oid + FROM pg_depend + WHERE objid = pg_constraint.oid + AND pg_depend.deptype = 'P' + AND refobjid IN (SELECT oid FROM pg_constraint WHERE contype = 'f') + LIMIT 1 + ) partitioned_parent_oids(parent_oid) ON true + WHERE contype = 'f'; + SQL + + Gitlab::Database::PostgresForeignKey.reset_column_information + end + + def down + execute <<~SQL + DROP VIEW IF EXISTS postgres_foreign_keys; + CREATE 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 + + Gitlab::Database::PostgresForeignKey.reset_column_information + end +end diff --git a/db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb b/db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb new file mode 100644 index 00000000000..7d3f4491818 --- /dev/null +++ b/db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddRoleApproversToScanResultPolicies < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :scan_result_policies, :role_approvers, :integer, array: true, default: [] + end +end diff --git a/db/migrate/20230307000000_create_design_management_repository.rb b/db/migrate/20230307000000_create_design_management_repository.rb new file mode 100644 index 00000000000..da4dee9f320 --- /dev/null +++ b/db/migrate/20230307000000_create_design_management_repository.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class CreateDesignManagementRepository < Gitlab::Database::Migration[2.1] + def change + create_table :design_management_repositories do |t| + t.references :project, index: { unique: true }, null: false, foreign_key: { on_delete: :cascade } + + t.timestamps_with_timezone null: false + end + end +end diff --git a/db/migrate/20230307132729_create_schema_inconsistencies.rb b/db/migrate/20230307132729_create_schema_inconsistencies.rb new file mode 100644 index 00000000000..4891cc6ab7b --- /dev/null +++ b/db/migrate/20230307132729_create_schema_inconsistencies.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CreateSchemaInconsistencies < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + create_table :schema_inconsistencies do |t| + t.references :issue, index: true, null: false, foreign_key: { on_delete: :cascade } + t.timestamps_with_timezone null: false + t.text :object_name, null: false, limit: 63 + t.text :table_name, null: false, limit: 63 + t.text :valitador_name, null: false, limit: 63 + end + end +end diff --git a/db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb b/db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb new file mode 100644 index 00000000000..b2e4cc8ceb2 --- /dev/null +++ b/db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class RemoveCreateLearnGitlabWorkerJobInstances < Gitlab::Database::Migration[2.1] + def up + # No-op to fix https://gitlab.com/gitlab-com/gl-infra/production/-/issues/8612 + end + + def down + # No-op to fix https://gitlab.com/gitlab-com/gl-infra/production/-/issues/8612 + end +end diff --git a/db/migrate/20230308154243_add_package_id_to_ml_candidates.rb b/db/migrate/20230308154243_add_package_id_to_ml_candidates.rb new file mode 100644 index 00000000000..ed13ddc894c --- /dev/null +++ b/db/migrate/20230308154243_add_package_id_to_ml_candidates.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddPackageIdToMlCandidates < Gitlab::Database::Migration[2.1] + def change + add_column :ml_candidates, :package_id, :bigint, null: true + end +end diff --git a/db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb b/db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb new file mode 100644 index 00000000000..7f12673e410 --- /dev/null +++ b/db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddPackageIdForeignKeyToMlCandidates < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ml_candidates, :packages_packages, column: :package_id, on_delete: :nullify + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :ml_candidates, column: :package_id + end + end +end diff --git a/db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb b/db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb new file mode 100644 index 00000000000..cb3c9cd5a33 --- /dev/null +++ b/db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddIndexOnPackageIdForMlCandidates < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_ml_candidates_on_package_id' + + def up + add_concurrent_index :ml_candidates, :package_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ml_candidates, name: INDEX_NAME + end +end diff --git a/db/migrate/20230313012226_create_search_indices.rb b/db/migrate/20230313012226_create_search_indices.rb new file mode 100644 index 00000000000..e1ef29be5af --- /dev/null +++ b/db/migrate/20230313012226_create_search_indices.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateSearchIndices < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + create_table :search_indices do |t| + t.timestamps_with_timezone null: false + t.integer :bucket_number # We allow null bucket numbers to support custom index assignments + t.text :path, null: false, limit: 255 + t.text :type, null: false, limit: 255 + end + + add_index :search_indices, [:id, :type], unique: true + add_index :search_indices, [:type, :path], unique: true + add_index :search_indices, [:type, :bucket_number], unique: true + end +end diff --git a/db/migrate/20230313012609_create_search_namespace_index_assignments.rb b/db/migrate/20230313012609_create_search_namespace_index_assignments.rb new file mode 100644 index 00000000000..ea3760ead74 --- /dev/null +++ b/db/migrate/20230313012609_create_search_namespace_index_assignments.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class CreateSearchNamespaceIndexAssignments < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + create_table :search_namespace_index_assignments do |t| + t.references :namespace, foreign_key: true, null: true, on_delete: :nullify + t.bigint :search_index_id, index: true, null: false + t.bigint :namespace_id_non_nullable, null: false + t.timestamps_with_timezone null: false + t.integer :namespace_id_hashed, null: false + t.text :index_type, null: false, limit: 255 + end + + add_index :search_namespace_index_assignments, + [:namespace_id, :index_type], + unique: true, + name: 'index_search_namespace_index_assignments_uniqueness_index_type' + + add_index :search_namespace_index_assignments, + [:namespace_id, :search_index_id], + unique: true, + name: 'index_search_namespace_index_assignments_uniqueness_on_index_id' + end +end diff --git a/db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb b/db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb new file mode 100644 index 00000000000..c49833b01e1 --- /dev/null +++ b/db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddSearchIndexForeignKeyToSearchNamespaceIndexAssignments < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + FK_NAME = 'fk_search_index_id_and_type' + + def up + add_concurrent_foreign_key :search_namespace_index_assignments, :search_indices, + name: FK_NAME, column: [:search_index_id, :index_type], target_column: [:id, :type], on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :search_namespace_index_assignments, name: FK_NAME + end + end +end diff --git a/db/migrate/20230313031351_create_resource_link_events.rb b/db/migrate/20230313031351_create_resource_link_events.rb new file mode 100644 index 00000000000..03f00c9416b --- /dev/null +++ b/db/migrate/20230313031351_create_resource_link_events.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CreateResourceLinkEvents < Gitlab::Database::Migration[2.1] + def change + create_table :resource_link_events do |t| + t.integer :action, limit: 2, null: false + t.bigint :user_id, null: false + t.references :issue, index: true, null: false, foreign_key: { on_delete: :cascade } + t.references :child_work_item, index: true, null: false, foreign_key: { to_table: :issues, on_delete: :cascade } + t.datetime_with_timezone :created_at, null: false + + t.index :user_id + end + end +end diff --git a/db/migrate/20230313181536_create_packages_npm_metadata_caches.rb b/db/migrate/20230313181536_create_packages_npm_metadata_caches.rb new file mode 100644 index 00000000000..fde33342f04 --- /dev/null +++ b/db/migrate/20230313181536_create_packages_npm_metadata_caches.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class CreatePackagesNpmMetadataCaches < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + INDEX_NAME = 'index_npm_metadata_caches_on_package_name_project_id_unique' + + def up + create_table :packages_npm_metadata_caches do |t| + t.timestamps_with_timezone + + t.datetime_with_timezone :last_downloaded_at + t.bigint :project_id, index: true + t.integer :file_store, default: 1 + t.integer :size, null: false + t.text :file, null: false, limit: 255 + t.text :package_name, null: false # rubocop:disable Migration/AddLimitToTextColumns + + t.index %i[package_name project_id], name: INDEX_NAME, unique: true, where: 'project_id IS NOT NULL' + end + end + + def down + drop_table :packages_npm_metadata_caches + end +end diff --git a/db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb b/db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb new file mode 100644 index 00000000000..421878967c4 --- /dev/null +++ b/db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddScreenshotToAbuseReports < Gitlab::Database::Migration[2.1] + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230327074932_add_text_limit_to_abuse_reports_screenshot + def change + add_column :abuse_reports, :screenshot, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb b/db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb new file mode 100644 index 00000000000..f6254cad192 --- /dev/null +++ b/db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class InsertDailyInvitesTrialPlanLimits < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + return unless Gitlab.com? + + create_or_update_plan_limit('daily_invites', 'premium_trial', 50) + create_or_update_plan_limit('daily_invites', 'ultimate_trial', 50) + end + + def down + return unless Gitlab.com? + + create_or_update_plan_limit('daily_invites', 'premium_trial', 0) + create_or_update_plan_limit('daily_invites', 'ultimate_trial', 0) + end +end diff --git a/db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb b/db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb new file mode 100644 index 00000000000..c0537a1985d --- /dev/null +++ b/db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class CreateServiceDeskCustomEmailCredentials < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + create_table(:service_desk_custom_email_credentials, id: false) do |t| + t.references :project, + primary_key: true, + default: nil, + index: false, + foreign_key: { to_table: :projects, on_delete: :cascade } + t.timestamps_with_timezone + t.integer :smtp_port + t.text :smtp_address, limit: 255 + t.binary :encrypted_smtp_username + t.binary :encrypted_smtp_username_iv + t.binary :encrypted_smtp_password + t.binary :encrypted_smtp_password_iv + end + end +end diff --git a/db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb b/db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb new file mode 100644 index 00000000000..4ed1fd6869c --- /dev/null +++ b/db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +class AddCurrentUserTodosWorkItemWidget < 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! + + WIDGET_NAME = 'Current user todos' + WIDGET_ENUM_VALUE = 15 + WORK_ITEM_TYPES = [ + 'Issue', + 'Incident', + 'Test Case', + 'Requirement', + 'Task', + 'Objective', + 'Key Result' + ].freeze + + def up + widgets = [] + + WORK_ITEM_TYPES.each do |type_name| + type = WorkItemType.find_by_name_and_namespace_id(type_name, nil) + + unless type + Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widget") + + next + end + + widgets << { + work_item_type_id: type.id, + name: WIDGET_NAME, + widget_type: WIDGET_ENUM_VALUE + } + 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.where(name: WIDGET_NAME).delete_all + end +end diff --git a/db/migrate/20230321085011_add_column_to_users_statistisc.rb b/db/migrate/20230321085011_add_column_to_users_statistisc.rb new file mode 100644 index 00000000000..8eef2ff5765 --- /dev/null +++ b/db/migrate/20230321085011_add_column_to_users_statistisc.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddColumnToUsersStatistisc < Gitlab::Database::Migration[2.1] + def change + add_column :users_statistics, :with_highest_role_guest_with_custom_role, :integer, default: 0, null: false + end +end diff --git a/db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb b/db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb new file mode 100644 index 00000000000..66a24dc73c4 --- /dev/null +++ b/db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AddIndexesToMergeRequestComplianceViolations < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_SEVERITY_LEVEL_DESC = 'i_compliance_violations_on_project_id_severity_and_id' + INDEX_REASON_ASC = 'i_compliance_violations_on_project_id_reason_and_id' + INDEX_TITLE_ASC = 'i_compliance_violations_on_project_id_title_and_id' + INDEX_MERGED_AT_ASC = 'i_compliance_violations_on_project_id_merged_at_and_id' + + def up + add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :severity_level, :id], + order: { severity_level: :desc, id: :desc }, using: :btree, name: INDEX_SEVERITY_LEVEL_DESC + add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :reason, :id], + order: { reason: :asc, id: :asc }, using: :btree, name: INDEX_REASON_ASC + add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :title, :id], + order: { title: :asc, id: :asc }, using: :btree, name: INDEX_TITLE_ASC + add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :merged_at, :id], + order: { merged_at: :asc, id: :asc }, using: :btree, name: INDEX_MERGED_AT_ASC + end + + def down + remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_TITLE_ASC + remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_TITLE_ASC + remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_SEVERITY_LEVEL_DESC + remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_REASON_ASC + remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_MERGED_AT_ASC + end +end diff --git a/db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb b/db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb new file mode 100644 index 00000000000..2e884e92aa7 --- /dev/null +++ b/db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RenameMlCandidatesIidToEid < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + rename_column_concurrently :ml_candidates, :iid, :eid + end + + def down + undo_rename_column_concurrently :ml_candidates, :iid, :eid + end +end diff --git a/db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb b/db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb new file mode 100644 index 00000000000..5f9400b9498 --- /dev/null +++ b/db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddProjectAccessTokenLimitToPlanLimits < Gitlab::Database::Migration[2.1] + def change + add_column(:plan_limits, :project_access_token_limit, :integer, default: 0, null: false) + end +end diff --git a/db/migrate/20230321161441_insert_project_access_token_limit.rb b/db/migrate/20230321161441_insert_project_access_token_limit.rb new file mode 100644 index 00000000000..a449e6f8e7c --- /dev/null +++ b/db/migrate/20230321161441_insert_project_access_token_limit.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class InsertProjectAccessTokenLimit < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + create_or_update_plan_limit('project_access_token_limit', 'premium_trial', 1) + create_or_update_plan_limit('project_access_token_limit', 'ultimate_trial', 1) + end + + def down + create_or_update_plan_limit('project_access_token_limit', 'premium_trial', 0) + create_or_update_plan_limit('project_access_token_limit', 'ultimate_trial', 0) + end +end diff --git a/db/migrate/20230321162810_add_project_id_to_ml_candidates.rb b/db/migrate/20230321162810_add_project_id_to_ml_candidates.rb new file mode 100644 index 00000000000..a8121f197d9 --- /dev/null +++ b/db/migrate/20230321162810_add_project_id_to_ml_candidates.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddProjectIdToMlCandidates < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :ml_candidates, :project_id, :bigint, null: true + end +end diff --git a/db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb b/db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb new file mode 100644 index 00000000000..e6c08468c0c --- /dev/null +++ b/db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddIndexOnProjectIdOnMlCandidates < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_ml_candidates_on_project_id' + + def up + add_concurrent_index :ml_candidates, :project_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ml_candidates, INDEX_NAME + end +end diff --git a/db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb b/db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb new file mode 100644 index 00000000000..3e43a160306 --- /dev/null +++ b/db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddProjectIdForeignKeyToMlCandidates < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ml_candidates, :projects, column: :project_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :ml_candidates, column: :project_id + end + end +end diff --git a/db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb b/db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb new file mode 100644 index 00000000000..f6ced91c0a8 --- /dev/null +++ b/db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddInternalIdToMlCandidates < Gitlab::Database::Migration[2.1] + def change + add_column :ml_candidates, :internal_id, :bigint, null: true + end +end diff --git a/db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb b/db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb new file mode 100644 index 00000000000..4c295972106 --- /dev/null +++ b/db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddIndexOnProjectIdOnInternalIdToMlCandidates < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_ml_candidates_on_project_id_on_internal_id' + + def up + add_concurrent_index :ml_candidates, [:project_id, :internal_id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ml_candidates, INDEX_NAME + end +end diff --git a/db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb b/db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb new file mode 100644 index 00000000000..7c542279bd0 --- /dev/null +++ b/db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddProjectIdForeignKeyToPackagesNpmMetadataCaches < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + SOURCE_TABLE = :packages_npm_metadata_caches + TARGET_TABLE = :projects + COLUMN = :project_id + + def up + add_concurrent_foreign_key SOURCE_TABLE, TARGET_TABLE, column: COLUMN, on_delete: :nullify + end + + def down + with_lock_retries do + remove_foreign_key SOURCE_TABLE, column: COLUMN + end + end +end diff --git a/db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb b/db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb new file mode 100644 index 00000000000..e140ecc58c7 --- /dev/null +++ b/db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class RerunRemoveInvalidDeployAccessLevel < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + # clean up any rows with invalid access_level entries + def up + update_column_in_batches(:protected_environment_deploy_access_levels, :access_level, nil) do |table, query| + query.where( + table.grouping(table[:user_id].not_eq(nil).or(table[:group_id].not_eq(nil))) + .and(table[:access_level].not_eq(nil))) + end + + update_column_in_batches(:protected_environment_deploy_access_levels, :group_id, nil) do |table, query| + query.where(table[:user_id].not_eq(nil).and(table[:group_id].not_eq(nil))) + end + end + + def down + # no-op + + # we are setting access_level to NULL if group_id or user_id are present + end +end diff --git a/db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb b/db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb new file mode 100644 index 00000000000..4cf82375563 --- /dev/null +++ b/db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddValidDeployAccessLevelConstraint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + CONSTRAINT_NAME = 'check_deploy_access_levels_user_group_access_level_any_not_null' + CONSTRAINT = '(num_nonnulls(user_id, group_id, access_level) = 1)' + + def up + add_check_constraint :protected_environment_deploy_access_levels, CONSTRAINT, CONSTRAINT_NAME + end + + def down + remove_check_constraint :protected_environment_deploy_access_levels, CONSTRAINT_NAME + end +end diff --git a/db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb b/db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb new file mode 100644 index 00000000000..e3592e0bd13 --- /dev/null +++ b/db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSilentModeEnabledToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :silent_mode_enabled, :boolean, default: false, null: false, if_not_exists: true + end +end diff --git a/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb b/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb new file mode 100644 index 00000000000..6a6b50c81a5 --- /dev/null +++ b/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +class AddAwardEmojiWorkItemWidget < 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! + + WIDGET_NAME = 'Award emoji' + WIDGET_ENUM_VALUE = 16 + WORK_ITEM_TYPES = [ + 'Issue', + 'Incident', + 'Test Case', + 'Requirement', + 'Task', + 'Objective', + 'Key Result' + ].freeze + + def up + widgets = [] + + WORK_ITEM_TYPES.each do |type_name| + type = WorkItemType.find_by_name_and_namespace_id(type_name, nil) + + unless type + Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widget") + + next + end + + widgets << { + work_item_type_id: type.id, + name: WIDGET_NAME, + widget_type: WIDGET_ENUM_VALUE + } + 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.where(name: WIDGET_NAME).delete_all + end +end diff --git a/db/migrate/20230323120601_create_dora_performance_scores.rb b/db/migrate/20230323120601_create_dora_performance_scores.rb new file mode 100644 index 00000000000..2c4304fedb6 --- /dev/null +++ b/db/migrate/20230323120601_create_dora_performance_scores.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateDoraPerformanceScores < Gitlab::Database::Migration[2.1] + def change + create_table :dora_performance_scores do |t| + t.references :project, null: false, foreign_key: { on_delete: :cascade }, index: false + t.date :date, null: false + t.integer :deployment_frequency, limit: 2 + t.integer :lead_time_for_changes, limit: 2 + t.integer :time_to_restore_service, limit: 2 + t.integer :change_failure_rate, limit: 2 + + t.index [:project_id, :date], unique: true + end + end +end diff --git a/db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb b/db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb new file mode 100644 index 00000000000..781ba3e89d4 --- /dev/null +++ b/db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddRootDirectoryToPagesDeployment < Gitlab::Database::Migration[2.1] + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230323140746_add_text_limit_to_pages_deployment_root_directory + def change + add_column :pages_deployments, :root_directory, :text, default: "public" + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb b/db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb new file mode 100644 index 00000000000..12209422fbb --- /dev/null +++ b/db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToPagesDeploymentRootDirectory < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :pages_deployments, :root_directory, 255 + end + + def down + remove_text_limit :pages_deployments, :root_directory + end +end diff --git a/db/migrate/20230323153042_track_push_rules_deletions.rb b/db/migrate/20230323153042_track_push_rules_deletions.rb new file mode 100644 index 00000000000..2aa7fad8de1 --- /dev/null +++ b/db/migrate/20230323153042_track_push_rules_deletions.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class TrackPushRulesDeletions < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers + + enable_lock_retries! + + def up + track_record_deletions(:push_rules) + end + + def down + untrack_record_deletions(:push_rules) + end +end diff --git a/db/migrate/20230323153328_track_tags_deletions.rb b/db/migrate/20230323153328_track_tags_deletions.rb new file mode 100644 index 00000000000..085d14a56fa --- /dev/null +++ b/db/migrate/20230323153328_track_tags_deletions.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class TrackTagsDeletions < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers + + enable_lock_retries! + + def up + track_record_deletions(:tags) + end + + def down + untrack_record_deletions(:tags) + end +end diff --git a/db/migrate/20230323191750_add_shard_settings_to_search_indices.rb b/db/migrate/20230323191750_add_shard_settings_to_search_indices.rb new file mode 100644 index 00000000000..b032e3b8a61 --- /dev/null +++ b/db/migrate/20230323191750_add_shard_settings_to_search_indices.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddShardSettingsToSearchIndices < Gitlab::Database::Migration[2.1] + def change + add_column :search_indices, :number_of_shards, :integer, default: 2, null: false + add_column :search_indices, :number_of_replicas, :integer, default: 1, null: false + end +end diff --git a/db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb b/db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb new file mode 100644 index 00000000000..3bb9722188f --- /dev/null +++ b/db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToAbuseReportsScreenshot < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :abuse_reports, :screenshot, 255 + end + + def down + remove_text_limit :abuse_reports, :screenshot + end +end diff --git a/db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb b/db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb new file mode 100644 index 00000000000..04041d78c3e --- /dev/null +++ b/db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class BackfillProductAnalyticsDataCollectorHost < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + # fills product_analytics_data_collector_host by replacing jitsu_host subdomain with collector + regex = "'://(.+?\\.)'" + replace_with = "'://collector.'" + execute <<~SQL + UPDATE application_settings + SET product_analytics_data_collector_host = regexp_replace(jitsu_host, #{regex}, #{replace_with}, 'g') + WHERE jitsu_host IS NOT NULL AND product_analytics_data_collector_host IS NULL + SQL + end + + def down + # noop + end +end diff --git a/db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb b/db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb new file mode 100644 index 00000000000..eac1d4e30c1 --- /dev/null +++ b/db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class DeleteUnusedIndexOnMergeRequestsOnStateIdAndMergeStatus < Gitlab::Database::Migration[2.1] + # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/402491 + + def up + prepare_async_index_removal :merge_requests, [:state_id, :merge_status], + where: "((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))", + name: 'idx_merge_requests_on_state_id_and_merge_status' + end + + def down + unprepare_async_index :merge_requests, [:state_id, :merge_status], + where: "((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))", + name: 'idx_merge_requests_on_state_id_and_merge_status' + end +end diff --git a/db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb b/db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb new file mode 100644 index 00000000000..00bccb5cde2 --- /dev/null +++ b/db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfAwardEmojiAwardableIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :award_emoji + COLUMNS = %i[awardable_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/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb b/db/migrate/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb new file mode 100644 index 00000000000..b30b681f42d --- /dev/null +++ b/db/migrate/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfEventsTargetIdToBigint < Gitlab::Database::Migration[2.1] + TABLE = :events + COLUMNS = %i[target_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/20230329032129_add_lock_version_to_terraform_state.rb b/db/migrate/20230329032129_add_lock_version_to_terraform_state.rb new file mode 100644 index 00000000000..78f0122c609 --- /dev/null +++ b/db/migrate/20230329032129_add_lock_version_to_terraform_state.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddLockVersionToTerraformState < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :terraform_states, :activerecord_lock_version, :integer, null: false, default: 0 + end +end diff --git a/db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb b/db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb new file mode 100644 index 00000000000..6a167f232ae --- /dev/null +++ b/db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddForeignKeyToResourceLinkEventsOnUser < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :resource_link_events, :users, column: :user_id, on_delete: :nullify, validate: true + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :resource_link_events, column: :user_id + end + end +end diff --git a/db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb b/db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb new file mode 100644 index 00000000000..bd11a4a6128 --- /dev/null +++ b/db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddAchievementsEnabledToUserPreferences < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :user_preferences, :achievements_enabled, :boolean, default: true, null: false + end +end diff --git a/db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb b/db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb new file mode 100644 index 00000000000..9b87f1319f3 --- /dev/null +++ b/db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexPackagesDebianFileMetadataWhenUnknown < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'i_pkgs_deb_file_meta_on_updated_at_package_file_id_when_unknown' + UNKNOWN = 1 + + def up + add_concurrent_index :packages_debian_file_metadata, [:updated_at, :package_file_id], + where: "file_type = #{UNKNOWN}", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :packages_debian_file_metadata, name: INDEX_NAME + end +end diff --git a/db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb b/db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb new file mode 100644 index 00000000000..8273ffc27e2 --- /dev/null +++ b/db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CreateFkMlCandidateParamsOnCandidateId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + NEW_CONSTRAINT_NAME = 'fk_ml_candidate_params_on_candidate_id' + + def up + add_concurrent_foreign_key( + :ml_candidate_params, + :ml_candidates, + column: :candidate_id, + on_delete: :cascade, + validate: false, + name: NEW_CONSTRAINT_NAME + ) + end + + def down + with_lock_retries do + remove_foreign_key_if_exists( + :ml_candidate_params, + column: :candidate_id, + on_delete: :cascade, + name: NEW_CONSTRAINT_NAME + ) + end + end +end diff --git a/db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb b/db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb new file mode 100644 index 00000000000..912380ac3b7 --- /dev/null +++ b/db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ValidateFkMlCandidateParamsOnCandidateId < Gitlab::Database::Migration[2.1] + NEW_CONSTRAINT_NAME = 'fk_ml_candidate_params_on_candidate_id' + + def up + validate_foreign_key(:ml_candidate_params, :candidate_id, name: NEW_CONSTRAINT_NAME) + end + + def down + # no-op + end +end diff --git a/db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb b/db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb new file mode 100644 index 00000000000..8e143cd3ed2 --- /dev/null +++ b/db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveOldFkMlCandidateParamsOnCandidateId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + OLD_CONSTRAINT_NAME = 'fk_rails_d4a51d1185' + + def up + remove_foreign_key_if_exists(:ml_candidate_params, column: :candidate_id, name: OLD_CONSTRAINT_NAME) + end + + def down + add_concurrent_foreign_key( + :ml_candidate_params, + :ml_candidates, + column: :candidate_id, + validate: false, + name: OLD_CONSTRAINT_NAME + ) + end +end diff --git a/db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb b/db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb new file mode 100644 index 00000000000..0ef0075127d --- /dev/null +++ b/db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CreateFkMlCandidateMetricsOnCandidateId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + NEW_CONSTRAINT_NAME = 'fk_ml_candidate_metrics_on_candidate_id' + + def up + add_concurrent_foreign_key( + :ml_candidate_metrics, + :ml_candidates, + column: :candidate_id, + on_delete: :cascade, + validate: false, + name: NEW_CONSTRAINT_NAME + ) + end + + def down + with_lock_retries do + remove_foreign_key_if_exists( + :ml_candidate_metrics, + column: :candidate_id, + on_delete: :cascade, + name: NEW_CONSTRAINT_NAME + ) + end + end +end diff --git a/db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb b/db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb new file mode 100644 index 00000000000..5180c6582cf --- /dev/null +++ b/db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ValidateFkMlCandidateMetricsOnCandidateId < Gitlab::Database::Migration[2.1] + NEW_CONSTRAINT_NAME = 'fk_ml_candidate_metrics_on_candidate_id' + + def up + validate_foreign_key(:ml_candidate_metrics, :candidate_id, name: NEW_CONSTRAINT_NAME) + end + + def down + # no-op + end +end diff --git a/db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb b/db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb new file mode 100644 index 00000000000..2e9153cb9d9 --- /dev/null +++ b/db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveOldFkMlCandidateMetricsOnCandidateId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + OLD_CONSTRAINT_NAME = 'fk_rails_efb613a25a' + + def up + remove_foreign_key_if_exists(:ml_candidate_metrics, column: :candidate_id, name: OLD_CONSTRAINT_NAME) + end + + def down + add_concurrent_foreign_key( + :ml_candidate_metrics, + :ml_candidates, + column: :candidate_id, + validate: false, + name: OLD_CONSTRAINT_NAME + ) + end +end diff --git a/db/migrate/20230330215636_remove_unused_project_jira_indexes.rb b/db/migrate/20230330215636_remove_unused_project_jira_indexes.rb new file mode 100644 index 00000000000..ce10b70f81c --- /dev/null +++ b/db/migrate/20230330215636_remove_unused_project_jira_indexes.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class RemoveUnusedProjectJiraIndexes < Gitlab::Database::Migration[2.1] + TITLE_INDEX = { + name: 'index_merge_requests_on_target_project_id_and_iid_jira_title', + where: "((title)::text ~ '[A-Z][A-Z_0-9]+-\d+'::text)" + }.freeze + + DESCRIPTION_INDEX = { + name: 'index_merge_requests_on_target_project_id_iid_jira_description', + where: "(description ~ '[A-Z][A-Z_0-9]+-\d+'::text)" + }.freeze + + # TODO: Indexes to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/403327 + def up + prepare_async_index_removal :merge_requests, [:target_project_id, :iid], + where: TITLE_INDEX[:where], + name: TITLE_INDEX[:name] + + prepare_async_index_removal :merge_requests, [:target_project_id, :iid], + where: DESCRIPTION_INDEX[:where], + name: DESCRIPTION_INDEX[:name] + end + + def down + unprepare_async_index :merge_requests, [:target_project_id, :iid], + where: TITLE_INDEX[:where], + name: TITLE_INDEX[:name] + + unprepare_async_index :merge_requests, [:target_project_id, :iid], + where: DESCRIPTION_INDEX[:where], + name: DESCRIPTION_INDEX[:name] + end +end diff --git a/db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb b/db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb new file mode 100644 index 00000000000..735cb414c99 --- /dev/null +++ b/db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddOpenAiApiKeyApplicationSetting < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :encrypted_openai_api_key, :binary + add_column :application_settings, :encrypted_openai_api_key_iv, :binary + end +end diff --git a/db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb b/db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb new file mode 100644 index 00000000000..136855403f9 --- /dev/null +++ b/db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddDatabaseMaxRunningBatchedBackgroundMigrationsToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :database_max_running_batched_background_migrations, + :integer, null: false, default: 2 + end +end diff --git a/db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb b/db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb new file mode 100644 index 00000000000..6e8d423e679 --- /dev/null +++ b/db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class SetMaxRunningBatchedBackgroundMigrationsForGitlabCom < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + return unless Gitlab.com? && !Gitlab.jh? + + execute 'UPDATE application_settings SET database_max_running_batched_background_migrations = 4' + end + + def down + return unless Gitlab.com? && !Gitlab.jh? + + execute 'UPDATE application_settings SET database_max_running_batched_background_migrations = 2' + end +end diff --git a/db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb b/db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb new file mode 100644 index 00000000000..8f7509db318 --- /dev/null +++ b/db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddPinnedNavItemsToUserPreference < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :user_preferences, :pinned_nav_items, :jsonb, null: false, default: {} + end +end diff --git a/db/migrate/20230403145705_add_purl_sync_to_settings.rb b/db/migrate/20230403145705_add_purl_sync_to_settings.rb new file mode 100644 index 00000000000..3bc9ce07235 --- /dev/null +++ b/db/migrate/20230403145705_add_purl_sync_to_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddPurlSyncToSettings < Gitlab::Database::Migration[2.1] + def change + add_column :application_settings, :package_metadata_purl_types, :smallint, array: true, default: [] + end +end diff --git a/db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb b/db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb new file mode 100644 index 00000000000..3428fba669f --- /dev/null +++ b/db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddForkStorageSizeColumnsToRootStorageStatistics < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :namespace_root_storage_statistics, :public_forks_storage_size, :bigint, default: 0, null: false + add_column :namespace_root_storage_statistics, :internal_forks_storage_size, :bigint, default: 0, null: false + add_column :namespace_root_storage_statistics, :private_forks_storage_size, :bigint, default: 0, null: false + end +end diff --git a/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb b/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb new file mode 100644 index 00000000000..d732fb35ce9 --- /dev/null +++ b/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddUniqueNamespaceIndexToStorageLimitExclusions < Gitlab::Database::Migration[2.1] + TABLE_NAME = 'namespaces_storage_limit_exclusions' + OLD_INDEX_NAME = 'index_namespaces_storage_limit_exclusions_on_namespace_id' + NEW_INDEX_NAME = 'unique_idx_namespaces_storage_limit_exclusions_on_namespace_id' + + disable_ddl_transaction! + + def up + add_concurrent_index TABLE_NAME, :namespace_id, + unique: true, + name: NEW_INDEX_NAME + + remove_concurrent_index_by_name TABLE_NAME, OLD_INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :namespace_id, + unique: false, + name: OLD_INDEX_NAME + + remove_concurrent_index_by_name TABLE_NAME, NEW_INDEX_NAME + end +end diff --git a/db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb b/db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb new file mode 100644 index 00000000000..042e588a5f5 --- /dev/null +++ b/db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSystemNoteMetadataIdToResourceLinkEvents < Gitlab::Database::Migration[2.1] + def change + add_column :resource_link_events, :system_note_metadata_id, :bigint + end +end diff --git a/db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb b/db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb new file mode 100644 index 00000000000..97d2e89c80b --- /dev/null +++ b/db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddUniqueIndexToResourceLinkEventsOnSystemNoteMetadataId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'unique_index_on_system_note_metadata_id' + + def up + add_concurrent_index :resource_link_events, :system_note_metadata_id, unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :resource_link_events, name: INDEX_NAME + end +end diff --git a/db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb b/db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb new file mode 100644 index 00000000000..431e7ac0e7e --- /dev/null +++ b/db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddSystemNoteMetadataForeignKeyToResourceLinkEvents < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :resource_link_events, :system_note_metadata, + column: :system_note_metadata_id, on_delete: :cascade, validate: false + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :resource_link_events, column: :system_note_metadata_id + end + end +end diff --git a/db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb b/db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb new file mode 100644 index 00000000000..4347d13ceb4 --- /dev/null +++ b/db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateInstanceExternalAuditEventDestinations < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + create_table :audit_events_instance_external_audit_event_destinations do |t| + t.timestamps_with_timezone null: false + t.text :destination_url, null: false, limit: 255 # rubocop:disable Migration/AddLimitToTextColumns + t.binary :encrypted_verification_token, null: false + t.binary :encrypted_verification_token_iv, null: false + end + end +end diff --git a/db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb b/db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb new file mode 100644 index 00000000000..f06657ccabc --- /dev/null +++ b/db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class ValidateForeignKeyForResourceLinkEventsOnSystemNoteMetadataId < Gitlab::Database::Migration[2.1] + def up + validate_foreign_key :resource_link_events, :system_note_metadata_id + end + + def down + # No-op + end +end diff --git a/db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb b/db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb new file mode 100644 index 00000000000..b6b33cdf17b --- /dev/null +++ b/db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddPaConfiguratorBaseToAppSettings < Gitlab::Database::Migration[2.1] + def up + add_column :application_settings, :encrypted_product_analytics_configurator_connection_string, :binary + add_column :application_settings, :encrypted_product_analytics_configurator_connection_string_iv, :binary + end + + def down + remove_column :application_settings, :encrypted_product_analytics_configurator_connection_string + remove_column :application_settings, :encrypted_product_analytics_configurator_connection_string_iv + end +end diff --git a/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb b/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb new file mode 100644 index 00000000000..0b7fcceb3ee --- /dev/null +++ b/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddIdentityToggleToUserPreferences < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :user_preferences, :pass_user_identities_to_ci_jwt, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb b/db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb new file mode 100644 index 00000000000..1adc3bb001a --- /dev/null +++ b/db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CreateAgentUserAccessProjectAuthorizationsTable < Gitlab::Database::Migration[2.1] + INDEX_NAME_1 = 'index_agent_user_access_on_project_id' + INDEX_NAME_2 = 'index_agent_user_access_on_agent_id_and_project_id' + + def change + create_table :agent_user_access_project_authorizations do |t| + t.bigint :project_id, null: false + t.bigint :agent_id, null: false + t.jsonb :config, null: false + + t.index [:project_id], name: INDEX_NAME_1 + t.index [:agent_id, :project_id], unique: true, name: INDEX_NAME_2 + end + end +end diff --git a/db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb b/db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb new file mode 100644 index 00000000000..1d4df7d7330 --- /dev/null +++ b/db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CreateAgentUserAccessGroupAuthorizationsTable < Gitlab::Database::Migration[2.1] + INDEX_NAME_1 = 'index_agent_user_access_on_group_id' + INDEX_NAME_2 = 'index_agent_user_access_on_agent_id_and_group_id' + + def change + create_table :agent_user_access_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], name: INDEX_NAME_1 + t.index [:agent_id, :group_id], unique: true, name: INDEX_NAME_2 + end + end +end diff --git a/db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb b/db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb new file mode 100644 index 00000000000..62f00620108 --- /dev/null +++ b/db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class AddFksToAgentUserAccessAuthorizations < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :agent_user_access_project_authorizations, :projects, + column: :project_id, on_delete: :cascade + add_concurrent_foreign_key :agent_user_access_project_authorizations, :cluster_agents, + column: :agent_id, on_delete: :cascade + add_concurrent_foreign_key :agent_user_access_group_authorizations, :namespaces, + column: :group_id, on_delete: :cascade + add_concurrent_foreign_key :agent_user_access_group_authorizations, :cluster_agents, + column: :agent_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :agent_user_access_project_authorizations, column: :project_id + end + + with_lock_retries do + remove_foreign_key_if_exists :agent_user_access_project_authorizations, column: :agent_id + end + + with_lock_retries do + remove_foreign_key_if_exists :agent_user_access_group_authorizations, column: :group_id + end + + with_lock_retries do + remove_foreign_key_if_exists :agent_user_access_group_authorizations, column: :agent_id + end + end +end diff --git a/db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb b/db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb new file mode 100644 index 00000000000..ce500fec2f0 --- /dev/null +++ b/db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddCodeSuggestionsToNamespaceSettings < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :namespace_settings, :code_suggestions, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb b/db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb new file mode 100644 index 00000000000..eaaddef083c --- /dev/null +++ b/db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddProductAnalyticsInstrumentationKeyToProjectSettings < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb + def up + with_lock_retries do + add_column :project_settings, :product_analytics_instrumentation_key, :text unless + column_exists?(:project_settings, :product_analytics_instrumentation_key) + end + end + + def down + with_lock_retries do + remove_column :project_settings, :product_analytics_instrumentation_key + end + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230411171001_create_abuse_trust_scores.rb b/db/migrate/20230411171001_create_abuse_trust_scores.rb new file mode 100644 index 00000000000..2c95a2ab01e --- /dev/null +++ b/db/migrate/20230411171001_create_abuse_trust_scores.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateAbuseTrustScores < Gitlab::Database::Migration[2.1] + def change + create_table :abuse_trust_scores do |t| + t.belongs_to :user, foreign_key: { to_table: :users, on_delete: :cascade }, index: false + + t.float :score, null: false + t.timestamps_with_timezone null: false + t.integer :source, limit: 2, null: false + t.text :correlation_id_value, limit: 32 + + t.index [:user_id, :source, :created_at] + end + end +end diff --git a/db/migrate/20230412073614_create_issue_assignment_events.rb b/db/migrate/20230412073614_create_issue_assignment_events.rb new file mode 100644 index 00000000000..1b57c59eb2b --- /dev/null +++ b/db/migrate/20230412073614_create_issue_assignment_events.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateIssueAssignmentEvents < Gitlab::Database::Migration[2.1] + def change + create_table :issue_assignment_events do |t| + t.references :user, null: true, index: true, foreign_key: { on_delete: :nullify } + t.bigint :issue_id, null: false + t.datetime_with_timezone :created_at, null: false, default: -> { 'NOW()' } + t.integer :action, limit: 2, null: false, default: 1 + + t.index %i[issue_id action created_at id], name: 'index_on_issue_assignment_events_issue_id_action_created_at_id' + end + end +end diff --git a/db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb b/db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb new file mode 100644 index 00000000000..3bff98c6e69 --- /dev/null +++ b/db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddConcurrentFkToIssueAssignmentEvents < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :issue_assignment_events, + :issues, + column: :issue_id, + on_delete: :cascade + end + + def down + remove_foreign_key_if_exists :resource_assignment_events, column: :issue_id + end +end diff --git a/db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb b/db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb new file mode 100644 index 00000000000..18bf8640a45 --- /dev/null +++ b/db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddCiJobArtifactsFileFinalPath < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in db/post_migrate/20230412152538_add_text_limit_to_ci_job_artifacts_file_final_path.rb + def change + add_column :ci_job_artifacts, :file_final_path, :text, null: true + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230413080906_create_merge_request_assignment_events.rb b/db/migrate/20230413080906_create_merge_request_assignment_events.rb new file mode 100644 index 00000000000..b976dc8935a --- /dev/null +++ b/db/migrate/20230413080906_create_merge_request_assignment_events.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CreateMergeRequestAssignmentEvents < Gitlab::Database::Migration[2.1] + def change + create_table :merge_request_assignment_events do |t| + t.references :user, null: true, index: true, foreign_key: { on_delete: :nullify } + t.bigint :merge_request_id, null: false + t.datetime_with_timezone :created_at, null: false, default: -> { 'NOW()' } + t.integer :action, limit: 2, null: false, default: 1 + + t.index %i[merge_request_id action created_at id], + name: 'index_on_mr_assignment_events_mr_id_action_created_at_id' + end + end +end diff --git a/db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb b/db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb new file mode 100644 index 00000000000..5b7d08a3547 --- /dev/null +++ b/db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddConcurrentFkToMergeRequestAssignmentEvents < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :merge_request_assignment_events, + :merge_requests, + column: :merge_request_id, + on_delete: :cascade + end + + def down + remove_foreign_key_if_exists :merge_request_assignment_events, column: :merge_request_id + end +end diff --git a/db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb b/db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb new file mode 100644 index 00000000000..7ec0a800066 --- /dev/null +++ b/db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitToProjectSettingsInstrumentationKey < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :project_settings, :product_analytics_instrumentation_key, 255 + end + + def down + remove_text_limit :project_settings, :product_analytics_instrumentation_key + end +end |