diff options
Diffstat (limited to 'db/migrate')
53 files changed, 905 insertions, 39 deletions
diff --git a/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb b/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb index 073faf721ae..86de78b831b 100644 --- a/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb +++ b/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb @@ -4,7 +4,7 @@ class RemovePartialIndexFromCiBuildsArtifactsFile < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts'.freeze + INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts' disable_ddl_transaction! diff --git a/db/migrate/20190402150158_backport_enterprise_schema.rb b/db/migrate/20190402150158_backport_enterprise_schema.rb index dcf84d762a3..c4fbb4b2ab9 100644 --- a/db/migrate/20190402150158_backport_enterprise_schema.rb +++ b/db/migrate/20190402150158_backport_enterprise_schema.rb @@ -198,9 +198,9 @@ class BackportEnterpriseSchema < ActiveRecord::Migration[5.0] # rubocop:enable Migration/DropTable end - def add_column_with_default_if_not_exists(table, name, *args) + def add_column_with_default_if_not_exists(table, name, type, **args) unless column_exists?(table, name) - add_column_with_default(table, name, *args) # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(table, name, type, **args) # rubocop:disable Migration/AddColumnWithDefault end end @@ -226,10 +226,10 @@ class BackportEnterpriseSchema < ActiveRecord::Migration[5.0] end end - def create_table_if_not_exists(name, *args, &block) + def create_table_if_not_exists(name, **args, &block) return if table_exists?(name) - create_table(name, *args, &block) + create_table(name, **args, &block) end def add_concurrent_foreign_key(source, target, column:, on_delete: nil, name: nil) diff --git a/db/migrate/20190709220143_add_index_to_issues_relative_position.rb b/db/migrate/20190709220143_add_index_to_issues_relative_position.rb index effab33ce4f..ec11c6d768f 100644 --- a/db/migrate/20190709220143_add_index_to_issues_relative_position.rb +++ b/db/migrate/20190709220143_add_index_to_issues_relative_position.rb @@ -8,7 +8,7 @@ class AddIndexToIssuesRelativePosition < ActiveRecord::Migration[5.1] disable_ddl_transaction! - INDEX_NAME = 'index_issues_on_project_id_and_state_and_rel_position_and_id'.freeze + INDEX_NAME = 'index_issues_on_project_id_and_state_and_rel_position_and_id' def up add_concurrent_index :issues, [:project_id, :state, :relative_position, :id], order: { id: :desc }, name: INDEX_NAME diff --git a/db/migrate/20190716144222_create_analytics_cycle_analytics_project_stages.rb b/db/migrate/20190716144222_create_analytics_cycle_analytics_project_stages.rb index c03191013dc..5723f6db0a3 100644 --- a/db/migrate/20190716144222_create_analytics_cycle_analytics_project_stages.rb +++ b/db/migrate/20190716144222_create_analytics_cycle_analytics_project_stages.rb @@ -11,19 +11,20 @@ class CreateAnalyticsCycleAnalyticsProjectStages < ActiveRecord::Migration[5.2] t.integer :relative_position t.integer :start_event_identifier, null: false t.integer :end_event_identifier, null: false - t.references(:project, { + + t.references(:project, null: false, foreign_key: { to_table: :projects, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_project_id' } - }) - t.references(:start_event_label, { + ) + t.references(:start_event_label, foreign_key: { to_table: :labels, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_start_event_label_id' } - }) - t.references(:end_event_label, { + ) + t.references(:end_event_label, foreign_key: { to_table: :labels, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_end_event_label_id' } - }) + ) t.boolean :hidden, default: false, null: false t.boolean :custom, default: true, null: false t.string :name, null: false, limit: 255 # rubocop:disable Migration/PreventStrings diff --git a/db/migrate/20190729062536_create_analytics_cycle_analytics_group_stages.rb b/db/migrate/20190729062536_create_analytics_cycle_analytics_group_stages.rb index 4753a7684e7..d438ece9951 100644 --- a/db/migrate/20190729062536_create_analytics_cycle_analytics_group_stages.rb +++ b/db/migrate/20190729062536_create_analytics_cycle_analytics_group_stages.rb @@ -11,19 +11,20 @@ class CreateAnalyticsCycleAnalyticsGroupStages < ActiveRecord::Migration[5.2] t.integer :relative_position t.integer :start_event_identifier, null: false t.integer :end_event_identifier, null: false - t.references(:group, { + + t.references(:group, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_group_id' } - }) - t.references(:start_event_label, { + ) + t.references(:start_event_label, foreign_key: { to_table: :labels, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_start_event_label_id' } - }) - t.references(:end_event_label, { + ) + t.references(:end_event_label, foreign_key: { to_table: :labels, on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_end_event_label_id' } - }) + ) t.boolean :hidden, default: false, null: false t.boolean :custom, default: true, null: false t.string :name, null: false, limit: 255 # rubocop:disable Migration/PreventStrings diff --git a/db/migrate/20190910125852_create_analytics_language_trend_repository_languages.rb b/db/migrate/20190910125852_create_analytics_language_trend_repository_languages.rb index 07da4c20d55..1fc9034655c 100644 --- a/db/migrate/20190910125852_create_analytics_language_trend_repository_languages.rb +++ b/db/migrate/20190910125852_create_analytics_language_trend_repository_languages.rb @@ -7,16 +7,15 @@ class CreateAnalyticsLanguageTrendRepositoryLanguages < ActiveRecord::Migration[ def change create_table :analytics_language_trend_repository_languages, id: false do |t| t.integer :file_count, null: false, default: 0 - t.references :programming_language, { + + t.references :programming_language, null: false, foreign_key: { on_delete: :cascade }, index: false - } - t.references :project, { + t.references :project, null: false, foreign_key: { on_delete: :cascade }, index: { name: INDEX_PREFIX + 'on_project_id' } - } t.integer :loc, null: false, default: 0 t.integer :bytes, null: false, default: 0 # Storing percentage (with 2 decimal places), on 2 bytes. diff --git a/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb b/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb index b88a1f01d79..01272dfad44 100644 --- a/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb +++ b/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb @@ -4,8 +4,8 @@ class AddIndexToEnvironmentsOnProjectIdStateEnvironmentType < ActiveRecord::Migr include Gitlab::Database::MigrationHelpers DOWNTIME = false - OLD_INDEX_NAME = 'index_environments_on_project_id_and_state'.freeze - NEW_INDEX_NAME = 'index_environments_on_project_id_state_environment_type'.freeze + OLD_INDEX_NAME = 'index_environments_on_project_id_and_state' + NEW_INDEX_NAME = 'index_environments_on_project_id_state_environment_type' disable_ddl_transaction! diff --git a/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb b/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb index 4511a2a0e49..4a34b9e791e 100644 --- a/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb +++ b/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb @@ -4,7 +4,7 @@ class AddProjectIdNameVersionPackageTypeIndexToPackagesPackages < ActiveRecord:: include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'idx_packages_packages_on_project_id_name_version_package_type'.freeze + INDEX_NAME = 'idx_packages_packages_on_project_id_name_version_package_type' disable_ddl_transaction! diff --git a/db/migrate/20191129144631_add_index_to_resource_group_id.rb b/db/migrate/20191129144631_add_index_to_resource_group_id.rb index 0e5a84f094d..01d56f417b5 100644 --- a/db/migrate/20191129144631_add_index_to_resource_group_id.rb +++ b/db/migrate/20191129144631_add_index_to_resource_group_id.rb @@ -4,7 +4,7 @@ class AddIndexToResourceGroupId < ActiveRecord::Migration[5.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_for_resource_group'.freeze + INDEX_NAME = 'index_for_resource_group' disable_ddl_transaction! diff --git a/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb b/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb index 5dacc3c0c66..ea92f9cfd32 100644 --- a/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb +++ b/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb @@ -4,7 +4,7 @@ class AddIndexesToDeploymentsOnProjectIdAndRef < ActiveRecord::Migration[5.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'partial_index_deployments_for_project_id_and_tag'.freeze + INDEX_NAME = 'partial_index_deployments_for_project_id_and_tag' disable_ddl_transaction! diff --git a/db/migrate/20200115135234_add_group_index_and_fk_to_import_failures.rb b/db/migrate/20200115135234_add_group_index_and_fk_to_import_failures.rb index ae0d6d31c42..c7f2354440b 100644 --- a/db/migrate/20200115135234_add_group_index_and_fk_to_import_failures.rb +++ b/db/migrate/20200115135234_add_group_index_and_fk_to_import_failures.rb @@ -4,7 +4,7 @@ class AddGroupIndexAndFkToImportFailures < ActiveRecord::Migration[5.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - GROUP_INDEX = 'index_import_failures_on_group_id_not_null'.freeze + GROUP_INDEX = 'index_import_failures_on_group_id_not_null' disable_ddl_transaction! diff --git a/db/migrate/20200117112554_update_project_index_to_import_failures.rb b/db/migrate/20200117112554_update_project_index_to_import_failures.rb index 1e8347aad44..888a9bec778 100644 --- a/db/migrate/20200117112554_update_project_index_to_import_failures.rb +++ b/db/migrate/20200117112554_update_project_index_to_import_failures.rb @@ -5,8 +5,8 @@ class UpdateProjectIndexToImportFailures < ActiveRecord::Migration[5.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - PROJECT_INDEX_OLD = 'index_import_failures_on_project_id'.freeze - PROJECT_INDEX_NEW = 'index_import_failures_on_project_id_not_null'.freeze + PROJECT_INDEX_OLD = 'index_import_failures_on_project_id' + PROJECT_INDEX_NEW = 'index_import_failures_on_project_id_not_null' disable_ddl_transaction! diff --git a/db/migrate/20200221144534_drop_activate_prometheus_services_background_jobs.rb b/db/migrate/20200221144534_drop_activate_prometheus_services_background_jobs.rb index 13b041d8f95..4ec514f7fca 100644 --- a/db/migrate/20200221144534_drop_activate_prometheus_services_background_jobs.rb +++ b/db/migrate/20200221144534_drop_activate_prometheus_services_background_jobs.rb @@ -2,8 +2,8 @@ class DropActivatePrometheusServicesBackgroundJobs < ActiveRecord::Migration[6.0] DOWNTIME = false - DROPPED_JOB_CLASS = 'ActivatePrometheusServicesForSharedClusterApplications'.freeze - QUEUE = 'background_migration'.freeze + DROPPED_JOB_CLASS = 'ActivatePrometheusServicesForSharedClusterApplications' + QUEUE = 'background_migration' def up sidekiq_queues.each do |queue| diff --git a/db/migrate/20200528054112_add_index_to_package_name.rb b/db/migrate/20200528054112_add_index_to_package_name.rb index 4629c32ab3d..fa12088741d 100644 --- a/db/migrate/20200528054112_add_index_to_package_name.rb +++ b/db/migrate/20200528054112_add_index_to_package_name.rb @@ -7,7 +7,7 @@ class AddIndexToPackageName < ActiveRecord::Migration[6.0] disable_ddl_transaction! - INDEX_NAME = 'package_name_index'.freeze + INDEX_NAME = 'package_name_index' def up add_concurrent_index(:packages_packages, :name, name: INDEX_NAME) diff --git a/db/migrate/20200624142107_create_analytics_cycle_analytics_group_value_streams.rb b/db/migrate/20200624142107_create_analytics_cycle_analytics_group_value_streams.rb index 24afe463684..4b3f5222399 100644 --- a/db/migrate/20200624142107_create_analytics_cycle_analytics_group_value_streams.rb +++ b/db/migrate/20200624142107_create_analytics_cycle_analytics_group_value_streams.rb @@ -13,11 +13,11 @@ class CreateAnalyticsCycleAnalyticsGroupValueStreams < ActiveRecord::Migration[6 with_lock_retries do create_table :analytics_cycle_analytics_group_value_streams do |t| t.timestamps_with_timezone - t.references(:group, { + t.references(:group, null: false, index: false, foreign_key: { to_table: :namespaces, on_delete: :cascade } - }) + ) t.text :name, null: false t.index [:group_id, :name], unique: true, name: INDEX_NAME end diff --git a/db/migrate/20200826092324_add_projects_index_on_import_type_creator_id_created_at.rb b/db/migrate/20200826092324_add_projects_index_on_import_type_creator_id_created_at.rb index 94d2e5cb4ab..5938d3c8d3a 100644 --- a/db/migrate/20200826092324_add_projects_index_on_import_type_creator_id_created_at.rb +++ b/db/migrate/20200826092324_add_projects_index_on_import_type_creator_id_created_at.rb @@ -4,7 +4,7 @@ class AddProjectsIndexOnImportTypeCreatorIdCreatedAt < ActiveRecord::Migration[6 include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_imported_projects_on_import_type_creator_id_created_at'.freeze + INDEX_NAME = 'index_imported_projects_on_import_type_creator_id_created_at' disable_ddl_transaction! diff --git a/db/migrate/20201005092709_remove_compliance_frameworks_group_id_fk.rb b/db/migrate/20201005092709_remove_compliance_frameworks_group_id_fk.rb index 88c019c849e..dcbe48c03f9 100644 --- a/db/migrate/20201005092709_remove_compliance_frameworks_group_id_fk.rb +++ b/db/migrate/20201005092709_remove_compliance_frameworks_group_id_fk.rb @@ -4,7 +4,7 @@ class RemoveComplianceFrameworksGroupIdFk < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_compliance_management_frameworks_on_group_id_and_name'.freeze + INDEX_NAME = 'index_compliance_management_frameworks_on_group_id_and_name' class TmpComplianceFramework < ActiveRecord::Base self.table_name = 'compliance_management_frameworks' diff --git a/db/migrate/20201014205300_drop_backfill_jira_tracker_deployment_type_jobs.rb b/db/migrate/20201014205300_drop_backfill_jira_tracker_deployment_type_jobs.rb index ea45e82dcc4..c26636444af 100644 --- a/db/migrate/20201014205300_drop_backfill_jira_tracker_deployment_type_jobs.rb +++ b/db/migrate/20201014205300_drop_backfill_jira_tracker_deployment_type_jobs.rb @@ -2,8 +2,8 @@ class DropBackfillJiraTrackerDeploymentTypeJobs < ActiveRecord::Migration[6.0] DOWNTIME = false - DROPPED_JOB_CLASS = 'BackfillJiraTrackerDeploymentType'.freeze - QUEUE = 'background_migration'.freeze + DROPPED_JOB_CLASS = 'BackfillJiraTrackerDeploymentType' + QUEUE = 'background_migration' def up sidekiq_queues.each do |queue| diff --git a/db/migrate/20201112215132_swap_partitioned_audit_events.rb b/db/migrate/20201112215132_swap_partitioned_audit_events.rb new file mode 100644 index 00000000000..8360dbd4aa5 --- /dev/null +++ b/db/migrate/20201112215132_swap_partitioned_audit_events.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class SwapPartitionedAuditEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::PartitioningMigrationHelpers + + DOWNTIME = false + + def up + replace_with_partitioned_table :audit_events + end + + def down + rollback_replace_with_partitioned_table :audit_events + end +end diff --git a/db/migrate/20201204105300_create_packages_debian_file_metadata.rb b/db/migrate/20201204105300_create_packages_debian_file_metadata.rb new file mode 100644 index 00000000000..2bba1b6f38e --- /dev/null +++ b/db/migrate/20201204105300_create_packages_debian_file_metadata.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CreatePackagesDebianFileMetadata < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:packages_debian_file_metadata) + create_table :packages_debian_file_metadata, id: false do |t| + t.timestamps_with_timezone + t.references :package_file, primary_key: true, index: false, default: nil, null: false, foreign_key: { to_table: :packages_package_files, on_delete: :cascade }, type: :bigint + t.integer :file_type, limit: 2, null: false + t.text :component + t.text :architecture + t.jsonb :fields + end + end + + add_text_limit :packages_debian_file_metadata, :component, 255 + add_text_limit :packages_debian_file_metadata, :architecture, 255 + end + + def down + drop_table :packages_debian_file_metadata + end +end diff --git a/db/migrate/20201204110700_create_packages_debian_project_distributions.rb b/db/migrate/20201204110700_create_packages_debian_project_distributions.rb new file mode 100644 index 00000000000..5fe45c6236f --- /dev/null +++ b/db/migrate/20201204110700_create_packages_debian_project_distributions.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +class CreatePackagesDebianProjectDistributions < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + UNIQUE_CODENAME = 'uniq_pkgs_debian_project_distributions_project_id_and_codename' + UNIQUE_SUITE = 'uniq_pkgs_debian_project_distributions_project_id_and_suite' + + disable_ddl_transaction! + + def up + with_lock_retries do + unless table_exists?(:packages_debian_project_distributions) + create_table :packages_debian_project_distributions do |t| + t.timestamps_with_timezone + t.references :project, foreign_key: { to_table: :projects, on_delete: :restrict }, null: false + t.references :creator, foreign_key: { to_table: :users, on_delete: :nullify } + t.integer :valid_time_duration_seconds + t.integer :file_store, limit: 2, default: 1, null: false + t.boolean :automatic, default: true, null: false + t.boolean :automatic_upgrades, default: false, null: false + t.text :codename, null: false + t.text :suite + t.text :origin + t.text :label + t.text :version + t.text :description + t.text :encrypted_signing_keys + t.text :encrypted_signing_keys_iv + t.text :file + t.text :file_signature + + t.index %w(project_id codename), + name: UNIQUE_CODENAME, + unique: true, + using: :btree + t.index %w(project_id suite), + name: UNIQUE_SUITE, + unique: true, + using: :btree + end + end + end + + add_text_limit :packages_debian_project_distributions, :codename, 255 + add_text_limit :packages_debian_project_distributions, :suite, 255 + add_text_limit :packages_debian_project_distributions, :origin, 255 + add_text_limit :packages_debian_project_distributions, :label, 255 + add_text_limit :packages_debian_project_distributions, :version, 255 + add_text_limit :packages_debian_project_distributions, :description, 255 + add_text_limit :packages_debian_project_distributions, :encrypted_signing_keys, 2048 + add_text_limit :packages_debian_project_distributions, :encrypted_signing_keys_iv, 255 + add_text_limit :packages_debian_project_distributions, :file, 255 + add_text_limit :packages_debian_project_distributions, :file_signature, 4096 + end + + def down + drop_table :packages_debian_project_distributions + end +end diff --git a/db/migrate/20201204110800_create_packages_debian_group_distributions.rb b/db/migrate/20201204110800_create_packages_debian_group_distributions.rb new file mode 100644 index 00000000000..9ad9a59b3e9 --- /dev/null +++ b/db/migrate/20201204110800_create_packages_debian_group_distributions.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +class CreatePackagesDebianGroupDistributions < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + UNIQUE_CODENAME = 'uniq_pkgs_debian_group_distributions_group_id_and_codename' + UNIQUE_SUITE = 'uniq_pkgs_debian_group_distributions_group_id_and_suite' + + disable_ddl_transaction! + + def up + with_lock_retries do + unless table_exists?(:packages_debian_group_distributions) + create_table :packages_debian_group_distributions do |t| + t.timestamps_with_timezone + t.references :group, foreign_key: { to_table: :namespaces, on_delete: :restrict }, null: false + t.references :creator, foreign_key: { to_table: :users, on_delete: :nullify } + t.integer :valid_time_duration_seconds + t.integer :file_store, limit: 2, default: 1, null: false + t.boolean :automatic, default: true, null: false + t.boolean :automatic_upgrades, default: false, null: false + t.text :codename, null: false + t.text :suite + t.text :origin + t.text :label + t.text :version + t.text :description + t.text :encrypted_signing_keys + t.text :encrypted_signing_keys_iv + t.text :file + t.text :file_signature + + t.index %w(group_id codename), + name: UNIQUE_CODENAME, + unique: true, + using: :btree + t.index %w(group_id suite), + name: UNIQUE_SUITE, + unique: true, + using: :btree + end + end + end + + add_text_limit :packages_debian_group_distributions, :codename, 255 + add_text_limit :packages_debian_group_distributions, :suite, 255 + add_text_limit :packages_debian_group_distributions, :origin, 255 + add_text_limit :packages_debian_group_distributions, :label, 255 + add_text_limit :packages_debian_group_distributions, :version, 255 + add_text_limit :packages_debian_group_distributions, :description, 255 + add_text_limit :packages_debian_group_distributions, :encrypted_signing_keys, 2048 + add_text_limit :packages_debian_group_distributions, :encrypted_signing_keys_iv, 255 + add_text_limit :packages_debian_group_distributions, :file, 255 + add_text_limit :packages_debian_group_distributions, :file_signature, 4096 + end + + def down + drop_table :packages_debian_group_distributions + end +end diff --git a/db/migrate/20201204111000_create_packages_debian_project_architectures.rb b/db/migrate/20201204111000_create_packages_debian_project_architectures.rb new file mode 100644 index 00000000000..f684a413873 --- /dev/null +++ b/db/migrate/20201204111000_create_packages_debian_project_architectures.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class CreatePackagesDebianProjectArchitectures < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + INDEX_NAME = 'idx_pkgs_deb_proj_architectures_on_distribution_id' + UNIQUE_NAME = 'uniq_pkgs_deb_proj_architectures_on_distribution_id_and_name' + + disable_ddl_transaction! + + def up + with_lock_retries do + unless table_exists?(:packages_debian_project_architectures) + create_table :packages_debian_project_architectures do |t| + t.timestamps_with_timezone + t.references :distribution, + foreign_key: { to_table: :packages_debian_project_distributions, on_delete: :cascade }, + null: false, + index: { name: INDEX_NAME } + t.text :name, null: false + + t.index %w(distribution_id name), + name: UNIQUE_NAME, + unique: true, + using: :btree + end + end + end + + add_text_limit :packages_debian_project_architectures, :name, 255 + end + + def down + drop_table :packages_debian_project_architectures + end +end diff --git a/db/migrate/20201204111100_create_packages_debian_group_architectures.rb b/db/migrate/20201204111100_create_packages_debian_group_architectures.rb new file mode 100644 index 00000000000..8a001414c45 --- /dev/null +++ b/db/migrate/20201204111100_create_packages_debian_group_architectures.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class CreatePackagesDebianGroupArchitectures < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + INDEX_NAME = 'idx_pkgs_deb_grp_architectures_on_distribution_id' + UNIQUE_NAME = 'uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name' + + disable_ddl_transaction! + + def up + with_lock_retries do + unless table_exists?(:packages_debian_group_architectures) + create_table :packages_debian_group_architectures do |t| + t.timestamps_with_timezone + t.references :distribution, + foreign_key: { to_table: :packages_debian_group_distributions, on_delete: :cascade }, + null: false, + index: { name: INDEX_NAME } + t.text :name, null: false + + t.index %w(distribution_id name), + name: UNIQUE_NAME, + unique: true, + using: :btree + end + end + end + + add_text_limit :packages_debian_group_architectures, :name, 255 + end + + def down + drop_table :packages_debian_group_architectures + end +end diff --git a/db/migrate/20201204193952_keep_latest_artifact_project_level.rb b/db/migrate/20201204193952_keep_latest_artifact_project_level.rb new file mode 100644 index 00000000000..3fc9fad1dc6 --- /dev/null +++ b/db/migrate/20201204193952_keep_latest_artifact_project_level.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class KeepLatestArtifactProjectLevel < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_column :project_ci_cd_settings, :keep_latest_artifact, :boolean, default: true, null: false + end + end + + def down + with_lock_retries do + remove_column :project_ci_cd_settings, :keep_latest_artifact + end + end +end diff --git a/db/migrate/20201208210209_create_incident_management_oncall_shifts.rb b/db/migrate/20201208210209_create_incident_management_oncall_shifts.rb new file mode 100644 index 00000000000..49cb32ffee0 --- /dev/null +++ b/db/migrate/20201208210209_create_incident_management_oncall_shifts.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +class CreateIncidentManagementOncallShifts < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + unless table_exists?(:incident_management_oncall_shifts) + with_lock_retries do + create_table :incident_management_oncall_shifts do |t| + t.references :rotation, null: false, foreign_key: { to_table: :incident_management_oncall_rotations, on_delete: :cascade } + t.references :participant, null: false, foreign_key: { to_table: :incident_management_oncall_participants, on_delete: :cascade } + t.datetime_with_timezone :starts_at, null: false + t.datetime_with_timezone :ends_at, null: false + end + + execute <<~SQL + ALTER TABLE incident_management_oncall_shifts + ADD CONSTRAINT inc_mgmnt_no_overlapping_oncall_shifts + EXCLUDE USING gist + ( rotation_id WITH =, + tstzrange(starts_at, ends_at, '[)') WITH && + ) + SQL + end + end + end + + def down + with_lock_retries do + drop_table :incident_management_oncall_shifts + end + end +end diff --git a/db/migrate/20201209163958_add_code_challenge_to_oauth_access_grants.rb b/db/migrate/20201209163958_add_code_challenge_to_oauth_access_grants.rb new file mode 100644 index 00000000000..48292cce55b --- /dev/null +++ b/db/migrate/20201209163958_add_code_challenge_to_oauth_access_grants.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class AddCodeChallengeToOauthAccessGrants < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column(:oauth_access_grants, :code_challenge, :text, null: true) unless column_exists?(:oauth_access_grants, :code_challenge) + # If `code_challenge_method` is 'plain' the length is at most 128 characters as per the spec + # https://tools.ietf.org/html/rfc7636#section-4.1 + # Otherwise the max length of base64(SHA256(code_verifier)) is 44 characters + add_text_limit(:oauth_access_grants, :code_challenge, 128, constraint_name: 'oauth_access_grants_code_challenge') + + add_column(:oauth_access_grants, :code_challenge_method, :text, null: true) unless column_exists?(:oauth_access_grants, :code_challenge_method) + # Values are either 'plain' or 'S256' + add_text_limit(:oauth_access_grants, :code_challenge_method, 5, constraint_name: 'oauth_access_grants_code_challenge_method') + end + + def down + remove_column(:oauth_access_grants, :code_challenge) + remove_column(:oauth_access_grants, :code_challenge_method) + end +end diff --git a/db/migrate/20201209193551_add_version_sha_cache_to_composer_metadata.rb b/db/migrate/20201209193551_add_version_sha_cache_to_composer_metadata.rb new file mode 100644 index 00000000000..62d0cdae8bc --- /dev/null +++ b/db/migrate/20201209193551_add_version_sha_cache_to_composer_metadata.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddVersionShaCacheToComposerMetadata < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_column :packages_composer_metadata, :version_cache_sha, :binary, null: true + end + end + + def down + with_lock_retries do + remove_column :packages_composer_metadata, :version_cache_sha, :binary + end + 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 new file mode 100644 index 00000000000..0d97d54f3e4 --- /dev/null +++ b/db/migrate/20201214000000_change_mr_allow_maintainer_to_push_default.rb @@ -0,0 +1,17 @@ +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 new file mode 100644 index 00000000000..f6e066b75da --- /dev/null +++ b/db/migrate/20201214032220_add_has_external_wiki_trigger.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +class AddHasExternalWikiTrigger < ActiveRecord::Migration[6.0] + include Gitlab::Database::SchemaHelpers + + DOWNTIME = false + FUNCTION_NAME = 'set_has_external_wiki'.freeze + TRIGGER_ON_INSERT_NAME = 'trigger_has_external_wiki_on_insert'.freeze + TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_wiki_on_update'.freeze + TRIGGER_ON_DELETE_NAME = 'trigger_has_external_wiki_on_delete'.freeze + + 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/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 new file mode 100644 index 00000000000..312220914c1 --- /dev/null +++ b/db/migrate/20201214111858_add_container_registry_cleanup_tags_service_max_list_size_to_application_settings.rb @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 00000000000..935dd641b4c --- /dev/null +++ b/db/migrate/20201214112752_add_app_settings_container_reg_cleanup_tags_service_max_list_size_constraint.rb @@ -0,0 +1,19 @@ +# 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/20201214184020_add_epic_board_list.rb b/db/migrate/20201214184020_add_epic_board_list.rb new file mode 100644 index 00000000000..9c4e3280754 --- /dev/null +++ b/db/migrate/20201214184020_add_epic_board_list.rb @@ -0,0 +1,33 @@ +# 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/20201215205404_create_namespace_package_settings.rb b/db/migrate/20201215205404_create_namespace_package_settings.rb new file mode 100644 index 00000000000..d74b99597ce --- /dev/null +++ b/db/migrate/20201215205404_create_namespace_package_settings.rb @@ -0,0 +1,25 @@ +# 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 new file mode 100644 index 00000000000..ac6d3fda2d2 --- /dev/null +++ b/db/migrate/20201216151616_add_squash_commit_sha_index.rb @@ -0,0 +1,22 @@ +# 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 new file mode 100644 index 00000000000..ada1bd9b346 --- /dev/null +++ b/db/migrate/20201216154457_add_devops_adoption_snapshot_range_end.rb @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 00000000000..dba9e6e440f --- /dev/null +++ b/db/migrate/20201217070530_add_group_merge_request_approval_settings.rb @@ -0,0 +1,24 @@ +# 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/20201217132603_create_elastic_reindexing_subtasks.rb b/db/migrate/20201217132603_create_elastic_reindexing_subtasks.rb new file mode 100644 index 00000000000..db084b885c2 --- /dev/null +++ b/db/migrate/20201217132603_create_elastic_reindexing_subtasks.rb @@ -0,0 +1,56 @@ +# 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/20201221124036_add_devops_snapshot_index.rb b/db/migrate/20201221124036_add_devops_snapshot_index.rb new file mode 100644 index 00000000000..85001e9abcf --- /dev/null +++ b/db/migrate/20201221124036_add_devops_snapshot_index.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..baec0da208b --- /dev/null +++ b/db/migrate/20201221213415_change_clusters_helm_major_version_default_to_3.rb @@ -0,0 +1,9 @@ +# 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/20201223114050_add_restrict_user_defined_variables_to_project_settings.rb b/db/migrate/20201223114050_add_restrict_user_defined_variables_to_project_settings.rb new file mode 100644 index 00000000000..d04c6981bf9 --- /dev/null +++ b/db/migrate/20201223114050_add_restrict_user_defined_variables_to_project_settings.rb @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 00000000000..a13e5e859e0 --- /dev/null +++ b/db/migrate/20201224144948_migrate_coverage_report_worker.rb @@ -0,0 +1,15 @@ +# 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' + end + + def down + sidekiq_queue_migrate 'ci_pipeline_artifacts_coverage_report', to: 'ci_pipelines_create_artifact' + 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 new file mode 100644 index 00000000000..92484aced4e --- /dev/null +++ b/db/migrate/20201228184500_add_dismissal_reason_into_vulnerability_feedback_table.rb @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 00000000000..025fcba0729 --- /dev/null +++ b/db/migrate/20201229105948_add_invisible_captcha_enabled_to_settings.rb @@ -0,0 +1,9 @@ +# 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 new file mode 100644 index 00000000000..647455f5f88 --- /dev/null +++ b/db/migrate/20201230161206_add_rate_limiting_response_text_to_application_settings.rb @@ -0,0 +1,12 @@ +# 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 new file mode 100644 index 00000000000..b9fe64eb19d --- /dev/null +++ b/db/migrate/20201230180202_create_onboarding_progress.rb @@ -0,0 +1,36 @@ +# 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 new file mode 100644 index 00000000000..b72f2ae7d70 --- /dev/null +++ b/db/migrate/20210101110640_set_limit_for_rate_limiting_response_text.rb @@ -0,0 +1,16 @@ +# 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 new file mode 100644 index 00000000000..0ecf194eb97 --- /dev/null +++ b/db/migrate/20210102164121_drop_temporary_index_on_ci_builds.rb @@ -0,0 +1,19 @@ +# 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'.freeze + + 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 new file mode 100644 index 00000000000..32c829f0288 --- /dev/null +++ b/db/migrate/20210104163218_add_epic_board_position_index.rb @@ -0,0 +1,18 @@ +# 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/20210106153021_drop_tmp_index_on_emails.rb b/db/migrate/20210106153021_drop_tmp_index_on_emails.rb new file mode 100644 index 00000000000..94b4a5437af --- /dev/null +++ b/db/migrate/20210106153021_drop_tmp_index_on_emails.rb @@ -0,0 +1,20 @@ +# 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/20210108161039_update_max_import_size_default.rb b/db/migrate/20210108161039_update_max_import_size_default.rb new file mode 100644 index 00000000000..5f0591b2766 --- /dev/null +++ b/db/migrate/20210108161039_update_max_import_size_default.rb @@ -0,0 +1,9 @@ +# 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/20210112084512_drop_tmp_index_on_emails_again.rb b/db/migrate/20210112084512_drop_tmp_index_on_emails_again.rb new file mode 100644 index 00000000000..6c2f9cbcb32 --- /dev/null +++ b/db/migrate/20210112084512_drop_tmp_index_on_emails_again.rb @@ -0,0 +1,18 @@ +# 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/20210114033715_remove_group_id_title_index.rb b/db/migrate/20210114033715_remove_group_id_title_index.rb new file mode 100644 index 00000000000..8d63da3d400 --- /dev/null +++ b/db/migrate/20210114033715_remove_group_id_title_index.rb @@ -0,0 +1,20 @@ +# 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 |