diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /db/migrate | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'db/migrate')
188 files changed, 628 insertions, 3066 deletions
diff --git a/db/migrate/20201211145950_add_bloat_estimate_to_reindex_action.rb b/db/migrate/20201211145950_add_bloat_estimate_to_reindex_action.rb deleted file mode 100644 index 894cee92284..00000000000 --- a/db/migrate/20201211145950_add_bloat_estimate_to_reindex_action.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddBloatEstimateToReindexAction < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :postgres_reindex_actions, :bloat_estimate_bytes_start, :bigint - end -end diff --git a/db/migrate/20201214000000_change_mr_allow_maintainer_to_push_default.rb b/db/migrate/20201214000000_change_mr_allow_maintainer_to_push_default.rb deleted file mode 100644 index 47eec16807b..00000000000 --- a/db/migrate/20201214000000_change_mr_allow_maintainer_to_push_default.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class ChangeMrAllowMaintainerToPushDefault < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - change_column_default :merge_requests, :allow_maintainer_to_push, from: nil, to: true - end - end - - def down - with_lock_retries do - change_column_default :merge_requests, :allow_maintainer_to_push, from: true, to: nil - end - end -end diff --git a/db/migrate/20201214032220_add_has_external_wiki_trigger.rb b/db/migrate/20201214032220_add_has_external_wiki_trigger.rb deleted file mode 100644 index c77b887d509..00000000000 --- a/db/migrate/20201214032220_add_has_external_wiki_trigger.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -class AddHasExternalWikiTrigger < ActiveRecord::Migration[6.0] - include Gitlab::Database::SchemaHelpers - - DOWNTIME = false - FUNCTION_NAME = 'set_has_external_wiki' - TRIGGER_ON_INSERT_NAME = 'trigger_has_external_wiki_on_insert' - TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_wiki_on_update' - TRIGGER_ON_DELETE_NAME = 'trigger_has_external_wiki_on_delete' - - def up - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE projects SET has_external_wiki = COALESCE(NEW.active, FALSE) - WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id); - RETURN NULL; - SQL - end - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME} - AFTER INSERT ON services - FOR EACH ROW - WHEN (NEW.active = TRUE AND NEW.type = 'ExternalWikiService' AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_UPDATE_NAME} - AFTER UPDATE ON services - FOR EACH ROW - WHEN (NEW.type = 'ExternalWikiService' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_DELETE_NAME} - AFTER DELETE ON services - FOR EACH ROW - WHEN (OLD.type = 'ExternalWikiService' AND OLD.project_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:services, TRIGGER_ON_INSERT_NAME) - drop_trigger(:services, TRIGGER_ON_UPDATE_NAME) - drop_trigger(:services, TRIGGER_ON_DELETE_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20201214084105_add_expiration_policy_completed_at_to_container_repositories.rb b/db/migrate/20201214084105_add_expiration_policy_completed_at_to_container_repositories.rb deleted file mode 100644 index 9e1f21068c2..00000000000 --- a/db/migrate/20201214084105_add_expiration_policy_completed_at_to_container_repositories.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true -class AddExpirationPolicyCompletedAtToContainerRepositories < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - add_column(:container_repositories, :expiration_policy_completed_at, :datetime_with_timezone) - end - - def down - remove_column(:container_repositories, :expiration_policy_completed_at) - end -end diff --git a/db/migrate/20201214111858_add_container_registry_cleanup_tags_service_max_list_size_to_application_settings.rb b/db/migrate/20201214111858_add_container_registry_cleanup_tags_service_max_list_size_to_application_settings.rb deleted file mode 100644 index 312220914c1..00000000000 --- a/db/migrate/20201214111858_add_container_registry_cleanup_tags_service_max_list_size_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddContainerRegistryCleanupTagsServiceMaxListSizeToApplicationSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column(:application_settings, :container_registry_cleanup_tags_service_max_list_size, :integer, default: 200, null: false) - end -end diff --git a/db/migrate/20201214112752_add_app_settings_container_reg_cleanup_tags_service_max_list_size_constraint.rb b/db/migrate/20201214112752_add_app_settings_container_reg_cleanup_tags_service_max_list_size_constraint.rb deleted file mode 100644 index 935dd641b4c..00000000000 --- a/db/migrate/20201214112752_add_app_settings_container_reg_cleanup_tags_service_max_list_size_constraint.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddAppSettingsContainerRegCleanupTagsServiceMaxListSizeConstraint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - CONSTRAINT_NAME = 'app_settings_container_reg_cleanup_tags_max_list_size_positive' - - disable_ddl_transaction! - - def up - add_check_constraint :application_settings, 'container_registry_cleanup_tags_service_max_list_size >= 0', CONSTRAINT_NAME - end - - def down - remove_check_constraint :application_settings, CONSTRAINT_NAME - end -end diff --git a/db/migrate/20201214113729_add_custom_mapping_columns_to_http_integrations.rb b/db/migrate/20201214113729_add_custom_mapping_columns_to_http_integrations.rb deleted file mode 100644 index dbad28280ac..00000000000 --- a/db/migrate/20201214113729_add_custom_mapping_columns_to_http_integrations.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddCustomMappingColumnsToHttpIntegrations < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :alert_management_http_integrations, :payload_example, :jsonb, null: false, default: {} - add_column :alert_management_http_integrations, :payload_attribute_mapping, :jsonb, null: false, default: {} - end -end diff --git a/db/migrate/20201214184020_add_epic_board_list.rb b/db/migrate/20201214184020_add_epic_board_list.rb deleted file mode 100644 index 9c4e3280754..00000000000 --- a/db/migrate/20201214184020_add_epic_board_list.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class AddEpicBoardList < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless table_exists?(:boards_epic_lists) - with_lock_retries do - create_table :boards_epic_lists do |t| - t.timestamps_with_timezone - t.references :epic_board, index: true, foreign_key: { to_table: :boards_epic_boards, on_delete: :cascade }, null: false - t.references :label, index: true, foreign_key: { on_delete: :cascade } - t.integer :position - t.integer :list_type, default: 1, limit: 2, null: false - - t.index [:epic_board_id, :label_id], unique: true, where: 'list_type = 1', name: 'index_boards_epic_lists_on_epic_board_id_and_label_id' - end - end - end - - add_check_constraint :boards_epic_lists, '(list_type <> 1) OR ("position" IS NOT NULL AND "position" >= 0)', 'boards_epic_lists_position_constraint' - end - - def down - with_lock_retries do - drop_table :boards_epic_lists - end - end -end diff --git a/db/migrate/20201215084652_delete_mock_deployment_service_records.rb b/db/migrate/20201215084652_delete_mock_deployment_service_records.rb deleted file mode 100644 index 6c601a5e852..00000000000 --- a/db/migrate/20201215084652_delete_mock_deployment_service_records.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DeleteMockDeploymentServiceRecords < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - if Rails.env.development? - execute("DELETE FROM services WHERE type = 'MockDeploymentService'") - end - end - - def down - # no-op - end -end diff --git a/db/migrate/20201215132151_change_unique_index_on_security_findings.rb b/db/migrate/20201215132151_change_unique_index_on_security_findings.rb deleted file mode 100644 index fe474ef3991..00000000000 --- a/db/migrate/20201215132151_change_unique_index_on_security_findings.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class ChangeUniqueIndexOnSecurityFindings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - OLD_INDEX_NAME = 'index_security_findings_on_uuid' - NEW_INDEX_NAME = 'index_security_findings_on_uuid_and_scan_id' - - disable_ddl_transaction! - - class SecurityFinding < ActiveRecord::Base - include EachBatch - - self.table_name = 'security_findings' - end - - def up - add_concurrent_index :security_findings, [:uuid, :scan_id], unique: true, name: NEW_INDEX_NAME - - remove_concurrent_index_by_name :security_findings, OLD_INDEX_NAME - end - - def down - # It is very unlikely that we rollback this migration but just in case if we have to, - # we have to clear the table because there can be multiple records with the same UUID - # which would break the creation of unique index on the `uuid` column. - # We choose clearing the table because just removing the duplicated records would - # cause data inconsistencies. - SecurityFinding.each_batch(of: 10000) { |relation| relation.delete_all } - - add_concurrent_index :security_findings, :uuid, unique: true, name: OLD_INDEX_NAME - - remove_concurrent_index_by_name :security_findings, NEW_INDEX_NAME - end -end diff --git a/db/migrate/20201215205404_create_namespace_package_settings.rb b/db/migrate/20201215205404_create_namespace_package_settings.rb deleted file mode 100644 index d74b99597ce..00000000000 --- a/db/migrate/20201215205404_create_namespace_package_settings.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class CreateNamespacePackageSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - with_lock_retries do - create_table :namespace_package_settings, if_not_exists: true, id: false do |t| - t.references :namespace, primary_key: true, index: false, default: nil, foreign_key: { to_table: :namespaces, on_delete: :cascade }, type: :bigint - t.boolean :maven_duplicates_allowed, null: false, default: true - t.text :maven_duplicate_exception_regex, null: false, default: '' - end - end - - add_text_limit :namespace_package_settings, :maven_duplicate_exception_regex, 255 - end - - def down - drop_table :namespace_package_settings - end -end diff --git a/db/migrate/20201216151616_add_squash_commit_sha_index.rb b/db/migrate/20201216151616_add_squash_commit_sha_index.rb deleted file mode 100644 index ac6d3fda2d2..00000000000 --- a/db/migrate/20201216151616_add_squash_commit_sha_index.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddSquashCommitShaIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = "index_merge_requests_on_target_project_id_and_squash_commit_sha" - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, - [:target_project_id, :squash_commit_sha], - name: INDEX_NAME - end - - def down - remove_concurrent_index :merge_requests, - [:target_project_id, :squash_commit_sha], - name: INDEX_NAME - end -end diff --git a/db/migrate/20201216154457_add_devops_adoption_snapshot_range_end.rb b/db/migrate/20201216154457_add_devops_adoption_snapshot_range_end.rb deleted file mode 100644 index ada1bd9b346..00000000000 --- a/db/migrate/20201216154457_add_devops_adoption_snapshot_range_end.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionSnapshotRangeEnd < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :analytics_devops_adoption_snapshots, :end_time, :datetime_with_timezone - end -end diff --git a/db/migrate/20201217070530_add_group_merge_request_approval_settings.rb b/db/migrate/20201217070530_add_group_merge_request_approval_settings.rb deleted file mode 100644 index dba9e6e440f..00000000000 --- a/db/migrate/20201217070530_add_group_merge_request_approval_settings.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddGroupMergeRequestApprovalSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - create_table :group_merge_request_approval_settings, id: false do |t| - t.timestamps_with_timezone null: false - t.references :group, references: :namespaces, primary_key: true, default: nil, index: false, - foreign_key: { to_table: :namespaces, on_delete: :cascade } - t.boolean :allow_author_approval, null: false, default: false - end - end - end - - def down - with_lock_retries do - drop_table :group_merge_request_approval_settings - end - end -end diff --git a/db/migrate/20201217111448_change_pages_deployment_size_to_bigint.rb b/db/migrate/20201217111448_change_pages_deployment_size_to_bigint.rb deleted file mode 100644 index 75420166b87..00000000000 --- a/db/migrate/20201217111448_change_pages_deployment_size_to_bigint.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ChangePagesDeploymentSizeToBigint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - change_column_type_concurrently :pages_deployments, :size, :bigint - end - - def down - undo_change_column_type_concurrently :pages_deployments, :size - end -end diff --git a/db/migrate/20201217132603_create_elastic_reindexing_subtasks.rb b/db/migrate/20201217132603_create_elastic_reindexing_subtasks.rb deleted file mode 100644 index db084b885c2..00000000000 --- a/db/migrate/20201217132603_create_elastic_reindexing_subtasks.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -class CreateElasticReindexingSubtasks < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class ReindexingTask < ActiveRecord::Base - self.table_name = 'elastic_reindexing_tasks' - end - - class ReindexingSubtask < ActiveRecord::Base - self.table_name = 'elastic_reindexing_subtasks' - end - - def up - unless table_exists?(:elastic_reindexing_subtasks) - create_table :elastic_reindexing_subtasks do |t| - t.references :elastic_reindexing_task, foreign_key: { on_delete: :cascade }, null: false - t.text :alias_name, null: false - t.text :index_name_from, null: false - t.text :index_name_to, null: false - t.text :elastic_task, null: false - t.integer :documents_count_target - t.integer :documents_count - t.timestamps_with_timezone null: false - end - end - - add_text_limit :elastic_reindexing_subtasks, :index_name_from, 255 - add_text_limit :elastic_reindexing_subtasks, :index_name_to, 255 - add_text_limit :elastic_reindexing_subtasks, :elastic_task, 255 - add_text_limit :elastic_reindexing_subtasks, :alias_name, 255 - - ReindexingTask.find_each do |task| - next if task.index_name_from.blank? || task.index_name_to.blank? || task.elastic_task.blank? - next if ReindexingSubtask.where(elastic_reindexing_task_id: task.id).exists? - - ReindexingSubtask.create( - elastic_reindexing_task_id: task.id, - documents_count_target: task.documents_count_target, - documents_count: task.documents_count, - alias_name: 'gitlab-production', - index_name_from: task.index_name_from, - index_name_to: task.index_name_to, - elastic_task: task.elastic_task - ) - end - end - - def down - drop_table :elastic_reindexing_subtasks - end -end diff --git a/db/migrate/20201218194311_create_admin_notes.rb b/db/migrate/20201218194311_create_admin_notes.rb deleted file mode 100644 index 32f5818cdfb..00000000000 --- a/db/migrate/20201218194311_create_admin_notes.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class CreateAdminNotes < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - create_table_with_constraints :namespace_admin_notes do |t| - t.timestamps_with_timezone - t.references :namespace, null: false, foreign_key: { on_delete: :cascade } - t.text :note - - t.text_limit :note, 1000 - end - end - - def down - drop_table :namespace_admin_notes - end -end diff --git a/db/migrate/20201221124036_add_devops_snapshot_index.rb b/db/migrate/20201221124036_add_devops_snapshot_index.rb deleted file mode 100644 index 85001e9abcf..00000000000 --- a/db/migrate/20201221124036_add_devops_snapshot_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsSnapshotIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_on_snapshots_segment_id_end_time' - - def up - add_concurrent_index :analytics_devops_adoption_snapshots, [:segment_id, :end_time], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :analytics_devops_adoption_snapshots, INDEX_NAME - end -end diff --git a/db/migrate/20201221213415_change_clusters_helm_major_version_default_to_3.rb b/db/migrate/20201221213415_change_clusters_helm_major_version_default_to_3.rb deleted file mode 100644 index baec0da208b..00000000000 --- a/db/migrate/20201221213415_change_clusters_helm_major_version_default_to_3.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class ChangeClustersHelmMajorVersionDefaultTo3 < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - change_column_default(:clusters, :helm_major_version, from: 2, to: 3) - end -end diff --git a/db/migrate/20201221225303_add_service_desk_reply_to_is_not_null_index_on_issues.rb b/db/migrate/20201221225303_add_service_desk_reply_to_is_not_null_index_on_issues.rb deleted file mode 100644 index 7643fc107aa..00000000000 --- a/db/migrate/20201221225303_add_service_desk_reply_to_is_not_null_index_on_issues.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddServiceDeskReplyToIsNotNullIndexOnIssues < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - # no-op, the migration's version number was lowered to be executed earlier than db/post_migrate/20201128210234_schedule_populate_issue_email_participants.rb - # - # The new migration is located here: db/migrate/20201128210000_add_service_desk_reply_to_is_not_null_index_on_issues_fix.rb - end -end diff --git a/db/migrate/20201222151823_update_trusted_apps_to_confidential.rb b/db/migrate/20201222151823_update_trusted_apps_to_confidential.rb deleted file mode 100644 index bcb94c65125..00000000000 --- a/db/migrate/20201222151823_update_trusted_apps_to_confidential.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class UpdateTrustedAppsToConfidential < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'tmp_index_oauth_applications_on_id_where_trusted' - - disable_ddl_transaction! - - def up - add_concurrent_index :oauth_applications, :id, where: 'trusted = true', name: INDEX_NAME - - execute('UPDATE oauth_applications SET confidential = true WHERE trusted = true') - end - - def down - # We won't be able to tell which trusted applications weren't confidential before the migration - # and setting all trusted applications are not confidential would introduce security issues - - remove_concurrent_index_by_name :oauth_applications, INDEX_NAME - end -end diff --git a/db/migrate/20201223114050_add_restrict_user_defined_variables_to_project_settings.rb b/db/migrate/20201223114050_add_restrict_user_defined_variables_to_project_settings.rb deleted file mode 100644 index d04c6981bf9..00000000000 --- a/db/migrate/20201223114050_add_restrict_user_defined_variables_to_project_settings.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddRestrictUserDefinedVariablesToProjectSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :project_ci_cd_settings, :restrict_user_defined_variables, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :project_ci_cd_settings, :restrict_user_defined_variables - end - end -end diff --git a/db/migrate/20201224144948_migrate_coverage_report_worker.rb b/db/migrate/20201224144948_migrate_coverage_report_worker.rb deleted file mode 100644 index 8580a15c256..00000000000 --- a/db/migrate/20201224144948_migrate_coverage_report_worker.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class MigrateCoverageReportWorker < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - sidekiq_queue_migrate 'ci_pipelines_create_artifact', to: 'ci_pipeline_artifacts_coverage_report' # rubocop:disable Migration/SidekiqQueueMigrate - end - - def down - sidekiq_queue_migrate 'ci_pipeline_artifacts_coverage_report', to: 'ci_pipelines_create_artifact' # rubocop:disable Migration/SidekiqQueueMigrate - end -end diff --git a/db/migrate/20201228110136_create_iterations_cadence.rb b/db/migrate/20201228110136_create_iterations_cadence.rb deleted file mode 100644 index 95601ab4b29..00000000000 --- a/db/migrate/20201228110136_create_iterations_cadence.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class CreateIterationsCadence < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - create_table_with_constraints :iterations_cadences do |t| - t.references :group, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade } - t.timestamps_with_timezone null: false - t.date :start_date, null: false - t.date :last_run_date - t.integer :duration_in_weeks - t.integer :iterations_in_advance - t.boolean :active, default: true, null: false - t.boolean :automatic, default: true, null: false - t.text :title, null: false - - t.text_limit :title, 255 - end - end - - def down - drop_table :iterations_cadences if table_exists?(:iterations_cadences) - end -end diff --git a/db/migrate/20201228110238_add_iterations_cadence_to_sprints.rb b/db/migrate/20201228110238_add_iterations_cadence_to_sprints.rb deleted file mode 100644 index 9d9026a265b..00000000000 --- a/db/migrate/20201228110238_add_iterations_cadence_to_sprints.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddIterationsCadenceToSprints < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_sprints_iterations_cadence_id' - - def up - add_column :sprints, :iterations_cadence_id, :integer unless column_exists?(:sprints, :iterations_cadence_id) - - add_concurrent_index :sprints, :iterations_cadence_id, name: INDEX_NAME - add_concurrent_foreign_key :sprints, :iterations_cadences, column: :iterations_cadence_id, on_delete: :cascade - end - - def down - remove_column :sprints, :iterations_cadence_id if column_exists?(:sprints, :iterations_cadence_id) - end -end diff --git a/db/migrate/20201228184500_add_dismissal_reason_into_vulnerability_feedback_table.rb b/db/migrate/20201228184500_add_dismissal_reason_into_vulnerability_feedback_table.rb deleted file mode 100644 index 92484aced4e..00000000000 --- a/db/migrate/20201228184500_add_dismissal_reason_into_vulnerability_feedback_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddDismissalReasonIntoVulnerabilityFeedbackTable < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - add_column :vulnerability_feedback, :dismissal_reason, :smallint - end - - def down - remove_column :vulnerability_feedback, :dismissal_reason - end -end diff --git a/db/migrate/20201229105948_add_invisible_captcha_enabled_to_settings.rb b/db/migrate/20201229105948_add_invisible_captcha_enabled_to_settings.rb deleted file mode 100644 index 025fcba0729..00000000000 --- a/db/migrate/20201229105948_add_invisible_captcha_enabled_to_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddInvisibleCaptchaEnabledToSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :application_settings, :invisible_captcha_enabled, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20201230161206_add_rate_limiting_response_text_to_application_settings.rb b/db/migrate/20201230161206_add_rate_limiting_response_text_to_application_settings.rb deleted file mode 100644 index 647455f5f88..00000000000 --- a/db/migrate/20201230161206_add_rate_limiting_response_text_to_application_settings.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class AddRateLimitingResponseTextToApplicationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210101110640_set_limit_for_rate_limiting_response_text - def change - add_column :application_settings, :rate_limiting_response_text, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20201230180202_create_onboarding_progress.rb b/db/migrate/20201230180202_create_onboarding_progress.rb deleted file mode 100644 index b9fe64eb19d..00000000000 --- a/db/migrate/20201230180202_create_onboarding_progress.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class CreateOnboardingProgress < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - create_table :onboarding_progresses do |t| - t.references :namespace, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.timestamps_with_timezone null: false - t.datetime_with_timezone :git_pull_at - t.datetime_with_timezone :git_write_at - t.datetime_with_timezone :merge_request_created_at - t.datetime_with_timezone :pipeline_created_at - t.datetime_with_timezone :user_added_at - t.datetime_with_timezone :trial_started_at - t.datetime_with_timezone :subscription_created_at - t.datetime_with_timezone :required_mr_approvals_enabled_at - t.datetime_with_timezone :code_owners_enabled_at - t.datetime_with_timezone :scoped_label_created_at - t.datetime_with_timezone :security_scan_enabled_at - t.datetime_with_timezone :issue_auto_closed_at - t.datetime_with_timezone :repository_imported_at - t.datetime_with_timezone :repository_mirrored_at - end - end - end - - def down - with_lock_retries do - drop_table :onboarding_progresses - end - end -end diff --git a/db/migrate/20210101110640_set_limit_for_rate_limiting_response_text.rb b/db/migrate/20210101110640_set_limit_for_rate_limiting_response_text.rb deleted file mode 100644 index b72f2ae7d70..00000000000 --- a/db/migrate/20210101110640_set_limit_for_rate_limiting_response_text.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class SetLimitForRateLimitingResponseText < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_text_limit :application_settings, :rate_limiting_response_text, 255 - end - - def down - remove_text_limit :application_settings, :rate_limiting_response_text - end -end diff --git a/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb b/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb deleted file mode 100644 index 9c99414792e..00000000000 --- a/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class DropTemporaryIndexOnCiBuilds < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX = 'tmp_build_stage_position_index' - - def up - remove_concurrent_index_by_name :ci_builds, INDEX - end - - def down - add_concurrent_index :ci_builds, [:stage_id, :stage_idx], where: 'stage_idx IS NOT NULL', name: INDEX - end -end diff --git a/db/migrate/20210104163218_add_epic_board_position_index.rb b/db/migrate/20210104163218_add_epic_board_position_index.rb deleted file mode 100644 index 32c829f0288..00000000000 --- a/db/migrate/20210104163218_add_epic_board_position_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddEpicBoardPositionIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_boards_epic_board_positions_on_scoped_relative_position' - - disable_ddl_transaction! - - def up - add_concurrent_index :boards_epic_board_positions, [:epic_board_id, :epic_id, :relative_position], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :boards_epic_board_positions, INDEX_NAME - end -end diff --git a/db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb b/db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb deleted file mode 100644 index cdfbd368070..00000000000 --- a/db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RenameAssetProxyWhitelistOnApplicationSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers::V2 - - DOWNTIME = false - - disable_ddl_transaction! - - def up - rename_column_concurrently :application_settings, - :asset_proxy_whitelist, - :asset_proxy_allowlist - end - - def down - undo_rename_column_concurrently :application_settings, - :asset_proxy_whitelist, - :asset_proxy_allowlist - end -end diff --git a/db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb b/db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb deleted file mode 100644 index 3b5ffff7645..00000000000 --- a/db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddEntityColumnsToVulnerabilityOccurrences < ActiveRecord::Migration[6.0] - DOWNTIME = false - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20200501000002_add_text_limit_to_sprints_extended_title - def change - add_column :vulnerability_occurrences, :description, :text - add_column :vulnerability_occurrences, :message, :text - add_column :vulnerability_occurrences, :solution, :text - add_column :vulnerability_occurrences, :cve, :text - add_column :vulnerability_occurrences, :location, :jsonb - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb b/db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb deleted file mode 100644 index c2e138303d8..00000000000 --- a/db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToVulnerabilityOccurrencesEntityColumns < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_text_limit :vulnerability_occurrences, :description, 15000 - add_text_limit :vulnerability_occurrences, :message, 3000 - add_text_limit :vulnerability_occurrences, :solution, 7000 - add_text_limit :vulnerability_occurrences, :cve, 48400 - end - - def down - remove_text_limit :vulnerability_occurrences, :description - remove_text_limit :vulnerability_occurrences, :message - remove_text_limit :vulnerability_occurrences, :solution - remove_text_limit :vulnerability_occurrences, :cve - end -end diff --git a/db/migrate/20210106061254_add_unique_index_for_golang_packages.rb b/db/migrate/20210106061254_add_unique_index_for_golang_packages.rb deleted file mode 100644 index 44237699fda..00000000000 --- a/db/migrate/20210106061254_add_unique_index_for_golang_packages.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexForGolangPackages < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_golang' - PACKAGE_TYPE_GOLANG = 8 - - disable_ddl_transaction! - - def up - add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, where: "package_type = #{PACKAGE_TYPE_GOLANG}", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name(:packages_packages, INDEX_NAME) - end -end diff --git a/db/migrate/20210106153021_drop_tmp_index_on_emails.rb b/db/migrate/20210106153021_drop_tmp_index_on_emails.rb deleted file mode 100644 index 94b4a5437af..00000000000 --- a/db/migrate/20210106153021_drop_tmp_index_on_emails.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class DropTmpIndexOnEmails < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - EMAIL_INDEX_NAME = 'tmp_index_for_email_unconfirmation_migration' - - disable_ddl_transaction! - - def up - Gitlab::BackgroundMigration.steal('WrongfullyConfirmedEmailUnconfirmer') - - remove_concurrent_index_by_name(:emails, EMAIL_INDEX_NAME) - end - - def down - add_concurrent_index(:emails, :id, where: 'confirmed_at IS NOT NULL', name: EMAIL_INDEX_NAME) - end -end diff --git a/db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb b/db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb deleted file mode 100644 index 906efa58bcd..00000000000 --- a/db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb +++ /dev/null @@ -1,22 +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 AddMergeRequestDiffCommitTrailers < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :merge_request_diff_commits, :trailers, :jsonb, default: {}, null: false - end - end - - def down - with_lock_retries do - remove_column :merge_request_diff_commits, :trailers - end - end -end diff --git a/db/migrate/20210106191305_rename_indexes_on_git_lab_com.rb b/db/migrate/20210106191305_rename_indexes_on_git_lab_com.rb deleted file mode 100644 index 5238192e1d1..00000000000 --- a/db/migrate/20210106191305_rename_indexes_on_git_lab_com.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -# This migration aligns an existing database schema with what we actually expect -# and fixes inconsistencies with index names and similar issues. -# -# This is intended for GitLab.com, but can be run on any instance. -class RenameIndexesOnGitLabCom < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - rename_index_if_exists :ldap_group_links, 'ldap_groups_pkey', 'ldap_group_links_pkey' - - # Removes unique constraint, add unique index instead - replace_unique_constraint_with_index :emails, :email, 'emails_email_key', 'index_emails_on_email' - replace_unique_constraint_with_index :users, :confirmation_token, 'users_confirmation_token_key', 'index_users_on_confirmation_token' - replace_unique_constraint_with_index :users, :reset_password_token, 'users_reset_password_token_key', 'index_users_on_reset_password_token' - replace_unique_constraint_with_index :users, :email, 'users_email_key', 'index_users_on_email' - - upgrade_to_primary_key(:schema_migrations, :version, 'schema_migrations_version_key', 'schema_migrations_pkey') - end - - def down - # no-op - end - - private - - def replace_unique_constraint_with_index(table, columns, old_name, new_name) - return unless index_exists_by_name?(table, old_name) - - add_concurrent_index table, columns, unique: true, name: new_name - execute "ALTER TABLE #{quote_table_name(table)} DROP CONSTRAINT #{quote_table_name(old_name)}" - end - - def rename_index_if_exists(table, old_name, new_name) - return unless index_exists_by_name?(table, old_name) - return if index_exists_by_name?(table, new_name) - - with_lock_retries do - rename_index table, old_name, new_name - end - end - - def upgrade_to_primary_key(table, column, old_name, new_name) - return unless index_exists_by_name?(table, old_name) - return if index_exists_by_name?(table, new_name) - - return if primary_key(table) - - execute "ALTER TABLE #{quote_table_name(table)} ADD CONSTRAINT #{new_name} PRIMARY KEY (#{column})" - execute "ALTER TABLE #{quote_table_name(table)} DROP CONSTRAINT #{old_name}" - end -end diff --git a/db/migrate/20210106225424_add_keep_latest_artifacts_to_application_settings.rb b/db/migrate/20210106225424_add_keep_latest_artifacts_to_application_settings.rb deleted file mode 100644 index 884159ddedb..00000000000 --- a/db/migrate/20210106225424_add_keep_latest_artifacts_to_application_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddKeepLatestArtifactsToApplicationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - # This is named keep_latest_artifact for consistency with the project level setting but - # turning it on keeps all (multiple) artifacts on the latest pipeline per ref - add_column :application_settings, :keep_latest_artifact, :boolean, default: true, null: false - end -end diff --git a/db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb b/db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb deleted file mode 100644 index 0b9b5e93054..00000000000 --- a/db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class AddDiffTypeToMergeRequestDiffs < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - UNIQUE_INDEX_NAME = 'index_merge_request_diffs_on_unique_merge_request_id' - - def up - unless column_exists?(:merge_request_diffs, :diff_type) - with_lock_retries do - add_column :merge_request_diffs, :diff_type, :integer, null: false, limit: 2, default: 1 - end - end - - add_concurrent_index :merge_request_diffs, :merge_request_id, unique: true, where: 'diff_type = 2', name: UNIQUE_INDEX_NAME - end - - def down - remove_concurrent_index_by_name(:merge_request_diffs, UNIQUE_INDEX_NAME) - - if column_exists?(:merge_request_diffs, :diff_type) - with_lock_retries do - remove_column :merge_request_diffs, :diff_type - end - end - end -end diff --git a/db/migrate/20210107154615_add_merge_request_context_commit_trailers.rb b/db/migrate/20210107154615_add_merge_request_context_commit_trailers.rb deleted file mode 100644 index e7bd7c2ea56..00000000000 --- a/db/migrate/20210107154615_add_merge_request_context_commit_trailers.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 AddMergeRequestContextCommitTrailers < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :merge_request_context_commits, :trailers, :jsonb, default: {}, null: false - end -end diff --git a/db/migrate/20210108161039_update_max_import_size_default.rb b/db/migrate/20210108161039_update_max_import_size_default.rb deleted file mode 100644 index 5f0591b2766..00000000000 --- a/db/migrate/20210108161039_update_max_import_size_default.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class UpdateMaxImportSizeDefault < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - change_column_default(:application_settings, :max_import_size, from: 50, to: 0) - end -end diff --git a/db/migrate/20210111051045_create_dast_profiles.rb b/db/migrate/20210111051045_create_dast_profiles.rb deleted file mode 100644 index f2667e1222e..00000000000 --- a/db/migrate/20210111051045_create_dast_profiles.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class CreateDastProfiles < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - table_comment = { owner: 'group::dynamic analysis', description: 'Profile used to run a DAST on-demand scan' } - - create_table_with_constraints :dast_profiles, comment: table_comment.to_json do |t| # rubocop:disable Migration/AddLimitToTextColumns - t.references :project, null: false, foreign_key: false, index: false - t.references :dast_site_profile, null: false, foreign_key: { on_delete: :cascade } - t.references :dast_scanner_profile, null: false, foreign_key: { on_delete: :cascade } - - t.timestamps_with_timezone - - # rubocop:disable Migration/AddLimitToTextColumns - t.text :name, null: false - t.text :description, null: false - # rubocop:enable Migration/AddLimitToTextColumns - - t.index [:project_id, :name], unique: true - - t.text_limit :name, 255 - t.text_limit :description, 255 - end - end - - def down - with_lock_retries do - drop_table :dast_profiles - end - end -end diff --git a/db/migrate/20210111053308_add_project_fk_for_dast_profile.rb b/db/migrate/20210111053308_add_project_fk_for_dast_profile.rb deleted file mode 100644 index 5dc057b5f70..00000000000 --- a/db/migrate/20210111053308_add_project_fk_for_dast_profile.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddProjectFkForDastProfile < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :dast_profiles, :projects, column: :project_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :dast_profiles, column: :project_id - end - end -end diff --git a/db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb b/db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb deleted file mode 100644 index a8f4e130f07..00000000000 --- a/db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddTemporaryIndexOnSecurityFindingsScanId < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'tmp_index_on_security_findings_scan_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :security_findings, :scan_id, where: 'uuid is null', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :security_findings, INDEX_NAME - end -end diff --git a/db/migrate/20210112084512_drop_tmp_index_on_emails_again.rb b/db/migrate/20210112084512_drop_tmp_index_on_emails_again.rb deleted file mode 100644 index 6c2f9cbcb32..00000000000 --- a/db/migrate/20210112084512_drop_tmp_index_on_emails_again.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DropTmpIndexOnEmailsAgain < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - EMAIL_INDEX_NAME = 'tmp_index_for_email_unconfirmation_migration' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name(:emails, EMAIL_INDEX_NAME) - end - - def down - add_concurrent_index(:emails, :id, where: 'confirmed_at IS NOT NULL', name: EMAIL_INDEX_NAME) - end -end diff --git a/db/migrate/20210112202949_create_composer_cache_file.rb b/db/migrate/20210112202949_create_composer_cache_file.rb deleted file mode 100644 index b1c2a1608dd..00000000000 --- a/db/migrate/20210112202949_create_composer_cache_file.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class CreateComposerCacheFile < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - # rubocop:disable Migration/AddLimitToTextColumns - create_table_with_constraints :packages_composer_cache_files do |t| - t.timestamps_with_timezone - - # record can be deleted after `delete_at` - t.datetime_with_timezone :delete_at - - # which namespace it belongs to - t.integer :namespace_id, null: true - - # file storage related fields - t.integer :file_store, limit: 2, null: false, default: 1 - t.text :file, null: false - t.binary :file_sha256, null: false - - t.index [:namespace_id, :file_sha256], name: "index_packages_composer_cache_namespace_and_sha", using: :btree, unique: true - t.foreign_key :namespaces, column: :namespace_id, on_delete: :nullify - - t.text_limit :file, 255 - end - end - - def down - drop_table :packages_composer_cache_files - end -end diff --git a/db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb b/db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb deleted file mode 100644 index 408d0579031..00000000000 --- a/db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddPipelineConfigurationFullPathToCompliancePipeline < ActiveRecord::Migration[6.0] - DOWNTIME = false - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb - def up - add_column :compliance_management_frameworks, :pipeline_configuration_full_path, :text - end - # rubocop:enable Migration/AddLimitToTextColumns - - def down - remove_column :compliance_management_frameworks, :pipeline_configuration_full_path - end -end diff --git a/db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb b/db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb deleted file mode 100644 index 25571b25af9..00000000000 --- a/db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddConvertedAtToExperimentSubjects < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :experiment_subjects, :converted_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20210113231546_add_context_to_experiment_subjects.rb b/db/migrate/20210113231546_add_context_to_experiment_subjects.rb deleted file mode 100644 index 7fac45e9952..00000000000 --- a/db/migrate/20210113231546_add_context_to_experiment_subjects.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddContextToExperimentSubjects < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :experiment_subjects, :context, :jsonb, default: {}, null: false - end -end diff --git a/db/migrate/20210114033715_remove_group_id_title_index.rb b/db/migrate/20210114033715_remove_group_id_title_index.rb deleted file mode 100644 index 8d63da3d400..00000000000 --- a/db/migrate/20210114033715_remove_group_id_title_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveGroupIdTitleIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_labels_on_group_id_and_title_with_null_project_id' - LABELS_TABLE = :labels - - def up - remove_concurrent_index_by_name LABELS_TABLE, INDEX_NAME - end - - def down - add_concurrent_index LABELS_TABLE, [:group_id, :title], where: 'project_id IS NULL', name: INDEX_NAME - end -end diff --git a/db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb b/db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb deleted file mode 100644 index 39964047e7f..00000000000 --- a/db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class AddIndexesToOnboardingProgresses < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - CREATE_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_create_track' - VERIFY_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_verify_track' - TRIAL_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_trial_track' - TEAM_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_team_track' - - disable_ddl_transaction! - - def up - add_concurrent_index :onboarding_progresses, :created_at, where: 'git_write_at IS NULL', name: CREATE_TRACK_INDEX_NAME - add_concurrent_index :onboarding_progresses, :git_write_at, where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NULL', name: VERIFY_TRACK_INDEX_NAME - add_concurrent_index :onboarding_progresses, 'GREATEST(git_write_at, pipeline_created_at)', where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NOT NULL AND trial_started_at IS NULL', name: TRIAL_TRACK_INDEX_NAME - add_concurrent_index :onboarding_progresses, 'GREATEST(git_write_at, pipeline_created_at, trial_started_at)', where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NOT NULL AND trial_started_at IS NOT NULL AND user_added_at IS NULL', name: TEAM_TRACK_INDEX_NAME - end - - def down - remove_concurrent_index_by_name :onboarding_progresses, CREATE_TRACK_INDEX_NAME - remove_concurrent_index_by_name :onboarding_progresses, VERIFY_TRACK_INDEX_NAME - remove_concurrent_index_by_name :onboarding_progresses, TRIAL_TRACK_INDEX_NAME - remove_concurrent_index_by_name :onboarding_progresses, TEAM_TRACK_INDEX_NAME - end -end diff --git a/db/migrate/20210115090452_create_group_repository_storage_move.rb b/db/migrate/20210115090452_create_group_repository_storage_move.rb deleted file mode 100644 index bd168dce5ac..00000000000 --- a/db/migrate/20210115090452_create_group_repository_storage_move.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class CreateGroupRepositoryStorageMove < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless table_exists?(:group_repository_storage_moves) - with_lock_retries do - create_table :group_repository_storage_moves do |t| - t.timestamps_with_timezone - t.references :group, references: :namespace, column: :group_id, index: true, null: false - t.integer :state, limit: 2, default: 1, null: false - t.text :source_storage_name, null: false - t.text :destination_storage_name, null: false - - t.foreign_key :namespaces, column: :group_id, on_delete: :cascade - end - end - end - - add_text_limit(:group_repository_storage_moves, :source_storage_name, 255, constraint_name: 'group_repository_storage_moves_source_storage_name') - add_text_limit(:group_repository_storage_moves, :destination_storage_name, 255, constraint_name: 'group_repository_storage_moves_destination_storage_name') - end - - def down - with_lock_retries do - drop_table :group_repository_storage_moves - end - end -end diff --git a/db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb b/db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb deleted file mode 100644 index 20fe0ee0fd1..00000000000 --- a/db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -class AddHasExternalIssueTrackerTrigger < ActiveRecord::Migration[6.0] - include Gitlab::Database::SchemaHelpers - - DOWNTIME = false - FUNCTION_NAME = 'set_has_external_issue_tracker' - TRIGGER_ON_INSERT_NAME = 'trigger_has_external_issue_tracker_on_insert' - TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_issue_tracker_on_update' - TRIGGER_ON_DELETE_NAME = 'trigger_has_external_issue_tracker_on_delete' - - def up - create_trigger_function(FUNCTION_NAME, replace: true) do - <<~SQL - UPDATE projects SET has_external_issue_tracker = ( - EXISTS - ( - SELECT 1 - FROM services - WHERE project_id = COALESCE(NEW.project_id, OLD.project_id) - AND active = TRUE - AND category = 'issue_tracker' - ) - ) - WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id); - RETURN NULL; - SQL - end - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME} - AFTER INSERT ON services - FOR EACH ROW - WHEN (NEW.category = 'issue_tracker' AND NEW.active = TRUE AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_UPDATE_NAME} - AFTER UPDATE ON services - FOR EACH ROW - WHEN (NEW.category = 'issue_tracker' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - - execute(<<~SQL) - CREATE TRIGGER #{TRIGGER_ON_DELETE_NAME} - AFTER DELETE ON services - FOR EACH ROW - WHEN (OLD.category = 'issue_tracker' AND OLD.active = TRUE AND OLD.project_id IS NOT NULL) - EXECUTE FUNCTION #{FUNCTION_NAME}(); - SQL - end - - def down - drop_trigger(:services, TRIGGER_ON_INSERT_NAME) - drop_trigger(:services, TRIGGER_ON_UPDATE_NAME) - drop_trigger(:services, TRIGGER_ON_DELETE_NAME) - drop_function(FUNCTION_NAME) - end -end diff --git a/db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb b/db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb deleted file mode 100644 index fd1ed4f207b..00000000000 --- a/db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddEnforceSshKeyExpirationToApplicationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :application_settings, :enforce_ssh_key_expiration, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210119153801_add_proxy_settings_to_jira_tracker_data.rb b/db/migrate/20210119153801_add_proxy_settings_to_jira_tracker_data.rb deleted file mode 100644 index 237ea25554d..00000000000 --- a/db/migrate/20210119153801_add_proxy_settings_to_jira_tracker_data.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddProxySettingsToJiraTrackerData < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :jira_tracker_data, :encrypted_proxy_address, :text - add_column :jira_tracker_data, :encrypted_proxy_address_iv, :text - add_column :jira_tracker_data, :encrypted_proxy_port, :text - add_column :jira_tracker_data, :encrypted_proxy_port_iv, :text - add_column :jira_tracker_data, :encrypted_proxy_username, :text - add_column :jira_tracker_data, :encrypted_proxy_username_iv, :text - add_column :jira_tracker_data, :encrypted_proxy_password, :text - add_column :jira_tracker_data, :encrypted_proxy_password_iv, :text - end -end diff --git a/db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb b/db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb deleted file mode 100644 index 2958dc8d0ec..00000000000 --- a/db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToCompliancePipelineConfigurationFullPath < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_text_limit :compliance_management_frameworks, :pipeline_configuration_full_path, 255 - end - - def down - remove_text_limit :compliance_management_frameworks, :pipeline_configuration_full_path - end -end diff --git a/db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb b/db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb deleted file mode 100644 index 421a2fac1ae..00000000000 --- a/db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class ExtendIndexOnCiBuildsMetadata < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - OLD_INDEX = :index_ci_builds_metadata_on_build_id_and_interruptible - NEW_INDEX = :index_ci_builds_metadata_on_build_id_and_id_and_interruptible - - TABLE = :ci_builds_metadata - - def up - create_covering_index(TABLE, NEW_INDEX) - - remove_concurrent_index_by_name TABLE, OLD_INDEX - end - - def down - add_concurrent_index TABLE, :build_id, where: 'interruptible = true', name: OLD_INDEX - - remove_concurrent_index_by_name TABLE, NEW_INDEX - end - - private - - def create_covering_index(table, name) - return if index_exists_by_name?(table, name) - - disable_statement_timeout do - execute <<~SQL - CREATE INDEX CONCURRENTLY #{name} - ON #{table} (build_id) INCLUDE (id) - WHERE interruptible = true - SQL - end - end -end diff --git a/db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb b/db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb deleted file mode 100644 index d29e63ba5da..00000000000 --- a/db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DeleteOauthApplicationsTmpIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'tmp_index_oauth_applications_on_id_where_trusted' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :oauth_applications, INDEX_NAME - end - - def down - add_concurrent_index :oauth_applications, :id, where: 'trusted = true', name: INDEX_NAME - end -end diff --git a/db/migrate/20210121093618_remove_repository_read_only_to_groups.rb b/db/migrate/20210121093618_remove_repository_read_only_to_groups.rb deleted file mode 100644 index 0b353ba5d88..00000000000 --- a/db/migrate/20210121093618_remove_repository_read_only_to_groups.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class RemoveRepositoryReadOnlyToGroups < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - if column_exists?(:namespaces, :repository_read_only) - with_lock_retries do - remove_column :namespaces, :repository_read_only # rubocop:disable Migration/RemoveColumn - end - end - end - - def down - unless column_exists?(:namespaces, :repository_read_only) - with_lock_retries do - add_column :namespaces, :repository_read_only, :boolean, default: false, null: false # rubocop:disable Migration/AddColumnsToWideTables - end - end - end -end diff --git a/db/migrate/20210121100038_add_devops_adoption_group_segment.rb b/db/migrate/20210121100038_add_devops_adoption_group_segment.rb deleted file mode 100644 index 619657e7f56..00000000000 --- a/db/migrate/20210121100038_add_devops_adoption_group_segment.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionGroupSegment < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column :analytics_devops_adoption_segments, :namespace_id, :integer, if_not_exists: true - add_concurrent_index :analytics_devops_adoption_segments, :namespace_id, unique: true - end - - def down - remove_column :analytics_devops_adoption_segments, :namespace_id - end -end diff --git a/db/migrate/20210121121102_optional_devops_adoption_segment_name.rb b/db/migrate/20210121121102_optional_devops_adoption_segment_name.rb deleted file mode 100644 index d7fda093cfc..00000000000 --- a/db/migrate/20210121121102_optional_devops_adoption_segment_name.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class OptionalDevopsAdoptionSegmentName < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_analytics_devops_adoption_segments_on_name' - - def up - change_column_null :analytics_devops_adoption_segments, :name, true - remove_concurrent_index_by_name :analytics_devops_adoption_segments, INDEX_NAME - end - - def down - transaction do - execute "DELETE FROM analytics_devops_adoption_segments WHERE name IS NULL" - change_column_null :analytics_devops_adoption_segments, :name, false - end - add_concurrent_index :analytics_devops_adoption_segments, :name, unique: true, name: INDEX_NAME - end -end diff --git a/db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb b/db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb deleted file mode 100644 index f6479bdb3a4..00000000000 --- a/db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddRepositoryReadOnlyToNamespaceSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :namespace_settings, :repository_read_only, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :namespace_settings, :repository_read_only - end - end -end diff --git a/db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb b/db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb deleted file mode 100644 index dd0c98615f7..00000000000 --- a/db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddStateToMergeRequestReviewers < ActiveRecord::Migration[6.0] - DOWNTIME = false - - REVIEW_DEFAULT_STATE = 0 - - def change - add_column :merge_request_reviewers, :state, :smallint, default: REVIEW_DEFAULT_STATE, null: false - end -end diff --git a/db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb b/db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb deleted file mode 100644 index 749e0b16eaf..00000000000 --- a/db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class AddPipelineStepToBulkImportsFailures < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless column_exists?(:bulk_import_failures, :pipeline_step, :text) - with_lock_retries do - add_column :bulk_import_failures, :pipeline_step, :text - end - end - - add_text_limit :bulk_import_failures, :pipeline_step, 255 - end - - def down - with_lock_retries do - remove_column :bulk_import_failures, :pipeline_step - end - end -end diff --git a/db/migrate/20210125105410_add_devops_adoption_segment_namespace_fk.rb b/db/migrate/20210125105410_add_devops_adoption_segment_namespace_fk.rb deleted file mode 100644 index c7c18ae69d0..00000000000 --- a/db/migrate/20210125105410_add_devops_adoption_segment_namespace_fk.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddDevopsAdoptionSegmentNamespaceFk < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :analytics_devops_adoption_segments, :namespaces, column: :namespace_id - end - - def down - remove_foreign_key_if_exists :analytics_devops_adoption_segments, :namespaces, column: :namespace_id - end -end diff --git a/db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb b/db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb deleted file mode 100644 index cd325747282..00000000000 --- a/db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddSecurityDashboardAccessLevelIntoProjectFeatures < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - PRIVATE_ACCESS_LEVEL = 10 - - def up - with_lock_retries do - add_column :project_features, :security_and_compliance_access_level, :integer, default: PRIVATE_ACCESS_LEVEL, null: false - end - end - - def down - with_lock_retries do - remove_column :project_features, :security_and_compliance_access_level - end - end -end diff --git a/db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb b/db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb deleted file mode 100644 index 272dca70a8b..00000000000 --- a/db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexServicesProjectIdAndType < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_services_on_project_id_and_type_unique' - - def up - add_concurrent_index :services, [:project_id, :type], name: INDEX_NAME, unique: true - end - - def down - remove_concurrent_index_by_name :services, name: INDEX_NAME - end -end diff --git a/db/migrate/20210126092102_remove_index_services_project_id_and_type.rb b/db/migrate/20210126092102_remove_index_services_project_id_and_type.rb deleted file mode 100644 index 49780d03b7b..00000000000 --- a/db/migrate/20210126092102_remove_index_services_project_id_and_type.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexServicesProjectIdAndType < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_services_on_project_id_and_type' - - # Replaced by the index added in 20210126091713_add_unique_index_services_project_id_and_type.rb - def up - remove_concurrent_index_by_name :services, name: INDEX_NAME - end - - def down - add_concurrent_index :services, [:project_id, :type], name: INDEX_NAME - end -end diff --git a/db/migrate/20210126233608_add_rubygems_max_file_size_to_plan_limits.rb b/db/migrate/20210126233608_add_rubygems_max_file_size_to_plan_limits.rb deleted file mode 100644 index e0e7e773d17..00000000000 --- a/db/migrate/20210126233608_add_rubygems_max_file_size_to_plan_limits.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddRubygemsMaxFileSizeToPlanLimits < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :plan_limits, :rubygems_max_file_size, :bigint, default: 3.gigabytes, null: false - end -end diff --git a/db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb b/db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb deleted file mode 100644 index fe2b2ef412d..00000000000 --- a/db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddSubgroupEventsToWebHooks < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :web_hooks, :subgroup_events, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20210127143025_add_oldest_merge_requests_index.rb b/db/migrate/20210127143025_add_oldest_merge_requests_index.rb deleted file mode 100644 index c25e12d89af..00000000000 --- a/db/migrate/20210127143025_add_oldest_merge_requests_index.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddOldestMergeRequestsIndex < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - # replaced by db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb - end - - def down - # replaced by db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb - end -end diff --git a/db/migrate/20210127152613_add_iterations_cadence_date_range_constraint.rb b/db/migrate/20210127152613_add_iterations_cadence_date_range_constraint.rb deleted file mode 100644 index 95ecd167076..00000000000 --- a/db/migrate/20210127152613_add_iterations_cadence_date_range_constraint.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class AddIterationsCadenceDateRangeConstraint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - execute <<~SQL - ALTER TABLE sprints - ADD CONSTRAINT iteration_start_and_due_date_iterations_cadence_id_constraint - EXCLUDE USING gist - ( iterations_cadence_id WITH =, - daterange(start_date, due_date, '[]') WITH && - ) - WHERE (group_id IS NOT NULL) - SQL - end - end - - def down - with_lock_retries do - execute <<~SQL - ALTER TABLE sprints - DROP CONSTRAINT IF EXISTS iteration_start_and_due_date_iterations_cadence_id_constraint - SQL - end - end -end diff --git a/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb b/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb deleted file mode 100644 index e6c5eb1b411..00000000000 --- a/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class RemoveIterationGroupDateRangeConstraint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - execute <<~SQL - ALTER TABLE sprints - DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint - SQL - end - end - - def down - with_lock_retries do - execute <<~SQL - ALTER TABLE sprints - ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint - EXCLUDE USING gist - ( group_id WITH =, - daterange(start_date, due_date, '[]') WITH && - ) - WHERE (group_id IS NOT NULL) - SQL - end - end -end diff --git a/db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb b/db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb deleted file mode 100644 index 77a1dd2131b..00000000000 --- a/db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddGitTwoFactorSessionExpiryToApplicationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :application_settings, :git_two_factor_session_expiry, :integer, default: 15, null: false - end -end diff --git a/db/migrate/20210128101707_add_prevent_merge_without_jira_issue_to_project_settings.rb b/db/migrate/20210128101707_add_prevent_merge_without_jira_issue_to_project_settings.rb deleted file mode 100644 index 18f186294f1..00000000000 --- a/db/migrate/20210128101707_add_prevent_merge_without_jira_issue_to_project_settings.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddPreventMergeWithoutJiraIssueToProjectSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - def up - with_lock_retries do - add_column :project_settings, :prevent_merge_without_jira_issue, :boolean, null: false, default: false - end - end - - def down - with_lock_retries do - remove_column :project_settings, :prevent_merge_without_jira_issue - end - end -end diff --git a/db/migrate/20210128114526_add_auto_delete_at_to_environments.rb b/db/migrate/20210128114526_add_auto_delete_at_to_environments.rb deleted file mode 100644 index 8f89c2f2ad0..00000000000 --- a/db/migrate/20210128114526_add_auto_delete_at_to_environments.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddAutoDeleteAtToEnvironments < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :environments, :auto_delete_at, :datetime_with_timezone - end - end - - def down - with_lock_retries do - remove_column :environments, :auto_delete_at - end - end -end diff --git a/db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb b/db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb deleted file mode 100644 index d016e3c20e2..00000000000 --- a/db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class AddContentTypeToDependencyProxyManifests < ActiveRecord::Migration[6.0] - DOWNTIME = false - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in 20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb - def change - add_column :dependency_proxy_manifests, :content_type, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb b/db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb deleted file mode 100644 index 035e4795ce0..00000000000 --- a/db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToDependencyProxyManifestsContentType < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_text_limit :dependency_proxy_manifests, :content_type, 255 - end - - def down - remove_text_limit :dependency_proxy_manifests, :content_type - end -end diff --git a/db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb b/db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb deleted file mode 100644 index d6ee057a56b..00000000000 --- a/db/migrate/20210128152830_create_ci_namespace_monthly_usage.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class CreateCiNamespaceMonthlyUsage < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - with_lock_retries do - create_table :ci_namespace_monthly_usages, if_not_exists: true do |t| - t.references :namespace, index: false, null: false - t.date :date, null: false - t.integer :additional_amount_available, null: false, default: 0 - t.decimal :amount_used, null: false, default: 0.0, precision: 18, scale: 2 - - t.index [:namespace_id, :date], unique: true - end - end - - add_check_constraint :ci_namespace_monthly_usages, "(date = date_trunc('month', date))", 'ci_namespace_monthly_usages_year_month_constraint' - end - - def down - with_lock_retries do - drop_table :ci_namespace_monthly_usages - end - end -end diff --git a/db/migrate/20210128172149_create_background_migration_tracking_tables.rb b/db/migrate/20210128172149_create_background_migration_tracking_tables.rb deleted file mode 100644 index 767bd8737a3..00000000000 --- a/db/migrate/20210128172149_create_background_migration_tracking_tables.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -class CreateBackgroundMigrationTrackingTables < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table_with_constraints :batched_background_migrations do |t| - t.timestamps_with_timezone - t.bigint :min_value, null: false, default: 1 - t.bigint :max_value, null: false - t.integer :batch_size, null: false - t.integer :sub_batch_size, null: false - t.integer :interval, limit: 2, null: false - t.integer :status, limit: 2, null: false, default: 0 - t.text :job_class_name, null: false - t.text :batch_class_name, null: false, - default: 'Gitlab::Database::BackgroundMigration::PrimaryKeyBatchingStrategy' - t.text :table_name, null: false - t.text :column_name, null: false - t.jsonb :job_arguments, null: false, default: '[]' - - t.text_limit :job_class_name, 100 - t.text_limit :batch_class_name, 100 - t.text_limit :table_name, 63 - t.text_limit :column_name, 63 - - t.check_constraint :check_positive_min_value, 'min_value > 0' - t.check_constraint :check_max_value_in_range, 'max_value >= min_value' - - t.check_constraint :check_positive_sub_batch_size, 'sub_batch_size > 0' - t.check_constraint :check_batch_size_in_range, 'batch_size >= sub_batch_size' - - t.index %i[job_class_name table_name column_name], name: :index_batched_migrations_on_job_table_and_column_name - end - - create_table :batched_background_migration_jobs do |t| - t.timestamps_with_timezone - t.datetime_with_timezone :started_at - t.datetime_with_timezone :finished_at - t.references :batched_background_migration, null: false, index: false, foreign_key: { on_delete: :cascade } - t.bigint :min_value, null: false - t.bigint :max_value, null: false - t.integer :batch_size, null: false - t.integer :sub_batch_size, null: false - t.integer :status, limit: 2, null: false, default: 0 - t.integer :attempts, limit: 2, null: false, default: 0 - - t.index [:batched_background_migration_id, :id], name: :index_batched_jobs_by_batched_migration_id_and_id - end - end - - def down - drop_table :batched_background_migration_jobs - - drop_table :batched_background_migrations - end -end diff --git a/db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb b/db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb deleted file mode 100644 index 8285aceb24a..00000000000 --- a/db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToOncallShftsOnStartsAtAndEndsAt < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - NEW_NAME = 'index_oncall_shifts_on_rotation_id_and_starts_at_and_ends_at' - OLD_NAME = 'index_incident_management_oncall_shifts_on_rotation_id' - - def up - add_concurrent_index :incident_management_oncall_shifts, %i[rotation_id starts_at ends_at], name: NEW_NAME - - remove_concurrent_index_by_name :incident_management_oncall_shifts, OLD_NAME - end - - def down - add_concurrent_index :incident_management_oncall_shifts, :rotation_id, name: OLD_NAME - - remove_concurrent_index_by_name :incident_management_oncall_shifts, NEW_NAME - end -end diff --git a/db/migrate/20210201034649_add_active_periods_to_on_call_rotations.rb b/db/migrate/20210201034649_add_active_periods_to_on_call_rotations.rb deleted file mode 100644 index 714187f60e0..00000000000 --- a/db/migrate/20210201034649_add_active_periods_to_on_call_rotations.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddActivePeriodsToOnCallRotations < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :incident_management_oncall_rotations, :active_period_start, :time, null: true - add_column :incident_management_oncall_rotations, :active_period_end, :time, null: true - end -end diff --git a/db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb b/db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb deleted file mode 100644 index a3fed9e576a..00000000000 --- a/db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -class AddOldestMergeRequestsIndexAgain < ActiveRecord::Migration[6.0] - include Gitlab::Database::SchemaHelpers - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - - INDEX = 'index_on_merge_requests_for_latest_diffs' - - def up - execute "DROP INDEX CONCURRENTLY #{INDEX}" if invalid_index? - - return if index_exists_by_name?('merge_requests', INDEX) - - begin - disable_statement_timeout do - execute "CREATE INDEX CONCURRENTLY #{INDEX} ON merge_requests " \ - 'USING btree (target_project_id) INCLUDE (id, latest_merge_request_diff_id)' - end - rescue ActiveRecord::StatementInvalid => ex - # Due to https://github.com/lfittl/pg_query/issues/184, if the CREATE - # INDEX statement fails, we trigger a separate error due to the Gem not - # supporting the INCLUDE syntax. - # - # To work around this, we raise a custom error instead, as these won't - # have a query context injected. - raise "The index #{INDEX} couldn't be added: #{ex.message}" - end - - create_comment( - 'INDEX', - INDEX, - 'Index used to efficiently obtain the oldest merge request for a commit SHA' - ) - end - - def down - return unless index_exists_by_name?('merge_requests', INDEX) - - disable_statement_timeout do - execute "DROP INDEX CONCURRENTLY #{INDEX}" - end - end - - def invalid_index? - result = execute(<<~SQL) - SELECT pg_class.relname - FROM pg_class, pg_index - WHERE pg_index.indisvalid = false - AND pg_index.indexrelid = pg_class.oid - AND pg_class.relname = '#{INDEX}'; - SQL - - result.values.any? - end -end diff --git a/db/migrate/20210203002331_drop_backup_label_index.rb b/db/migrate/20210203002331_drop_backup_label_index.rb deleted file mode 100644 index 430d2d0fb79..00000000000 --- a/db/migrate/20210203002331_drop_backup_label_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class DropBackupLabelIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'backup_labels_project_id_title_idx' - - def up - remove_concurrent_index_by_name(:backup_labels, name: INDEX_NAME) - end - - def down - add_concurrent_index :backup_labels, [:project_id, :title], name: INDEX_NAME, unique: true, where: 'group_id = NULL::integer' - end -end diff --git a/db/migrate/20210203092540_remove_has_external_wiki_constraint.rb b/db/migrate/20210203092540_remove_has_external_wiki_constraint.rb deleted file mode 100644 index 80b0cc11685..00000000000 --- a/db/migrate/20210203092540_remove_has_external_wiki_constraint.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveHasExternalWikiConstraint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - # This reverts the following migration: add_not_null_constraint :projects, :has_external_wiki, validate: false - if check_not_null_constraint_exists?(:projects, :has_external_wiki) - remove_not_null_constraint :projects, :has_external_wiki - end - end - - def down - # no-op - end -end diff --git a/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb b/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb deleted file mode 100644 index 37111b370a5..00000000000 --- a/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class RestoreHasExternalWikiDefaultValue < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class TmpProject < ActiveRecord::Base - self.table_name = 'projects' - end - - # This reverts the following migration: change_column_default(:projects, :has_external_wiki, from: nil, to: false) - # We only change the column when the current default value is false - def up - # Find out the current default value - column = TmpProject.columns.find { |c| c.name == 'has_external_wiki' } - return unless column - - if column.default == 'false' - with_lock_retries do - change_column_default(:projects, :has_external_wiki, from: false, to: nil) - end - end - end - - def down - # no-op - end -end diff --git a/db/migrate/20210203221631_create_packages_rubygems_metadata.rb b/db/migrate/20210203221631_create_packages_rubygems_metadata.rb deleted file mode 100644 index f4ad5abf7e5..00000000000 --- a/db/migrate/20210203221631_create_packages_rubygems_metadata.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -class CreatePackagesRubygemsMetadata < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - create_table_with_constraints :packages_rubygems_metadata, id: false do |t| - t.timestamps_with_timezone - t.references :package, primary_key: true, index: false, default: nil, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint - t.text :authors - t.text :files - t.text :summary - - t.text :description - t.text :email - t.text :homepage - t.text :licenses - t.text :metadata - - t.text :author - t.text :bindir - t.text :cert_chain - t.text :executables - t.text :extensions - t.text :extra_rdoc_files - t.text :platform - t.text :post_install_message - t.text :rdoc_options - t.text :require_paths - t.text :required_ruby_version - t.text :required_rubygems_version - t.text :requirements - t.text :rubygems_version - t.text :signing_key - - t.text_limit :authors, 255 - t.text_limit :files, 255 - t.text_limit :summary, 1024 - - t.text_limit :description, 1024 - t.text_limit :email, 255 - t.text_limit :homepage, 255 - t.text_limit :licenses, 255 - t.text_limit :metadata, 255 - - t.text_limit :author, 255 - t.text_limit :bindir, 255 - t.text_limit :cert_chain, 255 - t.text_limit :executables, 255 - t.text_limit :extensions, 255 - t.text_limit :extra_rdoc_files, 255 - t.text_limit :platform, 255 - t.text_limit :post_install_message, 255 - t.text_limit :rdoc_options, 255 - t.text_limit :require_paths, 255 - t.text_limit :required_ruby_version, 255 - t.text_limit :required_rubygems_version, 255 - t.text_limit :requirements, 255 - t.text_limit :rubygems_version, 255 - t.text_limit :signing_key, 255 - end - end - - def down - drop_table :packages_rubygems_metadata - end -end diff --git a/db/migrate/20210203222620_add_expired_index_to_composer_cache_files.rb b/db/migrate/20210203222620_add_expired_index_to_composer_cache_files.rb deleted file mode 100644 index 9c6a27812a5..00000000000 --- a/db/migrate/20210203222620_add_expired_index_to_composer_cache_files.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddExpiredIndexToComposerCacheFiles < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'composer_cache_files_index_on_deleted_at' - - def up - add_concurrent_index :packages_composer_cache_files, [:delete_at, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_composer_cache_files, INDEX_NAME - end -end diff --git a/db/migrate/20210203223551_add_orphan_index_to_composer_cache_files.rb b/db/migrate/20210203223551_add_orphan_index_to_composer_cache_files.rb deleted file mode 100644 index e2853977e5f..00000000000 --- a/db/migrate/20210203223551_add_orphan_index_to_composer_cache_files.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddOrphanIndexToComposerCacheFiles < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_composer_cache_files_where_namespace_id_is_null' - - def up - add_concurrent_index :packages_composer_cache_files, :id, name: INDEX_NAME, where: 'namespace_id IS NULL' - end - - def down - remove_concurrent_index_by_name :packages_composer_cache_files, INDEX_NAME - end -end diff --git a/db/migrate/20210204152257_add_status_to_packages_packages.rb b/db/migrate/20210204152257_add_status_to_packages_packages.rb deleted file mode 100644 index 4fd441048c6..00000000000 --- a/db/migrate/20210204152257_add_status_to_packages_packages.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddStatusToPackagesPackages < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :packages_packages, :status, :smallint, default: 0, null: false - end -end diff --git a/db/migrate/20210204212850_add_group_id_to_ci_daily_build_group_report_results.rb b/db/migrate/20210204212850_add_group_id_to_ci_daily_build_group_report_results.rb deleted file mode 100644 index ba0464f5ad6..00000000000 --- a/db/migrate/20210204212850_add_group_id_to_ci_daily_build_group_report_results.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddGroupIdToCiDailyBuildGroupReportResults < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column(:ci_daily_build_group_report_results, :group_id, :bigint) - end -end diff --git a/db/migrate/20210205084357_create_ci_project_monthly_usage.rb b/db/migrate/20210205084357_create_ci_project_monthly_usage.rb deleted file mode 100644 index c91bfa5ee1c..00000000000 --- a/db/migrate/20210205084357_create_ci_project_monthly_usage.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class CreateCiProjectMonthlyUsage < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - with_lock_retries do - create_table :ci_project_monthly_usages, if_not_exists: true do |t| - t.references :project, foreign_key: { on_delete: :cascade }, index: false, null: false - t.date :date, null: false - t.decimal :amount_used, null: false, default: 0.0, precision: 18, scale: 2 - - t.index [:project_id, :date], unique: true - end - end - - add_check_constraint :ci_project_monthly_usages, "(date = date_trunc('month', date))", 'ci_project_monthly_usages_year_month_constraint' - end - - def down - with_lock_retries do - drop_table :ci_project_monthly_usages - end - end -end diff --git a/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb b/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb deleted file mode 100644 index c01335767a8..00000000000 --- a/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddCreatorIdToCustomEmoji < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - # Custom Emoji is at the moment behind a default-disabled feature flag. It - # will be unlikely there are any records in this table, but to able to - # ensure a not-null constraint delete any existing rows. - # Roll-out issue: https://gitlab.com/gitlab-org/gitlab/-/issues/231317 - execute 'DELETE FROM custom_emoji' - - add_reference :custom_emoji, # rubocop:disable Migration/AddReference - :creator, - index: true, - null: false, # rubocop:disable Rails/NotNullColumn - foreign_key: false # FK is added in 20210219100137 - end - - def down - remove_reference :custom_emoji, :creator - end -end diff --git a/db/migrate/20210205143926_remove_namespace_id_foreign_key_on_namespace_onboarding_actions.rb b/db/migrate/20210205143926_remove_namespace_id_foreign_key_on_namespace_onboarding_actions.rb deleted file mode 100644 index 6fe66430dd0..00000000000 --- a/db/migrate/20210205143926_remove_namespace_id_foreign_key_on_namespace_onboarding_actions.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespaceIdForeignKeyOnNamespaceOnboardingActions < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - remove_foreign_key :namespace_onboarding_actions, :namespaces - end - end - - def down - with_lock_retries do - add_foreign_key :namespace_onboarding_actions, :namespaces, on_delete: :cascade - end - end -end diff --git a/db/migrate/20210205213915_remove_foreign_keys_from_alerts_service_data.rb b/db/migrate/20210205213915_remove_foreign_keys_from_alerts_service_data.rb deleted file mode 100644 index 1d539f783b4..00000000000 --- a/db/migrate/20210205213915_remove_foreign_keys_from_alerts_service_data.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class RemoveForeignKeysFromAlertsServiceData < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - remove_foreign_key_if_exists :alerts_service_data, column: :service_id - end - end - - def down - with_lock_retries do - add_foreign_key :alerts_service_data, :services, column: :service_id, on_delete: :cascade - end - end -end diff --git a/db/migrate/20210208103243_add_issue_created_at_to_onboarding_progress.rb b/db/migrate/20210208103243_add_issue_created_at_to_onboarding_progress.rb deleted file mode 100644 index e8318ecd929..00000000000 --- a/db/migrate/20210208103243_add_issue_created_at_to_onboarding_progress.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddIssueCreatedAtToOnboardingProgress < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :onboarding_progresses, :issue_created_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20210208125050_add_status_expires_at_to_user_statuses.rb b/db/migrate/20210208125050_add_status_expires_at_to_user_statuses.rb deleted file mode 100644 index 3ec1f6014a8..00000000000 --- a/db/migrate/20210208125050_add_status_expires_at_to_user_statuses.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddStatusExpiresAtToUserStatuses < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column(:user_statuses, :clear_status_at, :datetime_with_timezone, null: true) - end - end - - def down - with_lock_retries do - remove_column(:user_statuses, :clear_status_at) - end - end -end diff --git a/db/migrate/20210208125248_add_index_on_user_statuses_status_expires_at.rb b/db/migrate/20210208125248_add_index_on_user_statuses_status_expires_at.rb deleted file mode 100644 index 98f3449c2e8..00000000000 --- a/db/migrate/20210208125248_add_index_on_user_statuses_status_expires_at.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnUserStatusesStatusExpiresAt < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_user_statuses_on_clear_status_at_not_null' - - disable_ddl_transaction! - - def up - add_concurrent_index(:user_statuses, :clear_status_at, name: INDEX_NAME, where: 'clear_status_at IS NOT NULL') - end - - def down - remove_concurrent_index_by_name(:user_statuses, INDEX_NAME) - end -end diff --git a/db/migrate/20210208144134_add_index_group_id_to_ci_daily_build_group_report_results.rb b/db/migrate/20210208144134_add_index_group_id_to_ci_daily_build_group_report_results.rb deleted file mode 100644 index 422d8174043..00000000000 --- a/db/migrate/20210208144134_add_index_group_id_to_ci_daily_build_group_report_results.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddIndexGroupIdToCiDailyBuildGroupReportResults < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_ci_daily_build_group_report_results_on_group_id' - - disable_ddl_transaction! - - def up - add_concurrent_index(:ci_daily_build_group_report_results, :group_id, name: INDEX_NAME) - add_concurrent_foreign_key(:ci_daily_build_group_report_results, :namespaces, column: :group_id) - end - - def down - remove_foreign_key_if_exists(:ci_daily_build_group_report_results, column: :group_id) - remove_concurrent_index_by_name(:ci_daily_build_group_report_results, INDEX_NAME) - end -end diff --git a/db/migrate/20210208161207_add_notes_create_limit_to_application_settings.rb b/db/migrate/20210208161207_add_notes_create_limit_to_application_settings.rb deleted file mode 100644 index 4468da77e6c..00000000000 --- a/db/migrate/20210208161207_add_notes_create_limit_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddNotesCreateLimitToApplicationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :application_settings, :notes_create_limit, :integer, default: 300, null: false - end -end diff --git a/db/migrate/20210208200914_add_ends_at_to_oncall_rotations.rb b/db/migrate/20210208200914_add_ends_at_to_oncall_rotations.rb deleted file mode 100644 index 5cd179c9a80..00000000000 --- a/db/migrate/20210208200914_add_ends_at_to_oncall_rotations.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddEndsAtToOncallRotations < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :incident_management_oncall_rotations, :ends_at, :datetime_with_timezone - end -end diff --git a/db/migrate/20210209110019_create_external_approval_rules.rb b/db/migrate/20210209110019_create_external_approval_rules.rb deleted file mode 100644 index 5d6780ec412..00000000000 --- a/db/migrate/20210209110019_create_external_approval_rules.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -class CreateExternalApprovalRules < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - create_table_with_constraints :external_approval_rules, if_not_exists: true do |t| - t.references :project, foreign_key: { on_delete: :cascade }, null: false, index: false - t.timestamps_with_timezone - t.text :external_url, null: false - t.text_limit :external_url, 255 - t.text :name, null: false - t.text_limit :name, 255 - - t.index([:project_id, :name], - unique: true, - name: 'idx_on_external_approval_rules_project_id_name') - t.index([:project_id, :external_url], - unique: true, - name: 'idx_on_external_approval_rules_project_id_external_url') - end - - create_table :external_approval_rules_protected_branches do |t| - t.bigint :external_approval_rule_id, null: false, index: { name: 'idx_eaprpb_external_approval_rule_id' } - t.bigint :protected_branch_id, null: false - t.index([:protected_branch_id, :external_approval_rule_id], - unique: true, - name: 'idx_protected_branch_id_external_approval_rule_id') - end - end - - def down - with_lock_retries do - drop_table :external_approval_rules_protected_branches, force: :cascade, if_exists: true - end - - with_lock_retries do - drop_table :external_approval_rules, force: :cascade, if_exists: true - end - end -end diff --git a/db/migrate/20210209160510_create_security_orchestration_policy_configurations.rb b/db/migrate/20210209160510_create_security_orchestration_policy_configurations.rb deleted file mode 100644 index 896593c803f..00000000000 --- a/db/migrate/20210209160510_create_security_orchestration_policy_configurations.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class CreateSecurityOrchestrationPolicyConfigurations < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_PREFIX = 'index_sop_configs_' - - def up - table_comment = { owner: 'group::container security', description: 'Configuration used to store relationship between project and security policy repository' } - - create_table_with_constraints :security_orchestration_policy_configurations, comment: table_comment.to_json do |t| - t.references :project, null: false, foreign_key: { to_table: :projects, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_project_id', unique: true } - t.references :security_policy_management_project, null: false, foreign_key: { to_table: :projects, on_delete: :restrict }, index: { name: INDEX_PREFIX + 'on_security_policy_management_project_id', unique: true } - - t.timestamps_with_timezone - end - end - - def down - with_lock_retries do - drop_table :security_orchestration_policy_configurations, force: :cascade - end - end -end diff --git a/db/migrate/20210209171525_add_status_index_to_packages_packages.rb b/db/migrate/20210209171525_add_status_index_to_packages_packages.rb deleted file mode 100644 index cb956165d6e..00000000000 --- a/db/migrate/20210209171525_add_status_index_to_packages_packages.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddStatusIndexToPackagesPackages < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_packages_on_project_id_and_status' - - def up - add_concurrent_index :packages_packages, [:project_id, :status], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_packages, name: INDEX_NAME - end -end diff --git a/db/migrate/20210209232508_add_markdown_surround_selection_to_user_preferences.rb b/db/migrate/20210209232508_add_markdown_surround_selection_to_user_preferences.rb deleted file mode 100644 index c4063a55d18..00000000000 --- a/db/migrate/20210209232508_add_markdown_surround_selection_to_user_preferences.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddMarkdownSurroundSelectionToUserPreferences < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :user_preferences, :markdown_surround_selection, :boolean, default: true, null: false - end - end - - def down - with_lock_retries do - remove_column :user_preferences, :markdown_surround_selection, :boolean - end - end -end diff --git a/db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb b/db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb deleted file mode 100644 index 56feed3688c..00000000000 --- a/db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddNotesCreateLimitAllowlistToApplicationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :application_settings, :notes_create_limit_allowlist, :text, array: true, default: [], null: false - end -end diff --git a/db/migrate/20210211195543_add_created_by_user_for_cluster_agent_token.rb b/db/migrate/20210211195543_add_created_by_user_for_cluster_agent_token.rb deleted file mode 100644 index 94dc8192037..00000000000 --- a/db/migrate/20210211195543_add_created_by_user_for_cluster_agent_token.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class AddCreatedByUserForClusterAgentToken < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_cluster_agent_tokens_on_created_by_user_id' - - disable_ddl_transaction! - - def up - unless column_exists?(:cluster_agent_tokens, :created_by_user_id) - add_column :cluster_agent_tokens, :created_by_user_id, :bigint - end - - add_concurrent_index :cluster_agent_tokens, :created_by_user_id, name: INDEX_NAME - add_concurrent_foreign_key :cluster_agent_tokens, :users, column: :created_by_user_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :cluster_agent_tokens, :users, column: :created_by_user_id - end - - remove_concurrent_index_by_name :cluster_agent_tokens, INDEX_NAME - remove_column :cluster_agent_tokens, :created_by_user_id - end -end diff --git a/db/migrate/20210212153934_make_the_geo_oauth_application_trusted_by_default.rb b/db/migrate/20210212153934_make_the_geo_oauth_application_trusted_by_default.rb deleted file mode 100644 index ab0343887e4..00000000000 --- a/db/migrate/20210212153934_make_the_geo_oauth_application_trusted_by_default.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class MakeTheGeoOauthApplicationTrustedByDefault < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - execute(<<-SQL.squish) - UPDATE oauth_applications - SET confidential = true, trusted = true - WHERE id IN (SELECT oauth_application_id FROM geo_nodes); - SQL - end - - def down - # We won't be able to tell which trusted applications weren't - # confidential before the migration and setting all trusted - # applications are not confidential would introduce security - # issues. - end -end diff --git a/db/migrate/20210212163231_add_merge_when_pipeline_succeeds_to_notification_settings.rb b/db/migrate/20210212163231_add_merge_when_pipeline_succeeds_to_notification_settings.rb deleted file mode 100644 index 08d0a99436e..00000000000 --- a/db/migrate/20210212163231_add_merge_when_pipeline_succeeds_to_notification_settings.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 AddMergeWhenPipelineSucceedsToNotificationSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :notification_settings, :merge_when_pipeline_succeeds, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210214201118_add_delayed_project_removal_to_namespace_settings.rb b/db/migrate/20210214201118_add_delayed_project_removal_to_namespace_settings.rb deleted file mode 100644 index 1c6e0b0c27c..00000000000 --- a/db/migrate/20210214201118_add_delayed_project_removal_to_namespace_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddDelayedProjectRemovalToNamespaceSettings < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :namespace_settings, :delayed_project_removal, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210214205155_add_index_to_namespaces_delayed_project_removal.rb b/db/migrate/20210214205155_add_index_to_namespaces_delayed_project_removal.rb deleted file mode 100644 index 8d09a5c9269..00000000000 --- a/db/migrate/20210214205155_add_index_to_namespaces_delayed_project_removal.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToNamespacesDelayedProjectRemoval < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'tmp_idx_on_namespaces_delayed_project_removal' - - disable_ddl_transaction! - - def up - add_concurrent_index :namespaces, :id, name: INDEX_NAME, where: 'delayed_project_removal = TRUE' - end - - def down - remove_concurrent_index_by_name :namespaces, INDEX_NAME - end -end diff --git a/db/migrate/20210215172449_remove_artifact_expiry_temp_index.rb b/db/migrate/20210215172449_remove_artifact_expiry_temp_index.rb deleted file mode 100644 index 1e6619731a2..00000000000 --- a/db/migrate/20210215172449_remove_artifact_expiry_temp_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveArtifactExpiryTempIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'expired_artifacts_temp_index' - INDEX_CONDITION = "expire_at IS NULL AND date(created_at AT TIME ZONE 'UTC') < '2020-06-22'::date" - - def up - remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME - end - - def down - add_concurrent_index(:ci_job_artifacts, %i(id created_at), where: INDEX_CONDITION, name: INDEX_NAME) - end -end diff --git a/db/migrate/20210216122140_add_in_product_marketing_emails_enabled_setting.rb b/db/migrate/20210216122140_add_in_product_marketing_emails_enabled_setting.rb deleted file mode 100644 index 5813b1b5f33..00000000000 --- a/db/migrate/20210216122140_add_in_product_marketing_emails_enabled_setting.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddInProductMarketingEmailsEnabledSetting < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :application_settings, :in_product_marketing_emails_enabled, :boolean, null: false, default: true - end -end diff --git a/db/migrate/20210216135504_add_created_by_to_cluster_agent.rb b/db/migrate/20210216135504_add_created_by_to_cluster_agent.rb deleted file mode 100644 index fd679a1c525..00000000000 --- a/db/migrate/20210216135504_add_created_by_to_cluster_agent.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class AddCreatedByToClusterAgent < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_cluster_agents_on_created_by_user_id' - - disable_ddl_transaction! - - def up - unless column_exists?(:cluster_agents, :created_by_user_id) - with_lock_retries do - add_column :cluster_agents, :created_by_user_id, :bigint - end - end - - add_concurrent_index :cluster_agents, :created_by_user_id, name: INDEX_NAME - add_concurrent_foreign_key :cluster_agents, :users, column: :created_by_user_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_column :cluster_agents, :created_by_user_id - end - end -end diff --git a/db/migrate/20210216193620_add_description_to_cluster_token.rb b/db/migrate/20210216193620_add_description_to_cluster_token.rb deleted file mode 100644 index 67f7c6bd522..00000000000 --- a/db/migrate/20210216193620_add_description_to_cluster_token.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddDescriptionToClusterToken < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - unless column_exists?(:cluster_agent_tokens, :description) - add_column :cluster_agent_tokens, :description, :text - end - - add_text_limit :cluster_agent_tokens, :description, 1024 - end - - def down - remove_column :cluster_agent_tokens, :description - end -end diff --git a/db/migrate/20210216223335_remove_index_on_issues_where_service_desk_reply_to_is_not_null.rb b/db/migrate/20210216223335_remove_index_on_issues_where_service_desk_reply_to_is_not_null.rb deleted file mode 100644 index 5224b6f7031..00000000000 --- a/db/migrate/20210216223335_remove_index_on_issues_where_service_desk_reply_to_is_not_null.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexOnIssuesWhereServiceDeskReplyToIsNotNull < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - INDEX_TABLE = :issues - INDEX_NAME = 'idx_on_issues_where_service_desk_reply_to_is_not_null' - - def up - Gitlab::BackgroundMigration.steal('PopulateIssueEmailParticipants') - remove_concurrent_index_by_name INDEX_TABLE, INDEX_NAME - end - - def down - add_concurrent_index(INDEX_TABLE, [:id], name: INDEX_NAME, where: 'service_desk_reply_to IS NOT NULL') - end -end diff --git a/db/migrate/20210217101901_create_epic_list_user_preferences.rb b/db/migrate/20210217101901_create_epic_list_user_preferences.rb deleted file mode 100644 index 5aacea1938d..00000000000 --- a/db/migrate/20210217101901_create_epic_list_user_preferences.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class CreateEpicListUserPreferences < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def up - create_table :boards_epic_list_user_preferences do |t| - t.bigint :user_id, null: false - t.bigint :epic_list_id, index: true, null: false - t.timestamps_with_timezone null: false - t.boolean :collapsed, null: false, default: false - end - - add_index :boards_epic_list_user_preferences, [:user_id, :epic_list_id], unique: true, name: 'index_epic_board_list_preferences_on_user_and_list' - end - - def down - drop_table :boards_epic_list_user_preferences - end -end diff --git a/db/migrate/20210218040814_add_environment_scope_to_group_variables.rb b/db/migrate/20210218040814_add_environment_scope_to_group_variables.rb deleted file mode 100644 index 5cc41f570aa..00000000000 --- a/db/migrate/20210218040814_add_environment_scope_to_group_variables.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -class AddEnvironmentScopeToGroupVariables < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - OLD_INDEX = 'index_ci_group_variables_on_group_id_and_key' - NEW_INDEX = 'index_ci_group_variables_on_group_id_and_key_and_environment' - - disable_ddl_transaction! - - def up - unless column_exists?(:ci_group_variables, :environment_scope) - # rubocop:disable Migration/AddLimitToTextColumns - # Added in 20210305013509_add_text_limit_to_group_ci_variables_environment_scope - add_column :ci_group_variables, :environment_scope, :text, null: false, default: '*' - # rubocop:enable Migration/AddLimitToTextColumns - end - - add_concurrent_index :ci_group_variables, [:group_id, :key, :environment_scope], unique: true, name: NEW_INDEX - remove_concurrent_index_by_name :ci_group_variables, OLD_INDEX - end - - def down - remove_duplicates! - - add_concurrent_index :ci_group_variables, [:group_id, :key], unique: true, name: OLD_INDEX - remove_concurrent_index_by_name :ci_group_variables, NEW_INDEX - - remove_column :ci_group_variables, :environment_scope - end - - private - - def remove_duplicates! - execute <<-SQL - DELETE FROM ci_group_variables - WHERE id NOT IN ( - SELECT MIN(id) - FROM ci_group_variables - GROUP BY group_id, key - ) - SQL - end -end diff --git a/db/migrate/20210218142626_change_finding_fingerprint_enum.rb b/db/migrate/20210218142626_change_finding_fingerprint_enum.rb deleted file mode 100644 index 615509e0c04..00000000000 --- a/db/migrate/20210218142626_change_finding_fingerprint_enum.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ChangeFindingFingerprintEnum < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - change_column :vulnerability_finding_fingerprints, :algorithm_type, :integer, limit: 2 - end - - def down - change_column :vulnerability_finding_fingerprints, :algorithm_type, :integer - end -end diff --git a/db/migrate/20210218144056_add_sprints_start_date_not_null_check_constraint.rb b/db/migrate/20210218144056_add_sprints_start_date_not_null_check_constraint.rb deleted file mode 100644 index 243080f49b2..00000000000 --- a/db/migrate/20210218144056_add_sprints_start_date_not_null_check_constraint.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddSprintsStartDateNotNullCheckConstraint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_not_null_constraint(:sprints, :start_date, validate: false) - end - - def down - remove_not_null_constraint(:sprints, :start_date) - end -end diff --git a/db/migrate/20210218144656_add_sprints_due_date_not_null_check_constraint.rb b/db/migrate/20210218144656_add_sprints_due_date_not_null_check_constraint.rb deleted file mode 100644 index 9f3ed6fd13a..00000000000 --- a/db/migrate/20210218144656_add_sprints_due_date_not_null_check_constraint.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddSprintsDueDateNotNullCheckConstraint < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_not_null_constraint(:sprints, :due_date, validate: false) - end - - def down - remove_not_null_constraint(:sprints, :due_date) - end -end diff --git a/db/migrate/20210219100137_add_creator_foreign_key_to_custom_emoji.rb b/db/migrate/20210219100137_add_creator_foreign_key_to_custom_emoji.rb deleted file mode 100644 index a954ba5ba3b..00000000000 --- a/db/migrate/20210219100137_add_creator_foreign_key_to_custom_emoji.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddCreatorForeignKeyToCustomEmoji < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - FK_NAME = 'fk_custom_emoji_creator_id' - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :custom_emoji, :users, - on_delete: :cascade, - column: :creator_id, - name: FK_NAME - end - - def down - with_lock_retries do - remove_foreign_key :custom_emoji, name: FK_NAME - end - end -end diff --git a/db/migrate/20210219111040_add_epic_issue_composite_index.rb b/db/migrate/20210219111040_add_epic_issue_composite_index.rb deleted file mode 100644 index f1344baf0c7..00000000000 --- a/db/migrate/20210219111040_add_epic_issue_composite_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddEpicIssueCompositeIndex < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - INDEX_NAME = 'index_epic_issues_on_epic_id_and_issue_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :epic_issues, [:epic_id, :issue_id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :epic_issues, INDEX_NAME - end -end diff --git a/db/migrate/20210219211845_add_version_usage_data_id_to_raw_usage_data.rb b/db/migrate/20210219211845_add_version_usage_data_id_to_raw_usage_data.rb deleted file mode 100644 index 1b49fdd98bd..00000000000 --- a/db/migrate/20210219211845_add_version_usage_data_id_to_raw_usage_data.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddVersionUsageDataIdToRawUsageData < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :raw_usage_data, :version_usage_data_id_value, :bigint - end -end diff --git a/db/migrate/20210222030537_add_is_removed_to_oncall_participant.rb b/db/migrate/20210222030537_add_is_removed_to_oncall_participant.rb deleted file mode 100644 index 83b81a067ab..00000000000 --- a/db/migrate/20210222030537_add_is_removed_to_oncall_participant.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddIsRemovedToOncallParticipant < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :incident_management_oncall_participants, :is_removed, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :incident_management_oncall_participants, :is_removed - end - end -end diff --git a/db/migrate/20210222042745_add_is_removed_index_to_oncall_participant.rb b/db/migrate/20210222042745_add_is_removed_index_to_oncall_participant.rb deleted file mode 100644 index cfa9b1b89c9..00000000000 --- a/db/migrate/20210222042745_add_is_removed_index_to_oncall_participant.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddIsRemovedIndexToOncallParticipant < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - disable_ddl_transaction! - - DOWNTIME = false - EXISTING_INDEX_NAME = 'index_inc_mgmnt_oncall_participants_on_oncall_rotation_id' - NEW_INDEX_NAME = 'index_inc_mgmnt_oncall_pcpnt_on_oncall_rotation_id_is_removed' - - def up - add_concurrent_index :incident_management_oncall_participants, [:oncall_rotation_id, :is_removed], name: NEW_INDEX_NAME - remove_concurrent_index_by_name(:incident_management_oncall_participants, EXISTING_INDEX_NAME) - end - - def down - add_concurrent_index :incident_management_oncall_participants, :oncall_rotation_id, name: EXISTING_INDEX_NAME - remove_concurrent_index_by_name(:incident_management_oncall_participants, NEW_INDEX_NAME) - end -end diff --git a/db/migrate/20210222070356_add_storage_size_to_namespace_statistics.rb b/db/migrate/20210222070356_add_storage_size_to_namespace_statistics.rb deleted file mode 100644 index 838c22382c6..00000000000 --- a/db/migrate/20210222070356_add_storage_size_to_namespace_statistics.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddStorageSizeToNamespaceStatistics < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :namespace_statistics, :storage_size, :bigint, default: 0, null: false - end - end - - def down - with_lock_retries do - remove_column :namespace_statistics, :storage_size - end - end -end diff --git a/db/migrate/20210222070413_add_wiki_size_to_namespace_statistics.rb b/db/migrate/20210222070413_add_wiki_size_to_namespace_statistics.rb deleted file mode 100644 index 9e6ced9fd64..00000000000 --- a/db/migrate/20210222070413_add_wiki_size_to_namespace_statistics.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddWikiSizeToNamespaceStatistics < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :namespace_statistics, :wiki_size, :bigint, default: 0, null: false - end - end - - def down - with_lock_retries do - remove_column :namespace_statistics, :wiki_size - end - end -end diff --git a/db/migrate/20210222085529_add_epic_board_user_preference_user_fk.rb b/db/migrate/20210222085529_add_epic_board_user_preference_user_fk.rb deleted file mode 100644 index 52de892a177..00000000000 --- a/db/migrate/20210222085529_add_epic_board_user_preference_user_fk.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddEpicBoardUserPreferenceUserFk < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :boards_epic_list_user_preferences, :users, column: :user_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :boards_epic_list_user_preferences, :users - end - end -end diff --git a/db/migrate/20210222085551_add_epic_board_user_preference_epic_list_fk.rb b/db/migrate/20210222085551_add_epic_board_user_preference_epic_list_fk.rb deleted file mode 100644 index 3f62036b899..00000000000 --- a/db/migrate/20210222085551_add_epic_board_user_preference_epic_list_fk.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddEpicBoardUserPreferenceEpicListFk < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :boards_epic_list_user_preferences, :boards_epic_lists, column: :epic_list_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :boards_epic_list_user_preferences, :boards_epic_lists - end - end -end diff --git a/db/migrate/20210222105120_add_container_registry_access_level.rb b/db/migrate/20210222105120_add_container_registry_access_level.rb deleted file mode 100644 index 2324866b0ef..00000000000 --- a/db/migrate/20210222105120_add_container_registry_access_level.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class AddContainerRegistryAccessLevel < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column( - :project_features, - :container_registry_access_level, - :integer, - default: 0, # ProjectFeature::DISABLED value - null: false - ) - end - end - - def down - with_lock_retries do - remove_column :project_features, :container_registry_access_level - end - end -end diff --git a/db/migrate/20210223053451_add_branch_name_to_dast_profile.rb b/db/migrate/20210223053451_add_branch_name_to_dast_profile.rb deleted file mode 100644 index 311e809103f..00000000000 --- a/db/migrate/20210223053451_add_branch_name_to_dast_profile.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddBranchNameToDastProfile < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - with_lock_retries do - add_column :dast_profiles, :branch_name, :text - end - - add_text_limit :dast_profiles, :branch_name, 255 - end - - def down - with_lock_retries do - remove_column :dast_profiles, :branch_name - end - end -end diff --git a/db/migrate/20210223132934_add_foreign_key_to_external_approval_rules.rb b/db/migrate/20210223132934_add_foreign_key_to_external_approval_rules.rb deleted file mode 100644 index b5f04672813..00000000000 --- a/db/migrate/20210223132934_add_foreign_key_to_external_approval_rules.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToExternalApprovalRules < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :external_approval_rules_protected_branches, :external_approval_rules, column: :external_approval_rule_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :external_approval_rules_protected_branches, column: :external_approval_rule_id - end - end -end diff --git a/db/migrate/20210223133116_add_foreign_key_to_external_approval_rules_protected_branches.rb b/db/migrate/20210223133116_add_foreign_key_to_external_approval_rules_protected_branches.rb deleted file mode 100644 index ad51f765d8a..00000000000 --- a/db/migrate/20210223133116_add_foreign_key_to_external_approval_rules_protected_branches.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToExternalApprovalRulesProtectedBranches < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :external_approval_rules_protected_branches, :protected_branches, column: :protected_branch_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key :external_approval_rules_protected_branches, column: :protected_branch_id - end - end -end diff --git a/db/migrate/20210223230600_update_rubygems_metadata_metadata.rb b/db/migrate/20210223230600_update_rubygems_metadata_metadata.rb deleted file mode 100644 index 39e79be301e..00000000000 --- a/db/migrate/20210223230600_update_rubygems_metadata_metadata.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class UpdateRubygemsMetadataMetadata < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - remove_text_limit :packages_rubygems_metadata, :metadata - add_text_limit :packages_rubygems_metadata, :metadata, 30000 - end - - def down - remove_text_limit :packages_rubygems_metadata, :metadata - add_text_limit :packages_rubygems_metadata, :metadata, 255, validate: false - end -end diff --git a/db/migrate/20210224132547_add_null_constraint_to_terraform_state_name.rb b/db/migrate/20210224132547_add_null_constraint_to_terraform_state_name.rb deleted file mode 100644 index d9f23311cf5..00000000000 --- a/db/migrate/20210224132547_add_null_constraint_to_terraform_state_name.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddNullConstraintToTerraformStateName < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - change_column_null :terraform_states, :name, false - end -end diff --git a/db/migrate/20210224133337_add_name_field_to_cluster_agent_token.rb b/db/migrate/20210224133337_add_name_field_to_cluster_agent_token.rb deleted file mode 100644 index 2cec37f8477..00000000000 --- a/db/migrate/20210224133337_add_name_field_to_cluster_agent_token.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class AddNameFieldToClusterAgentToken < ActiveRecord::Migration[6.0] - DOWNTIME = false - - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in LimitClusterTokenSize - def change - add_column :cluster_agent_tokens, :name, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/migrate/20210224161552_add_jira_issue_transition_automatic_to_jira_tracker_data.rb b/db/migrate/20210224161552_add_jira_issue_transition_automatic_to_jira_tracker_data.rb deleted file mode 100644 index 6c788b9d554..00000000000 --- a/db/migrate/20210224161552_add_jira_issue_transition_automatic_to_jira_tracker_data.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddJiraIssueTransitionAutomaticToJiraTrackerData < ActiveRecord::Migration[6.0] - DOWNTIME = false - - def change - add_column :jira_tracker_data, :jira_issue_transition_automatic, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20210225090801_create_dora_daily_metrics.rb b/db/migrate/20210225090801_create_dora_daily_metrics.rb deleted file mode 100644 index 65c1dbc23e4..00000000000 --- a/db/migrate/20210225090801_create_dora_daily_metrics.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class CreateDoraDailyMetrics < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - with_lock_retries do - create_table :dora_daily_metrics, if_not_exists: true do |t| - t.references :environment, null: false, foreign_key: { on_delete: :cascade }, index: false - t.date :date, null: false - t.integer :deployment_frequency - t.integer :lead_time_for_changes_in_seconds - - t.index [:environment_id, :date], unique: true - end - end - - add_check_constraint :dora_daily_metrics, "deployment_frequency >= 0", 'dora_daily_metrics_deployment_frequency_positive' - add_check_constraint :dora_daily_metrics, "lead_time_for_changes_in_seconds >= 0", 'dora_daily_metrics_lead_time_for_changes_in_seconds_positive' - end - - def down - with_lock_retries do - drop_table :dora_daily_metrics - end - end -end diff --git a/db/migrate/20210225135533_limit_cluster_token_size.rb b/db/migrate/20210225135533_limit_cluster_token_size.rb deleted file mode 100644 index 6a1b6b7b4e8..00000000000 --- a/db/migrate/20210225135533_limit_cluster_token_size.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class LimitClusterTokenSize < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_text_limit :cluster_agent_tokens, :name, 255 - end - - def down - remove_text_limit :cluster_agent_tokens, :name - end -end diff --git a/db/migrate/20210225153522_add_allow_force_push_to_protected_branches.rb b/db/migrate/20210225153522_add_allow_force_push_to_protected_branches.rb deleted file mode 100644 index 92a15cb45dd..00000000000 --- a/db/migrate/20210225153522_add_allow_force_push_to_protected_branches.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddAllowForcePushToProtectedBranches < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :protected_branches, :allow_force_push, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :protected_branches, :allow_force_push - end - end -end diff --git a/db/migrate/20210301150451_add_tier_to_environments.rb b/db/migrate/20210301150451_add_tier_to_environments.rb deleted file mode 100644 index 28592dd2bf6..00000000000 --- a/db/migrate/20210301150451_add_tier_to_environments.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTierToEnvironments < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :environments, :tier, :smallint - end - end - - def down - with_lock_retries do - remove_column :environments, :tier - end - end -end diff --git a/db/migrate/20210301193412_add_optional_to_ci_build_needs.rb b/db/migrate/20210301193412_add_optional_to_ci_build_needs.rb deleted file mode 100644 index 2c6e85f930d..00000000000 --- a/db/migrate/20210301193412_add_optional_to_ci_build_needs.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddOptionalToCiBuildNeeds < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - with_lock_retries do - add_column :ci_build_needs, :optional, :boolean, default: false, null: false - end - end - - def down - with_lock_retries do - remove_column :ci_build_needs, :optional - end - end -end diff --git a/db/migrate/20210301200601_rename_asset_proxy_allowlist_on_application_settings.rb b/db/migrate/20210301200601_rename_asset_proxy_allowlist_on_application_settings.rb deleted file mode 100644 index 8ac334fc6a4..00000000000 --- a/db/migrate/20210301200601_rename_asset_proxy_allowlist_on_application_settings.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RenameAssetProxyAllowlistOnApplicationSettings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers::V2 - - DOWNTIME = false - - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :application_settings, - :asset_proxy_whitelist, - :asset_proxy_allowlist - - rename_column_concurrently :application_settings, - :asset_proxy_allowlist, - :asset_proxy_whitelist - end - - def down - undo_rename_column_concurrently :application_settings, - :asset_proxy_allowlist, - :asset_proxy_whitelist - - undo_cleanup_concurrent_column_rename :application_settings, - :asset_proxy_whitelist, - :asset_proxy_allowlist - end -end diff --git a/db/migrate/20181228175414_init_schema.rb b/db/migrate/20210301200959_init_schema.rb index df68927d79a..df68927d79a 100644 --- a/db/migrate/20181228175414_init_schema.rb +++ b/db/migrate/20210301200959_init_schema.rb diff --git a/db/migrate/20210811193033_add_unique_index_to_vulnerability_finding_links.rb b/db/migrate/20210811193033_add_unique_index_to_vulnerability_finding_links.rb new file mode 100644 index 00000000000..1bcee89ae57 --- /dev/null +++ b/db/migrate/20210811193033_add_unique_index_to_vulnerability_finding_links.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddUniqueIndexToVulnerabilityFindingLinks < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + NAME_URL_INDEX_NAME = 'finding_link_name_url_idx' + URL_INDEX_NAME = 'finding_link_url_idx' + + def up + add_concurrent_index :vulnerability_finding_links, [:vulnerability_occurrence_id, :name, :url], unique: true, name: NAME_URL_INDEX_NAME + add_concurrent_index :vulnerability_finding_links, [:vulnerability_occurrence_id, :url], unique: true, where: 'name is null', name: URL_INDEX_NAME + end + + def down + remove_concurrent_index :vulnerability_finding_links, [:vulnerability_occurrence_id, :name, :url], name: NAME_URL_INDEX_NAME + remove_concurrent_index :vulnerability_finding_links, [:vulnerability_occurrence_id, :url], name: URL_INDEX_NAME + 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 new file mode 100644 index 00000000000..90e68f6a0ac --- /dev/null +++ b/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb @@ -0,0 +1,7 @@ +# 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/20211209230042_add_status_to_cluster_agent_tokens.rb b/db/migrate/20211209230042_add_status_to_cluster_agent_tokens.rb new file mode 100644 index 00000000000..596c82eb209 --- /dev/null +++ b/db/migrate/20211209230042_add_status_to_cluster_agent_tokens.rb @@ -0,0 +1,7 @@ +# 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 new file mode 100644 index 00000000000..1644fbe9000 --- /dev/null +++ b/db/migrate/20211210025754_alter_constraint_of_phone.rb @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 00000000000..5432f6d3d24 --- /dev/null +++ b/db/migrate/20211210031721_change_user_details_phone_text_limit.rb @@ -0,0 +1,15 @@ +# 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/20211213142344_add_settings_user_email_lookup_limit.rb b/db/migrate/20211213142344_add_settings_user_email_lookup_limit.rb new file mode 100644 index 00000000000..ac7027bf082 --- /dev/null +++ b/db/migrate/20211213142344_add_settings_user_email_lookup_limit.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..38ea069a30b --- /dev/null +++ b/db/migrate/20211213154259_add_status_to_packages_package_files.rb @@ -0,0 +1,7 @@ +# 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 new file mode 100644 index 00000000000..7067e3efa6c --- /dev/null +++ b/db/migrate/20211213154704_add_status_index_to_packages_package_files.rb @@ -0,0 +1,15 @@ +# 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/20211215182006_update_application_settings_protected_paths.rb b/db/migrate/20211215182006_update_application_settings_protected_paths.rb new file mode 100644 index 00000000000..f1c1dde55e0 --- /dev/null +++ b/db/migrate/20211215182006_update_application_settings_protected_paths.rb @@ -0,0 +1,58 @@ +# 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 new file mode 100644 index 00000000000..0bbd5c25df4 --- /dev/null +++ b/db/migrate/20211216133107_add_cluster_agent_id_to_vulnerability_reads.rb @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 00000000000..f4776ff10a4 --- /dev/null +++ b/db/migrate/20211216134134_add_text_limit_to_vulnerability_reads_cluster_agent_id.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..05928083823 --- /dev/null +++ b/db/migrate/20211216135651_add_index_to_cluster_agent_id.rb @@ -0,0 +1,16 @@ +# 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 new file mode 100644 index 00000000000..e931aa3709b --- /dev/null +++ b/db/migrate/20211216220939_add_group_crm_settings.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..fa81fa512ae --- /dev/null +++ b/db/migrate/20211217050753_remove_artifacts_archive_id_foreign_key_from_project_pages_metadata.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..cf9f2511176 --- /dev/null +++ b/db/migrate/20211220174504_add_secure_scanning_actions_to_onboarding_progresses.rb @@ -0,0 +1,15 @@ +# 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 new file mode 100644 index 00000000000..7dd2ec1a8aa --- /dev/null +++ b/db/migrate/20211223125921_add_temp_index_to_members_state.rb @@ -0,0 +1,16 @@ +# 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 new file mode 100644 index 00000000000..cb58033361f --- /dev/null +++ b/db/migrate/20211224112937_add_packages_cleanup_package_file_worker_capacity_to_application_settings.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..3a40540a1e1 --- /dev/null +++ b/db/migrate/20211224114539_add_packages_cleanup_package_file_worker_capacity_check_constraint_to_app_settings.rb @@ -0,0 +1,15 @@ +# 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 new file mode 100644 index 00000000000..2cef570966b --- /dev/null +++ b/db/migrate/20220104174445_add_ci_runners_index_on_active_state.rb @@ -0,0 +1,15 @@ +# 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/20220105121325_add_route_namespace_reference.rb b/db/migrate/20220105121325_add_route_namespace_reference.rb new file mode 100644 index 00000000000..77bd0530b8a --- /dev/null +++ b/db/migrate/20220105121325_add_route_namespace_reference.rb @@ -0,0 +1,13 @@ +# 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/20220106141756_remove_lock_version_indexes.rb b/db/migrate/20220106141756_remove_lock_version_indexes.rb new file mode 100644 index 00000000000..382f20dfc73 --- /dev/null +++ b/db/migrate/20220106141756_remove_lock_version_indexes.rb @@ -0,0 +1,23 @@ +# 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/20220106230629_add_registry_migration_application_settings.rb b/db/migrate/20220106230629_add_registry_migration_application_settings.rb new file mode 100644 index 00000000000..191443de6eb --- /dev/null +++ b/db/migrate/20220106230629_add_registry_migration_application_settings.rb @@ -0,0 +1,15 @@ +# 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 new file mode 100644 index 00000000000..76dccbe785f --- /dev/null +++ b/db/migrate/20220106230712_add_migration_columns_to_container_repositories.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..bc1044a24da --- /dev/null +++ b/db/migrate/20220107091629_add_route_namespace_index.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..15b4a3caf78 --- /dev/null +++ b/db/migrate/20220107165036_remove_note_id_index.rb @@ -0,0 +1,16 @@ +# 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 new file mode 100644 index 00000000000..abbd54ff19b --- /dev/null +++ b/db/migrate/20220109133006_remove_ci_pipelines_lock_version_index.rb @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 00000000000..1498a2d0212 --- /dev/null +++ b/db/migrate/20220110170953_create_ci_secure_files.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..969774983c4 --- /dev/null +++ b/db/migrate/20220111095006_add_maintainer_note_to_ci_runners.rb @@ -0,0 +1,12 @@ +# 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 new file mode 100644 index 00000000000..0a0a4171306 --- /dev/null +++ b/db/migrate/20220111095007_add_text_limit_to_ci_runners_maintainer_note.rb @@ -0,0 +1,13 @@ +# 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/20220111200254_remove_index_from_merge_requests.rb b/db/migrate/20220111200254_remove_index_from_merge_requests.rb new file mode 100644 index 00000000000..0ac6019ad5e --- /dev/null +++ b/db/migrate/20220111200254_remove_index_from_merge_requests.rb @@ -0,0 +1,15 @@ +# 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 new file mode 100644 index 00000000000..01fe4f1d5cf --- /dev/null +++ b/db/migrate/20220112115413_add_requires_verification_to_user_details.rb @@ -0,0 +1,9 @@ +# 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 new file mode 100644 index 00000000000..afddec6a134 --- /dev/null +++ b/db/migrate/20220112205111_create_security_training_providers.rb @@ -0,0 +1,14 @@ +# 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 new file mode 100644 index 00000000000..d67ea09a78c --- /dev/null +++ b/db/migrate/20220112232037_add_member_namespace_reference.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..ba32df53ae7 --- /dev/null +++ b/db/migrate/20220112232605_add_member_namespace_index.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..6924c7bd189 --- /dev/null +++ b/db/migrate/20220113125401_create_security_trainings.rb @@ -0,0 +1,18 @@ +# 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/20220114131950_add_status_only_index_to_packages_package_files.rb b/db/migrate/20220114131950_add_status_only_index_to_packages_package_files.rb new file mode 100644 index 00000000000..948edea1138 --- /dev/null +++ b/db/migrate/20220114131950_add_status_only_index_to_packages_package_files.rb @@ -0,0 +1,15 @@ +# 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/20220117225936_add_text_limits_to_container_repositories_migration_columns.rb b/db/migrate/20220117225936_add_text_limits_to_container_repositories_migration_columns.rb new file mode 100644 index 00000000000..91c0612716b --- /dev/null +++ b/db/migrate/20220117225936_add_text_limits_to_container_repositories_migration_columns.rb @@ -0,0 +1,15 @@ +# 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/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 new file mode 100644 index 00000000000..c7247d03423 --- /dev/null +++ b/db/migrate/20220118141950_add_text_limit_to_container_registry_import_target_plan.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..32ca8a5fb12 --- /dev/null +++ b/db/migrate/20220118155846_add_runner_token_expiration_interval_settings_to_application_settings.rb @@ -0,0 +1,9 @@ +# 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 new file mode 100644 index 00000000000..7b83cb2dd55 --- /dev/null +++ b/db/migrate/20220118155847_add_runner_token_expiration_interval_settings_to_namespace_settings.rb @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 00000000000..ef959171828 --- /dev/null +++ b/db/migrate/20220118155848_add_runner_token_expiration_interval_settings_to_project_settings.rb @@ -0,0 +1,9 @@ +# 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 |