Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb2
-rw-r--r--db/migrate/20210525085325_backfill_deployments_for_bigint_conversion.rb2
-rw-r--r--db/migrate/20210525100603_backfill_geo_job_artifact_deleted_events_for_bigint_conversion.rb2
-rw-r--r--db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb2
-rw-r--r--db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb24
-rw-r--r--db/migrate/20220221102333_change_maintenance_note_limit_in_ci_runner.rb db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb14
-rw-r--r--db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb13
-rw-r--r--db/migrate/20220329092245_add_password_chars_requirement_to_application_settings.rb10
-rw-r--r--db/migrate/20220503035221_add_gitlab_schema_to_batched_background_migrations.rb11
-rw-r--r--db/migrate/20220503035437_add_text_limit_to_batched_background_migrations_gitlab_schema.rb13
-rw-r--r--db/migrate/20220511144946_add_work_item_parent_child_table.rb27
-rw-r--r--db/migrate/20220512020500_index_batched_migrations_on_gitlab_schema_and_configuration.rb19
-rw-r--r--db/migrate/20220513093614_add_ding_talk_into_application_settings.rb14
-rw-r--r--db/migrate/20220513093615_add_ding_talk_tracker_data.rb15
-rw-r--r--db/migrate/20220513095545_create_timelog_categories.rb28
-rw-r--r--db/migrate/20220513114706_add_jira_connect_application_id_application_setting.rb10
-rw-r--r--db/migrate/20220513114850_add_text_limit_to_jira_connect_application_id_application_setting.rb13
-rw-r--r--db/migrate/20220516054002_temp_index_for_project_namespace_member_backfill.rb19
-rw-r--r--db/migrate/20220516092207_add_globally_allowed_ips_to_application_setting.rb11
-rw-r--r--db/migrate/20220516123101_add_text_limit_to_globally_allowed_ips_on_application_settings.rb13
-rw-r--r--db/migrate/20220516201245_add_security_policy_scan_execution_schedules_to_plan_limits.rb11
-rw-r--r--db/migrate/20220517182529_create_vulnerability_state_transition.rb18
-rw-r--r--db/migrate/20220518183504_create_ssh_signatures.rb13
-rw-r--r--db/migrate/20220518183548_add_projects_relation_to_ssh_signatures.rb15
-rw-r--r--db/migrate/20220519013213_create_cluster_enabled_grants.rb12
-rw-r--r--db/migrate/20220519141345_add_job_artifact_id_on_refresh_start_to_build_artifacts_size_refresh.rb7
-rw-r--r--db/migrate/20220520030504_drop_index_namespaces_on_name.rb15
-rw-r--r--db/migrate/20220520122755_unlock_delayed_project_removal.rb25
-rw-r--r--db/migrate/20220520143105_add_keys_relation_to_ssh_signatures.rb15
-rw-r--r--db/migrate/20220520144821_add_registry_migration_pre_import_tags_rate_to_application_settings.rb12
-rw-r--r--db/migrate/20220523030804_add_web_hook_calls_med_and_max_to_plan_limits.rb8
-rw-r--r--db/migrate/20220523030805_add_web_hook_calls_to_plan_limits_paid_tiers.rb81
-rw-r--r--db/migrate/20220524021855_add_deleted_at_to_terraform_states.rb9
-rw-r--r--db/migrate/20220524141800_create_audit_events_streaming_headers.rb20
-rw-r--r--db/migrate/20220524191259_add_application_settings_container_registry_pre_import_tags_rate_constraint.rb15
-rw-r--r--db/migrate/20220525082303_create_issuable_resource_links.rb14
-rw-r--r--db/migrate/20220525123825_add_raw_to_ci_pipeline_variables.rb9
-rw-r--r--db/migrate/20220525123851_add_raw_to_ci_group_variables.rb9
-rw-r--r--db/migrate/20220525123914_add_raw_to_ci_instance_variables.rb9
-rw-r--r--db/migrate/20220525123940_add_raw_to_ci_job_variables.rb9
-rw-r--r--db/migrate/20220525124104_add_raw_to_ci_pipeline_schedule_variables.rb9
-rw-r--r--db/migrate/20220525124125_add_raw_to_ci_variables.rb9
-rw-r--r--db/migrate/20220530103023_add_created_at_and_id_index_to_deployment_approvals.rb15
-rw-r--r--db/migrate/20220530104431_add_timestamps_to_compliance_frameworks.rb13
-rw-r--r--db/migrate/20220531100920_add_license_usage_data_exported_to_application_settings.rb9
-rw-r--r--db/migrate/20220601091804_add_semver_column_to_ci_runners.rb14
-rw-r--r--db/migrate/20220601091805_add_text_limit_to_ci_runners_semver.rb13
-rw-r--r--db/migrate/20220601101800_add_index_on_runner_id_and_semver_columns.rb17
-rw-r--r--db/migrate/20220601223501_add_vulnerability_related_columns.rb30
-rw-r--r--db/migrate/20220602130306_add_namespace_type_index.rb15
-rw-r--r--db/migrate/20220603095158_drop_ci_build_report_results_build_id_sequence.rb13
-rw-r--r--db/migrate/20220605170009_add_url_vars_to_web_hook.rb8
-rw-r--r--db/migrate/20220607011733_add_phone_verification_code_enabled_to_application_settings.rb16
-rw-r--r--db/migrate/20220607095219_drop_ci_pipelines_config_pipeline_id_sequence.rb13
-rw-r--r--db/migrate/20220607115703_drop_ci_job_artifact_states_job_artifact_id_sequence.rb11
-rw-r--r--db/migrate/20220608114734_prepare_confidential_note_index_on_id.rb13
-rw-r--r--db/migrate/20220609150626_add_partial_index_on_slack_integrations_with_bot_user_id.rb15
-rw-r--r--db/migrate/20220610074326_add_epic_issue_weight.rb10
-rw-r--r--db/migrate/20220610125248_add_enabled_git_access_protocol_to_namespace_settings.rb7
-rw-r--r--db/migrate/20220614095912_add_has_vulnerabilities_to_cluster_agents.rb9
-rw-r--r--db/migrate/20220615091059_add_created_at_index_to_compliance_management_frameworks.rb17
-rw-r--r--db/migrate/20220615105811_add_index_on_clusters_agent_project_id_and_has_vulnerabilities_columns.rb17
62 files changed, 867 insertions, 14 deletions
diff --git a/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb b/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb
index 63ac308e4be..778e186eb9c 100644
--- a/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb
+++ b/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb
@@ -3,6 +3,8 @@
class BackfillTaggingsForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
TABLE = :taggings
COLUMNS = %i(id taggable_id)
diff --git a/db/migrate/20210525085325_backfill_deployments_for_bigint_conversion.rb b/db/migrate/20210525085325_backfill_deployments_for_bigint_conversion.rb
index 6de89cadef8..0795abf19d4 100644
--- a/db/migrate/20210525085325_backfill_deployments_for_bigint_conversion.rb
+++ b/db/migrate/20210525085325_backfill_deployments_for_bigint_conversion.rb
@@ -3,6 +3,8 @@
class BackfillDeploymentsForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
TABLE = :deployments
COLUMNS = %i(deployable_id)
diff --git a/db/migrate/20210525100603_backfill_geo_job_artifact_deleted_events_for_bigint_conversion.rb b/db/migrate/20210525100603_backfill_geo_job_artifact_deleted_events_for_bigint_conversion.rb
index eab79a33006..c2845760b5c 100644
--- a/db/migrate/20210525100603_backfill_geo_job_artifact_deleted_events_for_bigint_conversion.rb
+++ b/db/migrate/20210525100603_backfill_geo_job_artifact_deleted_events_for_bigint_conversion.rb
@@ -3,6 +3,8 @@
class BackfillGeoJobArtifactDeletedEventsForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
TABLE = :geo_job_artifact_deleted_events
COLUMNS = %i(job_artifact_id)
diff --git a/db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb b/db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb
index 6376305c784..4a52600d4c7 100644
--- a/db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb
+++ b/db/migrate/20210608072346_backfill_ci_stages_for_bigint_conversion.rb
@@ -3,6 +3,8 @@
class BackfillCiStagesForBigintConversion < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
TABLE = :ci_stages
COLUMNS = %i(id)
diff --git a/db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb b/db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb
new file mode 100644
index 00000000000..a3d71a060b8
--- /dev/null
+++ b/db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class ChangeMaintainerNoteLimitInCiRunner < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit(
+ :ci_runners,
+ :maintainer_note,
+ 1024,
+ constraint_name: check_constraint_name(:ci_runners, :maintainer_note, 'max_length_1MB')
+ )
+
+ remove_text_limit(
+ :ci_runners,
+ :maintainer_note,
+ constraint_name: check_constraint_name(:ci_runners, :maintainer_note, 'max_length')
+ )
+ end
+
+ def down
+ # no-op: Danger of failing if there are records with length(maintainer_note) > 255
+ end
+end
diff --git a/db/migrate/20220221102333_change_maintenance_note_limit_in_ci_runner.rb db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb b/db/migrate/20220221102333_change_maintenance_note_limit_in_ci_runner.rb db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb
deleted file mode 100644
index 98930691b3b..00000000000
--- a/db/migrate/20220221102333_change_maintenance_note_limit_in_ci_runner.rb db/migrate/20220221102333_change_maintainer_note_limit_in_ci_runner.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeMaintainerNoteLimitInCiRunner < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :ci_runners, :maintainer_note, 1024, constraint_name: check_constraint_name(:ci_runners, :maintainer_note, 'max_length_1MB')
- remove_text_limit :ci_runners, :maintainer_note, constraint_name: check_constraint_name(:ci_runners, :maintainer_note, 'max_length')
- end
-
- def down
- # no-op: Danger of failing if there are records with length(maintainer_note) > 255
- end
-end
diff --git a/db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb b/db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb
new file mode 100644
index 00000000000..4effdfa6a5e
--- /dev/null
+++ b/db/migrate/20220314094841_add_package_registry_access_level_into_project_features.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddPackageRegistryAccessLevelIntoProjectFeatures < Gitlab::Database::Migration[1.0]
+ DISABLED = 0 # ProjectFeature::DISABLED
+
+ def up
+ add_column :project_features, :package_registry_access_level, :integer, default: DISABLED, null: false
+ end
+
+ def down
+ remove_column :project_features, :package_registry_access_level
+ end
+end
diff --git a/db/migrate/20220329092245_add_password_chars_requirement_to_application_settings.rb b/db/migrate/20220329092245_add_password_chars_requirement_to_application_settings.rb
new file mode 100644
index 00000000000..152ee10df74
--- /dev/null
+++ b/db/migrate/20220329092245_add_password_chars_requirement_to_application_settings.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddPasswordCharsRequirementToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :password_uppercase_required, :boolean, default: false, null: false
+ add_column :application_settings, :password_lowercase_required, :boolean, default: false, null: false
+ add_column :application_settings, :password_number_required, :boolean, default: false, null: false
+ add_column :application_settings, :password_symbol_required, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20220503035221_add_gitlab_schema_to_batched_background_migrations.rb b/db/migrate/20220503035221_add_gitlab_schema_to_batched_background_migrations.rb
new file mode 100644
index 00000000000..eaebe979ff3
--- /dev/null
+++ b/db/migrate/20220503035221_add_gitlab_schema_to_batched_background_migrations.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddGitlabSchemaToBatchedBackgroundMigrations < Gitlab::Database::Migration[2.0]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20220503035437_add_text_limit_to_batched_background_migrations_gitlab_schema
+ def change
+ add_column :batched_background_migrations, :gitlab_schema, :text, null: false, default: :gitlab_main
+ change_column_default(:batched_background_migrations, :gitlab_schema, from: :gitlab_main, to: nil)
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20220503035437_add_text_limit_to_batched_background_migrations_gitlab_schema.rb b/db/migrate/20220503035437_add_text_limit_to_batched_background_migrations_gitlab_schema.rb
new file mode 100644
index 00000000000..d5629cd1b8d
--- /dev/null
+++ b/db/migrate/20220503035437_add_text_limit_to_batched_background_migrations_gitlab_schema.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToBatchedBackgroundMigrationsGitlabSchema < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :batched_background_migrations, :gitlab_schema, 255
+ end
+
+ def down
+ remove_text_limit :batched_background_migrations, :gitlab_schema
+ end
+end
diff --git a/db/migrate/20220511144946_add_work_item_parent_child_table.rb b/db/migrate/20220511144946_add_work_item_parent_child_table.rb
new file mode 100644
index 00000000000..160dac78160
--- /dev/null
+++ b/db/migrate/20220511144946_add_work_item_parent_child_table.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class AddWorkItemParentChildTable < Gitlab::Database::Migration[2.0]
+ def up
+ create_table :work_item_parent_links do |t|
+ t.references :work_item,
+ index: false,
+ unique: true,
+ foreign_key: { to_table: :issues, on_delete: :cascade },
+ null: false
+ t.references :work_item_parent,
+ index: true,
+ foreign_key: { to_table: :issues, on_delete: :cascade },
+ null: false
+ t.integer :relative_position
+ t.timestamps_with_timezone null: false
+
+ t.index [:work_item_id, :work_item_parent_id],
+ unique: true,
+ name: :index_parent_links_on_work_item_id_and_work_item_parent_id
+ end
+ end
+
+ def down
+ drop_table :work_item_parent_links
+ end
+end
diff --git a/db/migrate/20220512020500_index_batched_migrations_on_gitlab_schema_and_configuration.rb b/db/migrate/20220512020500_index_batched_migrations_on_gitlab_schema_and_configuration.rb
new file mode 100644
index 00000000000..077a60856cd
--- /dev/null
+++ b/db/migrate/20220512020500_index_batched_migrations_on_gitlab_schema_and_configuration.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class IndexBatchedMigrationsOnGitlabSchemaAndConfiguration < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TABLE_NAME = :batched_background_migrations
+ INDEX_NAME = 'index_batched_migrations_on_gl_schema_and_unique_configuration'
+
+ def up
+ add_concurrent_index TABLE_NAME,
+ %i[gitlab_schema job_class_name table_name column_name job_arguments],
+ unique: true,
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb b/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb
new file mode 100644
index 00000000000..5a34200a3c8
--- /dev/null
+++ b/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddDingTalkIntoApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :dingtalk_integration_enabled, :boolean, null: false,
+ default: false, comment: 'JiHu-specific column'
+ add_column :application_settings, :encrypted_dingtalk_corpid, :binary, comment: 'JiHu-specific column'
+ add_column :application_settings, :encrypted_dingtalk_corpid_iv, :binary, comment: 'JiHu-specific column'
+ add_column :application_settings, :encrypted_dingtalk_app_key, :binary, comment: 'JiHu-specific column'
+ add_column :application_settings, :encrypted_dingtalk_app_key_iv, :binary, comment: 'JiHu-specific column'
+ add_column :application_settings, :encrypted_dingtalk_app_secret, :binary, comment: 'JiHu-specific column'
+ add_column :application_settings, :encrypted_dingtalk_app_secret_iv, :binary, comment: 'JiHu-specific column'
+ end
+end
diff --git a/db/migrate/20220513093615_add_ding_talk_tracker_data.rb b/db/migrate/20220513093615_add_ding_talk_tracker_data.rb
new file mode 100644
index 00000000000..0a9c340fbf0
--- /dev/null
+++ b/db/migrate/20220513093615_add_ding_talk_tracker_data.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddDingTalkTrackerData < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_on_dingtalk_tracker_data_corpid'
+
+ def change
+ create_table :dingtalk_tracker_data, comment: 'JiHu-specific table' do |t|
+ t.references :integration, foreign_key: { on_delete: :cascade },
+ type: :bigint, index: true, null: false, comment: 'JiHu-specific column'
+ t.timestamps_with_timezone
+ t.text :corpid, comment: 'JiHu-specific column', limit: 255
+ t.index :corpid, where: "(corpid IS NOT NULL)", name: INDEX_NAME, comment: 'JiHu-specific index'
+ end
+ end
+end
diff --git a/db/migrate/20220513095545_create_timelog_categories.rb b/db/migrate/20220513095545_create_timelog_categories.rb
new file mode 100644
index 00000000000..aaf4a833ce0
--- /dev/null
+++ b/db/migrate/20220513095545_create_timelog_categories.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class CreateTimelogCategories < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ create_table :timelog_categories do |t|
+ t.references :namespace,
+ index: false,
+ null: false,
+ foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.decimal :billing_rate, precision: 18, scale: 4, default: 0
+ t.boolean :billable, default: false, null: false
+ t.text :name, null: false, limit: 255
+ t.text :description, limit: 1024
+ t.text :color, limit: 7, default: '#6699cc', null: false
+
+ t.index 'namespace_id, LOWER(name)',
+ unique: true,
+ name: :index_timelog_categories_on_unique_name_per_namespace
+ end
+ end
+
+ def down
+ drop_table :timelog_categories
+ end
+end
diff --git a/db/migrate/20220513114706_add_jira_connect_application_id_application_setting.rb b/db/migrate/20220513114706_add_jira_connect_application_id_application_setting.rb
new file mode 100644
index 00000000000..2557ec94167
--- /dev/null
+++ b/db/migrate/20220513114706_add_jira_connect_application_id_application_setting.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddJiraConnectApplicationIdApplicationSetting < Gitlab::Database::Migration[2.0]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20220513114850_add_text_limit_to_jira_connect_application_id_application_setting.rb
+ def change
+ add_column :application_settings, :jira_connect_application_key, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20220513114850_add_text_limit_to_jira_connect_application_id_application_setting.rb b/db/migrate/20220513114850_add_text_limit_to_jira_connect_application_id_application_setting.rb
new file mode 100644
index 00000000000..a379a273bb6
--- /dev/null
+++ b/db/migrate/20220513114850_add_text_limit_to_jira_connect_application_id_application_setting.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToJiraConnectApplicationIdApplicationSetting < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :application_settings, :jira_connect_application_key, 255
+ end
+
+ def down
+ remove_text_limit :application_settings, :jira_connect_application_key
+ end
+end
diff --git a/db/migrate/20220516054002_temp_index_for_project_namespace_member_backfill.rb b/db/migrate/20220516054002_temp_index_for_project_namespace_member_backfill.rb
new file mode 100644
index 00000000000..fc2fef582f5
--- /dev/null
+++ b/db/migrate/20220516054002_temp_index_for_project_namespace_member_backfill.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class TempIndexForProjectNamespaceMemberBackfill < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'tmp_index_for_namespace_id_migration_on_project_members'
+
+ disable_ddl_transaction!
+
+ def up
+ # Temporary index to be removed in future
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/356509
+ add_concurrent_index :members, :id,
+ where: "members.member_namespace_id IS NULL and members.type = 'ProjectMember'",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :members, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220516092207_add_globally_allowed_ips_to_application_setting.rb b/db/migrate/20220516092207_add_globally_allowed_ips_to_application_setting.rb
new file mode 100644
index 00000000000..895400aedc4
--- /dev/null
+++ b/db/migrate/20220516092207_add_globally_allowed_ips_to_application_setting.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+class AddGloballyAllowedIpsToApplicationSetting < Gitlab::Database::Migration[2.0]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20220516123101_add_text_limit_to_globally_allowed_ips_on_application_settings
+ def change
+ add_column :application_settings, :globally_allowed_ips, :text, null: false, default: ""
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20220516123101_add_text_limit_to_globally_allowed_ips_on_application_settings.rb b/db/migrate/20220516123101_add_text_limit_to_globally_allowed_ips_on_application_settings.rb
new file mode 100644
index 00000000000..887a7da0a74
--- /dev/null
+++ b/db/migrate/20220516123101_add_text_limit_to_globally_allowed_ips_on_application_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToGloballyAllowedIpsOnApplicationSettings < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :application_settings, :globally_allowed_ips, 255
+ end
+
+ def down
+ remove_text_limit :application_settings, :globally_allowed_ips
+ end
+end
diff --git a/db/migrate/20220516201245_add_security_policy_scan_execution_schedules_to_plan_limits.rb b/db/migrate/20220516201245_add_security_policy_scan_execution_schedules_to_plan_limits.rb
new file mode 100644
index 00000000000..733ac971b98
--- /dev/null
+++ b/db/migrate/20220516201245_add_security_policy_scan_execution_schedules_to_plan_limits.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddSecurityPolicyScanExecutionSchedulesToPlanLimits < Gitlab::Database::Migration[2.0]
+ def up
+ add_column(:plan_limits, :security_policy_scan_execution_schedules, :integer, default: 0, null: false)
+ end
+
+ def down
+ remove_column(:plan_limits, :security_policy_scan_execution_schedules)
+ end
+end
diff --git a/db/migrate/20220517182529_create_vulnerability_state_transition.rb b/db/migrate/20220517182529_create_vulnerability_state_transition.rb
new file mode 100644
index 00000000000..6ffa10ae597
--- /dev/null
+++ b/db/migrate/20220517182529_create_vulnerability_state_transition.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityStateTransition < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ create_table :vulnerability_state_transitions do |t|
+ t.references :vulnerability, index: true, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :to_state, limit: 2, null: false
+ t.integer :from_state, limit: 2, null: false
+ t.timestamps_with_timezone null: false
+ end
+ end
+
+ def down
+ drop_table :vulnerability_state_transitions
+ end
+end
diff --git a/db/migrate/20220518183504_create_ssh_signatures.rb b/db/migrate/20220518183504_create_ssh_signatures.rb
new file mode 100644
index 00000000000..6708d3f295c
--- /dev/null
+++ b/db/migrate/20220518183504_create_ssh_signatures.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CreateSshSignatures < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :ssh_signatures do |t|
+ t.timestamps_with_timezone null: false
+ t.bigint :project_id, null: false, index: true
+ t.bigint :key_id, null: false, index: true
+ t.integer :verification_status, default: 0, null: false, limit: 2
+ t.binary :commit_sha, null: false, index: { unique: true }
+ end
+ end
+end
diff --git a/db/migrate/20220518183548_add_projects_relation_to_ssh_signatures.rb b/db/migrate/20220518183548_add_projects_relation_to_ssh_signatures.rb
new file mode 100644
index 00000000000..459d1bc4bf9
--- /dev/null
+++ b/db/migrate/20220518183548_add_projects_relation_to_ssh_signatures.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddProjectsRelationToSshSignatures < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ssh_signatures, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :ssh_signatures, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20220519013213_create_cluster_enabled_grants.rb b/db/migrate/20220519013213_create_cluster_enabled_grants.rb
new file mode 100644
index 00000000000..45c18ecca45
--- /dev/null
+++ b/db/migrate/20220519013213_create_cluster_enabled_grants.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateClusterEnabledGrants < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ create_table :cluster_enabled_grants do |t|
+ t.references :namespace, index: { unique: true }, null: false, foreign_key: { on_delete: :cascade }
+ t.datetime_with_timezone :created_at, null: false
+ end
+ end
+end
diff --git a/db/migrate/20220519141345_add_job_artifact_id_on_refresh_start_to_build_artifacts_size_refresh.rb b/db/migrate/20220519141345_add_job_artifact_id_on_refresh_start_to_build_artifacts_size_refresh.rb
new file mode 100644
index 00000000000..ee19fd9da23
--- /dev/null
+++ b/db/migrate/20220519141345_add_job_artifact_id_on_refresh_start_to_build_artifacts_size_refresh.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddJobArtifactIdOnRefreshStartToBuildArtifactsSizeRefresh < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :project_build_artifacts_size_refreshes, :last_job_artifact_id_on_refresh_start, :bigint, default: 0
+ end
+end
diff --git a/db/migrate/20220520030504_drop_index_namespaces_on_name.rb b/db/migrate/20220520030504_drop_index_namespaces_on_name.rb
new file mode 100644
index 00000000000..74019f726aa
--- /dev/null
+++ b/db/migrate/20220520030504_drop_index_namespaces_on_name.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DropIndexNamespacesOnName < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_namespaces_on_name'
+
+ def up
+ remove_concurrent_index_by_name :namespaces, INDEX_NAME, if_exists: true
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20220520122755_unlock_delayed_project_removal.rb b/db/migrate/20220520122755_unlock_delayed_project_removal.rb
new file mode 100644
index 00000000000..aaecf601e2b
--- /dev/null
+++ b/db/migrate/20220520122755_unlock_delayed_project_removal.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class UnlockDelayedProjectRemoval < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class ApplicationSetting < MigrationRecord
+ self.table_name = 'application_settings'
+ end
+
+ # As part of https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86568 the
+ # lock_delayed_project_removal setting is updated for the first time. No up
+ # migration is needed because the column existsted. However a down migration
+ # is needed to disable the settting because users would have no way to edit it
+ # and would have the cascading setting permanently locked on groups.
+
+ def up
+ # no-op
+ end
+
+ def down
+ ApplicationSetting.reset_column_information
+
+ ApplicationSetting.update_all(lock_delayed_project_removal: false)
+ end
+end
diff --git a/db/migrate/20220520143105_add_keys_relation_to_ssh_signatures.rb b/db/migrate/20220520143105_add_keys_relation_to_ssh_signatures.rb
new file mode 100644
index 00000000000..15fc3e19439
--- /dev/null
+++ b/db/migrate/20220520143105_add_keys_relation_to_ssh_signatures.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddKeysRelationToSshSignatures < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ssh_signatures, :keys, column: :key_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :ssh_signatures, column: :key_id
+ end
+ end
+end
diff --git a/db/migrate/20220520144821_add_registry_migration_pre_import_tags_rate_to_application_settings.rb b/db/migrate/20220520144821_add_registry_migration_pre_import_tags_rate_to_application_settings.rb
new file mode 100644
index 00000000000..f9451b38b82
--- /dev/null
+++ b/db/migrate/20220520144821_add_registry_migration_pre_import_tags_rate_to_application_settings.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddRegistryMigrationPreImportTagsRateToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :container_registry_pre_import_tags_rate,
+ :decimal,
+ precision: 6,
+ scale: 2,
+ default: 0.5,
+ null: false
+ end
+end
diff --git a/db/migrate/20220523030804_add_web_hook_calls_med_and_max_to_plan_limits.rb b/db/migrate/20220523030804_add_web_hook_calls_med_and_max_to_plan_limits.rb
new file mode 100644
index 00000000000..c1ed306551f
--- /dev/null
+++ b/db/migrate/20220523030804_add_web_hook_calls_med_and_max_to_plan_limits.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddWebHookCallsMedAndMaxToPlanLimits < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :plan_limits, :web_hook_calls_mid, :integer, null: false, default: 0
+ add_column :plan_limits, :web_hook_calls_low, :integer, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20220523030805_add_web_hook_calls_to_plan_limits_paid_tiers.rb b/db/migrate/20220523030805_add_web_hook_calls_to_plan_limits_paid_tiers.rb
new file mode 100644
index 00000000000..842bb297803
--- /dev/null
+++ b/db/migrate/20220523030805_add_web_hook_calls_to_plan_limits_paid_tiers.rb
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+class AddWebHookCallsToPlanLimitsPaidTiers < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ MAX_RATE_LIMIT_NAME = 'web_hook_calls'
+ MID_RATE_LIMIT_NAME = 'web_hook_calls_mid'
+ MIN_RATE_LIMIT_NAME = 'web_hook_calls_low'
+
+ UP_FREE_LIMITS = {
+ MAX_RATE_LIMIT_NAME => 500,
+ MID_RATE_LIMIT_NAME => 500,
+ MIN_RATE_LIMIT_NAME => 500
+ }.freeze
+
+ UP_PREMIUM_LIMITS = {
+ MAX_RATE_LIMIT_NAME => 4_000,
+ MID_RATE_LIMIT_NAME => 2_800,
+ MIN_RATE_LIMIT_NAME => 1_600
+ }.freeze
+
+ UP_ULTIMATE_LIMITS = {
+ MAX_RATE_LIMIT_NAME => 13_000,
+ MID_RATE_LIMIT_NAME => 9_000,
+ MIN_RATE_LIMIT_NAME => 6_000
+ }.freeze
+
+ DOWN_FREE_LIMITS = {
+ # 120 is the value for 'free' migrated in `db/migrate/20210601131742_update_web_hook_calls_limit.rb`
+ MAX_RATE_LIMIT_NAME => 120,
+ MID_RATE_LIMIT_NAME => 0,
+ MIN_RATE_LIMIT_NAME => 0
+ }.freeze
+
+ DOWN_PAID_LIMITS = {
+ MAX_RATE_LIMIT_NAME => 0,
+ MID_RATE_LIMIT_NAME => 0,
+ MIN_RATE_LIMIT_NAME => 0
+ }.freeze
+
+ def up
+ return unless Gitlab.com?
+
+ apply_limits('free', UP_FREE_LIMITS)
+
+ # Apply Premium limits
+ apply_limits('bronze', UP_PREMIUM_LIMITS)
+ apply_limits('silver', UP_PREMIUM_LIMITS)
+ apply_limits('premium', UP_PREMIUM_LIMITS)
+ apply_limits('premium_trial', UP_PREMIUM_LIMITS)
+
+ # Apply Ultimate limits
+ apply_limits('gold', UP_ULTIMATE_LIMITS)
+ apply_limits('ultimate', UP_ULTIMATE_LIMITS)
+ apply_limits('ultimate_trial', UP_ULTIMATE_LIMITS)
+ apply_limits('opensource', UP_ULTIMATE_LIMITS)
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ apply_limits('free', DOWN_FREE_LIMITS)
+
+ apply_limits('bronze', DOWN_PAID_LIMITS)
+ apply_limits('silver', DOWN_PAID_LIMITS)
+ apply_limits('premium', DOWN_PAID_LIMITS)
+ apply_limits('premium_trial', DOWN_PAID_LIMITS)
+ apply_limits('gold', DOWN_PAID_LIMITS)
+ apply_limits('ultimate', DOWN_PAID_LIMITS)
+ apply_limits('ultimate_trial', DOWN_PAID_LIMITS)
+ apply_limits('opensource', DOWN_PAID_LIMITS)
+ end
+
+ private
+
+ def apply_limits(plan_name, limits)
+ limits.each_pair do |limit_name, limit|
+ create_or_update_plan_limit(limit_name, plan_name, limit)
+ end
+ end
+end
diff --git a/db/migrate/20220524021855_add_deleted_at_to_terraform_states.rb b/db/migrate/20220524021855_add_deleted_at_to_terraform_states.rb
new file mode 100644
index 00000000000..01bbeb17db7
--- /dev/null
+++ b/db/migrate/20220524021855_add_deleted_at_to_terraform_states.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDeletedAtToTerraformStates < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :terraform_states, :deleted_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20220524141800_create_audit_events_streaming_headers.rb b/db/migrate/20220524141800_create_audit_events_streaming_headers.rb
new file mode 100644
index 00000000000..2bd0362874c
--- /dev/null
+++ b/db/migrate/20220524141800_create_audit_events_streaming_headers.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CreateAuditEventsStreamingHeaders < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'idx_streaming_headers_on_external_audit_event_destination_id'
+ UNIQ_INDEX_NAME = 'idx_external_audit_event_destination_id_key_uniq'
+
+ def change
+ create_table :audit_events_streaming_headers do |t|
+ t.timestamps_with_timezone null: false
+ t.references :external_audit_event_destination,
+ null: false,
+ index: { name: INDEX_NAME },
+ foreign_key: { to_table: 'audit_events_external_audit_event_destinations', on_delete: :cascade }
+ t.text :key, null: false, limit: 255
+ t.text :value, null: false, limit: 255
+
+ t.index [:key, :external_audit_event_destination_id], unique: true, name: UNIQ_INDEX_NAME
+ end
+ end
+end
diff --git a/db/migrate/20220524191259_add_application_settings_container_registry_pre_import_tags_rate_constraint.rb b/db/migrate/20220524191259_add_application_settings_container_registry_pre_import_tags_rate_constraint.rb
new file mode 100644
index 00000000000..020db30d529
--- /dev/null
+++ b/db/migrate/20220524191259_add_application_settings_container_registry_pre_import_tags_rate_constraint.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddApplicationSettingsContainerRegistryPreImportTagsRateConstraint < Gitlab::Database::Migration[2.0]
+ CONSTRAINT_NAME = 'app_settings_container_registry_pre_import_tags_rate_positive'
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint :application_settings, 'container_registry_pre_import_tags_rate >= 0', CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :application_settings, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20220525082303_create_issuable_resource_links.rb b/db/migrate/20220525082303_create_issuable_resource_links.rb
new file mode 100644
index 00000000000..d6cf3057821
--- /dev/null
+++ b/db/migrate/20220525082303_create_issuable_resource_links.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateIssuableResourceLinks < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :issuable_resource_links do |t|
+ t.references :issue, null: false, foreign_key: { on_delete: :cascade }, index: true
+ t.text :link_text, null: true, limit: 255
+ t.text :link, null: false, limit: 2200
+ t.integer :link_type, null: false, limit: 2, default: 0 # general resource link
+
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/migrate/20220525123825_add_raw_to_ci_pipeline_variables.rb b/db/migrate/20220525123825_add_raw_to_ci_pipeline_variables.rb
new file mode 100644
index 00000000000..258b4631643
--- /dev/null
+++ b/db/migrate/20220525123825_add_raw_to_ci_pipeline_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRawToCiPipelineVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_pipeline_variables, :raw, :boolean, null: false, default: true
+ end
+end
diff --git a/db/migrate/20220525123851_add_raw_to_ci_group_variables.rb b/db/migrate/20220525123851_add_raw_to_ci_group_variables.rb
new file mode 100644
index 00000000000..9eae210d8c3
--- /dev/null
+++ b/db/migrate/20220525123851_add_raw_to_ci_group_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRawToCiGroupVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_group_variables, :raw, :boolean, null: false, default: true
+ end
+end
diff --git a/db/migrate/20220525123914_add_raw_to_ci_instance_variables.rb b/db/migrate/20220525123914_add_raw_to_ci_instance_variables.rb
new file mode 100644
index 00000000000..71674b48e39
--- /dev/null
+++ b/db/migrate/20220525123914_add_raw_to_ci_instance_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRawToCiInstanceVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_instance_variables, :raw, :boolean, null: false, default: true
+ end
+end
diff --git a/db/migrate/20220525123940_add_raw_to_ci_job_variables.rb b/db/migrate/20220525123940_add_raw_to_ci_job_variables.rb
new file mode 100644
index 00000000000..abd1f1eb211
--- /dev/null
+++ b/db/migrate/20220525123940_add_raw_to_ci_job_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRawToCiJobVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_job_variables, :raw, :boolean, null: false, default: true
+ end
+end
diff --git a/db/migrate/20220525124104_add_raw_to_ci_pipeline_schedule_variables.rb b/db/migrate/20220525124104_add_raw_to_ci_pipeline_schedule_variables.rb
new file mode 100644
index 00000000000..c7a3b832552
--- /dev/null
+++ b/db/migrate/20220525124104_add_raw_to_ci_pipeline_schedule_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRawToCiPipelineScheduleVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_pipeline_schedule_variables, :raw, :boolean, null: false, default: true
+ end
+end
diff --git a/db/migrate/20220525124125_add_raw_to_ci_variables.rb b/db/migrate/20220525124125_add_raw_to_ci_variables.rb
new file mode 100644
index 00000000000..168cd107d1c
--- /dev/null
+++ b/db/migrate/20220525124125_add_raw_to_ci_variables.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRawToCiVariables < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_variables, :raw, :boolean, null: false, default: true
+ end
+end
diff --git a/db/migrate/20220530103023_add_created_at_and_id_index_to_deployment_approvals.rb b/db/migrate/20220530103023_add_created_at_and_id_index_to_deployment_approvals.rb
new file mode 100644
index 00000000000..88117b310c9
--- /dev/null
+++ b/db/migrate/20220530103023_add_created_at_and_id_index_to_deployment_approvals.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddCreatedAtAndIdIndexToDeploymentApprovals < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_deployment_approvals_on_created_at_and_id'
+
+ def up
+ add_concurrent_index :deployment_approvals, %i[created_at id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :deployment_approvals, %i[created_at id], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220530104431_add_timestamps_to_compliance_frameworks.rb b/db/migrate/20220530104431_add_timestamps_to_compliance_frameworks.rb
new file mode 100644
index 00000000000..88013fddc81
--- /dev/null
+++ b/db/migrate/20220530104431_add_timestamps_to_compliance_frameworks.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTimestampsToComplianceFrameworks < Gitlab::Database::Migration[2.0]
+ def up
+ add_column :compliance_management_frameworks, :created_at, :datetime_with_timezone, null: true
+ add_column :compliance_management_frameworks, :updated_at, :datetime_with_timezone, null: true
+ end
+
+ def down
+ remove_column :compliance_management_frameworks, :created_at
+ remove_column :compliance_management_frameworks, :updated_at
+ end
+end
diff --git a/db/migrate/20220531100920_add_license_usage_data_exported_to_application_settings.rb b/db/migrate/20220531100920_add_license_usage_data_exported_to_application_settings.rb
new file mode 100644
index 00000000000..825697d5387
--- /dev/null
+++ b/db/migrate/20220531100920_add_license_usage_data_exported_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddLicenseUsageDataExportedToApplicationSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :application_settings, :license_usage_data_exported, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20220601091804_add_semver_column_to_ci_runners.rb b/db/migrate/20220601091804_add_semver_column_to_ci_runners.rb
new file mode 100644
index 00000000000..4d4739a03e0
--- /dev/null
+++ b/db/migrate/20220601091804_add_semver_column_to_ci_runners.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddSemverColumnToCiRunners < Gitlab::Database::Migration[2.0]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20220601091805_add_text_limit_to_ci_runners_semver
+ def up
+ add_column :ci_runners, :semver, :text, null: true
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ def down
+ remove_column :ci_runners, :semver
+ end
+end
diff --git a/db/migrate/20220601091805_add_text_limit_to_ci_runners_semver.rb b/db/migrate/20220601091805_add_text_limit_to_ci_runners_semver.rb
new file mode 100644
index 00000000000..dac067add90
--- /dev/null
+++ b/db/migrate/20220601091805_add_text_limit_to_ci_runners_semver.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToCiRunnersSemver < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :ci_runners, :semver, 16
+ end
+
+ def down
+ remove_text_limit :ci_runners, :semver
+ end
+end
diff --git a/db/migrate/20220601101800_add_index_on_runner_id_and_semver_columns.rb b/db/migrate/20220601101800_add_index_on_runner_id_and_semver_columns.rb
new file mode 100644
index 00000000000..1b5aa6237f6
--- /dev/null
+++ b/db/migrate/20220601101800_add_index_on_runner_id_and_semver_columns.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnRunnerIdAndSemverColumns < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_runners_on_id_and_semver_cidr'
+
+ def up
+ add_concurrent_index :ci_runners,
+ 'id, (semver::cidr)',
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_runners, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220601223501_add_vulnerability_related_columns.rb b/db/migrate/20220601223501_add_vulnerability_related_columns.rb
new file mode 100644
index 00000000000..be310b02467
--- /dev/null
+++ b/db/migrate/20220601223501_add_vulnerability_related_columns.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class AddVulnerabilityRelatedColumns < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :approval_merge_request_rules,
+ :vulnerabilities_allowed,
+ :integer,
+ limit: 2,
+ null: false,
+ default: 0
+ add_column :approval_merge_request_rules,
+ :scanners,
+ :text,
+ array: true,
+ null: false,
+ default: []
+ add_column :approval_merge_request_rules,
+ :severity_levels,
+ :text,
+ array: true,
+ null: false,
+ default: []
+ add_column :approval_merge_request_rules,
+ :vulnerability_states,
+ :text,
+ array: true,
+ null: false,
+ default: ['newly_detected']
+ end
+end
diff --git a/db/migrate/20220602130306_add_namespace_type_index.rb b/db/migrate/20220602130306_add_namespace_type_index.rb
new file mode 100644
index 00000000000..b20f36b3278
--- /dev/null
+++ b/db/migrate/20220602130306_add_namespace_type_index.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddNamespaceTypeIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_groups_on_parent_id_id'
+
+ def up
+ add_concurrent_index :namespaces, [:parent_id, :id], where: "type = 'Group'", name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name(:namespaces, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20220603095158_drop_ci_build_report_results_build_id_sequence.rb b/db/migrate/20220603095158_drop_ci_build_report_results_build_id_sequence.rb
new file mode 100644
index 00000000000..370eddf4390
--- /dev/null
+++ b/db/migrate/20220603095158_drop_ci_build_report_results_build_id_sequence.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class DropCiBuildReportResultsBuildIdSequence < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ drop_sequence(:ci_build_report_results, :build_id, :ci_build_report_results_build_id_seq)
+ end
+
+ def down
+ add_sequence(:ci_build_report_results, :build_id, :ci_build_report_results_build_id_seq, 1)
+ end
+end
diff --git a/db/migrate/20220605170009_add_url_vars_to_web_hook.rb b/db/migrate/20220605170009_add_url_vars_to_web_hook.rb
new file mode 100644
index 00000000000..207b0fc10c2
--- /dev/null
+++ b/db/migrate/20220605170009_add_url_vars_to_web_hook.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddUrlVarsToWebHook < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :web_hooks, :encrypted_url_variables, :binary
+ add_column :web_hooks, :encrypted_url_variables_iv, :binary
+ end
+end
diff --git a/db/migrate/20220607011733_add_phone_verification_code_enabled_to_application_settings.rb b/db/migrate/20220607011733_add_phone_verification_code_enabled_to_application_settings.rb
new file mode 100644
index 00000000000..321e55a2abf
--- /dev/null
+++ b/db/migrate/20220607011733_add_phone_verification_code_enabled_to_application_settings.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddPhoneVerificationCodeEnabledToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def up
+ add_column :application_settings,
+ :phone_verification_code_enabled,
+ :boolean,
+ null: false,
+ default: false,
+ comment: 'JiHu-specific column'
+ end
+
+ def down
+ remove_column :application_settings, :phone_verification_code_enabled
+ end
+end
diff --git a/db/migrate/20220607095219_drop_ci_pipelines_config_pipeline_id_sequence.rb b/db/migrate/20220607095219_drop_ci_pipelines_config_pipeline_id_sequence.rb
new file mode 100644
index 00000000000..fb7e14330cd
--- /dev/null
+++ b/db/migrate/20220607095219_drop_ci_pipelines_config_pipeline_id_sequence.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class DropCiPipelinesConfigPipelineIdSequence < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ drop_sequence(:ci_pipelines_config, :pipeline_id, :ci_pipelines_config_pipeline_id_seq)
+ end
+
+ def down
+ add_sequence(:ci_pipelines_config, :pipeline_id, :ci_pipelines_config_pipeline_id_seq, 1)
+ end
+end
diff --git a/db/migrate/20220607115703_drop_ci_job_artifact_states_job_artifact_id_sequence.rb b/db/migrate/20220607115703_drop_ci_job_artifact_states_job_artifact_id_sequence.rb
new file mode 100644
index 00000000000..d3d56f72cee
--- /dev/null
+++ b/db/migrate/20220607115703_drop_ci_job_artifact_states_job_artifact_id_sequence.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class DropCiJobArtifactStatesJobArtifactIdSequence < Gitlab::Database::Migration[2.0]
+ def up
+ drop_sequence(:ci_job_artifact_states, :job_artifact_id, :ci_job_artifact_states_job_artifact_id_seq)
+ end
+
+ def down
+ add_sequence(:ci_job_artifact_states, :job_artifact_id, :ci_job_artifact_states_job_artifact_id_seq, 1)
+ end
+end
diff --git a/db/migrate/20220608114734_prepare_confidential_note_index_on_id.rb b/db/migrate/20220608114734_prepare_confidential_note_index_on_id.rb
new file mode 100644
index 00000000000..7c23029283c
--- /dev/null
+++ b/db/migrate/20220608114734_prepare_confidential_note_index_on_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class PrepareConfidentialNoteIndexOnId < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_notes_on_id_where_confidential'
+
+ def up
+ prepare_async_index :notes, :id, where: 'confidential = true', name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :notes, :id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220609150626_add_partial_index_on_slack_integrations_with_bot_user_id.rb b/db/migrate/20220609150626_add_partial_index_on_slack_integrations_with_bot_user_id.rb
new file mode 100644
index 00000000000..498c1da9e19
--- /dev/null
+++ b/db/migrate/20220609150626_add_partial_index_on_slack_integrations_with_bot_user_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddPartialIndexOnSlackIntegrationsWithBotUserId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'partial_index_slack_integrations_with_bot_user_id'
+
+ def up
+ add_concurrent_index :slack_integrations, :id, name: INDEX_NAME, where: 'bot_user_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :slack_integrations, :id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220610074326_add_epic_issue_weight.rb b/db/migrate/20220610074326_add_epic_issue_weight.rb
new file mode 100644
index 00000000000..b1c1f1c56c7
--- /dev/null
+++ b/db/migrate/20220610074326_add_epic_issue_weight.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddEpicIssueWeight < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :epics, :total_opened_issue_weight, :integer, default: 0, null: false
+ add_column :epics, :total_closed_issue_weight, :integer, default: 0, null: false
+ add_column :epics, :total_opened_issue_count, :integer, default: 0, null: false
+ add_column :epics, :total_closed_issue_count, :integer, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20220610125248_add_enabled_git_access_protocol_to_namespace_settings.rb b/db/migrate/20220610125248_add_enabled_git_access_protocol_to_namespace_settings.rb
new file mode 100644
index 00000000000..2f16467acd1
--- /dev/null
+++ b/db/migrate/20220610125248_add_enabled_git_access_protocol_to_namespace_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddEnabledGitAccessProtocolToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :namespace_settings, :enabled_git_access_protocol, :integer, default: 0, null: false, limit: 2
+ end
+end
diff --git a/db/migrate/20220614095912_add_has_vulnerabilities_to_cluster_agents.rb b/db/migrate/20220614095912_add_has_vulnerabilities_to_cluster_agents.rb
new file mode 100644
index 00000000000..e4e4e3ab7ae
--- /dev/null
+++ b/db/migrate/20220614095912_add_has_vulnerabilities_to_cluster_agents.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddHasVulnerabilitiesToClusterAgents < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :cluster_agents, :has_vulnerabilities, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20220615091059_add_created_at_index_to_compliance_management_frameworks.rb b/db/migrate/20220615091059_add_created_at_index_to_compliance_management_frameworks.rb
new file mode 100644
index 00000000000..a930dde9a83
--- /dev/null
+++ b/db/migrate/20220615091059_add_created_at_index_to_compliance_management_frameworks.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddCreatedAtIndexToComplianceManagementFrameworks < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = "i_compliance_frameworks_on_id_and_created_at"
+
+ def up
+ add_concurrent_index :compliance_management_frameworks,
+ [:id, :created_at, :pipeline_configuration_full_path],
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :compliance_management_frameworks, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220615105811_add_index_on_clusters_agent_project_id_and_has_vulnerabilities_columns.rb b/db/migrate/20220615105811_add_index_on_clusters_agent_project_id_and_has_vulnerabilities_columns.rb
new file mode 100644
index 00000000000..007f36c26ed
--- /dev/null
+++ b/db/migrate/20220615105811_add_index_on_clusters_agent_project_id_and_has_vulnerabilities_columns.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnClustersAgentProjectIdAndHasVulnerabilitiesColumns < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_cluster_agents_on_project_id_and_has_vulnerabilities'
+
+ def up
+ add_concurrent_index :cluster_agents,
+ [:project_id, :has_vulnerabilities],
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :cluster_agents, INDEX_NAME
+ end
+end