summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /db/migrate
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
downloadgitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20190225160300_steal_encrypt_runners_tokens.rb19
-rw-r--r--db/migrate/20190315191339_create_merge_request_assignees_table.rb2
-rw-r--r--db/migrate/20190722144316_create_milestone_releases_table.rb2
-rw-r--r--db/migrate/20190927055500_create_description_versions.rb2
-rw-r--r--db/migrate/20191112212815_create_web_authn_table.rb26
-rw-r--r--db/migrate/20191118053631_add_group_deletion_schedules.rb2
-rw-r--r--db/migrate/20191127151619_create_gitlab_subscription_histories.rb2
-rw-r--r--db/migrate/20200214025454_add_canonical_emails.rb2
-rw-r--r--db/migrate/20200227165129_create_user_details.rb2
-rw-r--r--db/migrate/20200229171700_create_custom_emojis.rb29
-rw-r--r--db/migrate/20200305020458_add_label_restore_table.rb31
-rw-r--r--db/migrate/20200305020459_add_label_restore_foreign_keys.rb35
-rw-r--r--db/migrate/20200311093210_create_user_highest_roles.rb2
-rw-r--r--db/migrate/20200326122700_create_diff_note_positions.rb2
-rw-r--r--db/migrate/20200330203837_recreate_ci_ref.rb2
-rw-r--r--db/migrate/20200331132103_add_project_compliance_framework_settings_table.rb2
-rw-r--r--db/migrate/20200407182205_create_partitioned_foreign_keys.rb2
-rw-r--r--db/migrate/20200407222647_create_project_repository_storage_moves.rb2
-rw-r--r--db/migrate/20200408125046_create_ci_freeze_periods.rb2
-rw-r--r--db/migrate/20200416005331_create_status_page_published_incidents.rb2
-rw-r--r--db/migrate/20200417044453_create_alert_management_alerts.rb2
-rw-r--r--db/migrate/20200420104303_add_group_import_states_table.rb2
-rw-r--r--db/migrate/20200420115948_create_metrics_users_starred_dashboard.rb2
-rw-r--r--db/migrate/20200422091541_create_ci_instance_variables.rb2
-rw-r--r--db/migrate/20200424102023_add_shared_runners_enabled_and_override_to_namespaces.rb21
-rw-r--r--db/migrate/20200424135319_create_nuget_dependency_link_metadata.rb2
-rw-r--r--db/migrate/20200430130048_create_packages_nuget_metadata.rb2
-rw-r--r--db/migrate/20200430174637_create_group_deploy_keys.rb2
-rw-r--r--db/migrate/20200510181937_add_web_authn_xid_to_user_details.rb12
-rw-r--r--db/migrate/20200510182218_add_text_limit_to_user_details_webauthn_xid.rb16
-rw-r--r--db/migrate/20200510182556_add_text_limit_to_webauthn_registrations_name.rb16
-rw-r--r--db/migrate/20200510182824_add_text_limit_to_webauthn_registrations_credential_xid.rb16
-rw-r--r--db/migrate/20200510183128_add_foreign_key_from_webauthn_registrations_to_users.rb21
-rw-r--r--db/migrate/20200521225327_create_alert_management_alert_assignees.rb2
-rw-r--r--db/migrate/20200522205606_create_group_deploy_keys_group.rb25
-rw-r--r--db/migrate/20200524104346_add_source_to_resource_state_event.rb21
-rw-r--r--db/migrate/20200526193555_add_squash_option_to_project.rb9
-rw-r--r--db/migrate/20200526231421_update_index_approval_rule_name_for_code_owners_rule_type.rb116
-rw-r--r--db/migrate/20200527211605_add_locked_to_ci_pipelines.rb19
-rw-r--r--db/migrate/20200604001128_add_secrets_to_ci_builds_metadata.rb19
-rw-r--r--db/migrate/20200604143628_create_project_security_settings.rb2
-rw-r--r--db/migrate/20200604145731_create_board_user_preferences.rb2
-rw-r--r--db/migrate/20200605160806_add_index_on_repository_size_and_project_id_to_project_statistics.rb17
-rw-r--r--db/migrate/20200605160836_add_index_on_storage_size_and_project_id_to_project_statistics.rb17
-rw-r--r--db/migrate/20200605160851_add_index_on_wiki_size_and_project_id_to_project_statistics.rb17
-rw-r--r--db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb19
-rw-r--r--db/migrate/20200610130002_create_vulnerability_statistics.rb30
-rw-r--r--db/migrate/20200613104045_add_compliance_frameworks_to_application_settings.rb19
-rw-r--r--db/migrate/20200615141554_add_closed_by_fields_to_resource_state_events.rb17
-rw-r--r--db/migrate/20200615193524_add_verify_known_sign_in_to_application_settings.rb9
-rw-r--r--db/migrate/20200615234047_create_clusters_applications_cilium.rb14
-rw-r--r--db/migrate/20200616124338_add_plan_limits_for_max_size_per_artifact_type.rb48
-rw-r--r--db/migrate/20200616145031_add_author_id_index_to_audit_events.rb22
-rw-r--r--db/migrate/20200617000757_clean_up_file_store_lfs_objects.rb21
-rw-r--r--db/migrate/20200617001001_clean_up_store_uploads.rb21
-rw-r--r--db/migrate/20200617001118_clean_up_file_store_ci_job_artifacts.rb23
-rw-r--r--db/migrate/20200617150041_create_namespace_limits.rb22
-rw-r--r--db/migrate/20200617205000_add_deploy_key_id_to_push_access_levels.rb22
-rw-r--r--db/migrate/20200618105638_add_index_on_id_and_created_at_to_snippets.rb17
-rw-r--r--db/migrate/20200618134223_restore_previous_schema_without_lock_version_null_constraint.rb20
-rw-r--r--db/migrate/20200618134723_restore_previous_schema_with_lock_version_indices.rb22
-rw-r--r--db/migrate/20200619000316_add_has_confluence_to_project_settings.rb19
-rw-r--r--db/migrate/20200619154527_add_project_key_to_jira_tracker_data.rb12
-rw-r--r--db/migrate/20200619154528_add_text_limit_to_jira_tracker_data_project_key.rb17
-rw-r--r--db/migrate/20200622040750_add_prometheus_alert_id_to_alert_management_alerts.rb16
-rw-r--r--db/migrate/20200622070606_add_vendor_to_vulnerability_scanners.rb23
-rw-r--r--db/migrate/20200622070620_add_limit_to_vulnerability_scanners_vendor.rb17
-rw-r--r--db/migrate/20200622095419_add_snippets_size_to_project_statistics.rb9
-rw-r--r--db/migrate/20200622103836_create_snippet_statistics.rb24
-rw-r--r--db/migrate/20200622104923_create_ci_pipeline_messages_table.rb27
-rw-r--r--db/migrate/20200622235737_remove_index_ci_job_artifacts_file_store_is_null.rb18
-rw-r--r--db/migrate/20200623000148_remove_index_lfs_objects_file_store_is_null.rb18
-rw-r--r--db/migrate/20200623000320_remove_index_uploads_store_is_null.rb18
-rw-r--r--db/migrate/20200623073431_add_source_merge_request_id_to_resource_state_events.rb33
-rw-r--r--db/migrate/20200623090030_add_author_name_to_audit_event.rb22
-rw-r--r--db/migrate/20200623121135_create_dynamic_partitions_schema.rb19
-rw-r--r--db/migrate/20200623141217_add_view_diffs_file_by_file_to_user_preferences.rb21
-rw-r--r--db/migrate/20200623141544_create_elastic_reindexing_task.rb33
-rw-r--r--db/migrate/20200623170000_create_static_partitions_schema.rb19
-rw-r--r--db/migrate/20200623185440_add_product_analytics_table.rb202
-rw-r--r--db/migrate/20200624075411_add_storage_size_limit_to_plan_limit.rb9
-rw-r--r--db/migrate/20200624142107_create_analytics_cycle_analytics_group_value_streams.rb33
-rw-r--r--db/migrate/20200624142207_add_group_value_stream_to_cycle_analytics_group_stages.rb19
-rw-r--r--db/migrate/20200624222443_add_default_branch_name_to_application_settings.rb12
-rw-r--r--db/migrate/20200625045442_add_idx_and_fk_for_prometheus_and_environment_to_alert_management_alerts.rb25
-rw-r--r--db/migrate/20200625082258_add_snippets_size_to_root_storage_statistics.rb19
-rw-r--r--db/migrate/20200625113337_add_last_used_to_personal_access_tokens.rb19
-rw-r--r--db/migrate/20200625174052_add_partial_index_to_locked_pipelines.rb17
-rw-r--r--db/migrate/20200625190458_add_limit_to_default_branch_name_to_application_settings.rb17
-rw-r--r--db/migrate/20200626130220_drop_partitions_dynamic_schema_if_exists.rb14
-rw-r--r--db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb29
-rw-r--r--db/migrate/20200629192638_add_uniq_index_on_metric_identifier_and_project_id.rb17
-rw-r--r--db/migrate/20200630091656_add_bio_html_to_user_details.rb24
-rw-r--r--db/migrate/20200630110826_add_documents_count_target_to_elastic_reindexing_tasks.rb9
-rw-r--r--db/migrate/20200701064756_add_not_valid_foreign_key_to_cycle_analytics_group_stages.rb22
-rw-r--r--db/migrate/20200701093859_add_import_export_limits_to_application_settings.rb15
-rw-r--r--db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb19
-rw-r--r--db/migrate/20200701205710_create_background_migration_jobs.rb29
-rw-r--r--db/migrate/20200702123805_change_project_id_index_to_be_unique_on_vulnerability_statistics_table.rb17
-rw-r--r--db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb22
-rw-r--r--db/migrate/20200703121557_remove_f_keys_from_ci_daily_report_results_table.rb21
-rw-r--r--db/migrate/20200703124823_create_namespace_settings.rb22
-rw-r--r--db/migrate/20200703154822_add_issues_enabled_to_jira_tracker_data.rb9
-rw-r--r--db/migrate/20200706005325_remove_elastic_batch_project_indexer_worker_queue.rb11
-rw-r--r--db/migrate/20200706035141_adjust_unique_index_alert_management_alerts.rb35
-rw-r--r--db/migrate/20200706170536_add_temporary_storage_increase_to_namespace_limits.rb9
-rw-r--r--db/migrate/20200707071941_drop_old_non_unique_index_on_mr_metrics.rb18
-rw-r--r--db/migrate/20200707094341_add_browser_performance_to_plan_limits.rb9
-rw-r--r--db/migrate/20200707095849_add_load_performance_to_plan_limits.rb9
-rw-r--r--db/migrate/20200708080631_add_pager_duty_integration_columns_to_project_incident_management_settings.rb13
-rw-r--r--db/migrate/20200710105332_change_issues_create_limit_default.rb19
-rw-r--r--db/migrate/20200710130234_add_limit_constraints_to_project_incident_management_settings_token.rb18
-rw-r--r--db/migrate/20200712084655_create_dast_sites.rb27
-rw-r--r--db/migrate/20200712235622_create_dast_site_profiles.rb28
-rw-r--r--db/migrate/20200713152443_add_background_migration_job_index_for_partitioning_migrations.rb18
-rw-r--r--db/migrate/20200716044023_add_entity_path_to_audit_events.rb21
-rw-r--r--db/migrate/20200716120419_add_text_limit_on_entity_path_to_audit_events.rb17
117 files changed, 2087 insertions, 69 deletions
diff --git a/db/migrate/20190225160300_steal_encrypt_runners_tokens.rb b/db/migrate/20190225160300_steal_encrypt_runners_tokens.rb
deleted file mode 100644
index 18c0d2a2e1b..00000000000
--- a/db/migrate/20190225160300_steal_encrypt_runners_tokens.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-class StealEncryptRunnersTokens < ActiveRecord::Migration[5.0]
- include Gitlab::Database::MigrationHelpers
-
- # This cleans after `EncryptRunnersTokens`
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- Gitlab::BackgroundMigration.steal('EncryptRunnersTokens')
- end
-
- def down
- # no-op
- end
-end
diff --git a/db/migrate/20190315191339_create_merge_request_assignees_table.rb b/db/migrate/20190315191339_create_merge_request_assignees_table.rb
index dbd9ea3e35b..6fc4463f281 100644
--- a/db/migrate/20190315191339_create_merge_request_assignees_table.rb
+++ b/db/migrate/20190315191339_create_merge_request_assignees_table.rb
@@ -17,8 +17,6 @@ class CreateMergeRequestAssigneesTable < ActiveRecord::Migration[5.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :merge_request_assignees
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20190722144316_create_milestone_releases_table.rb b/db/migrate/20190722144316_create_milestone_releases_table.rb
index 911ca941a56..55878bcec41 100644
--- a/db/migrate/20190722144316_create_milestone_releases_table.rb
+++ b/db/migrate/20190722144316_create_milestone_releases_table.rb
@@ -15,8 +15,6 @@ class CreateMilestoneReleasesTable < ActiveRecord::Migration[5.2]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :milestone_releases
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20190927055500_create_description_versions.rb b/db/migrate/20190927055500_create_description_versions.rb
index 9046ebbc499..b3082533a6f 100644
--- a/db/migrate/20190927055500_create_description_versions.rb
+++ b/db/migrate/20190927055500_create_description_versions.rb
@@ -24,8 +24,6 @@ class CreateDescriptionVersions < ActiveRecord::Migration[5.2]
def down
remove_column :system_note_metadata, :description_version_id
- # rubocop:disable Migration/DropTable
drop_table :description_versions
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20191112212815_create_web_authn_table.rb b/db/migrate/20191112212815_create_web_authn_table.rb
new file mode 100644
index 00000000000..72895f955df
--- /dev/null
+++ b/db/migrate/20191112212815_create_web_authn_table.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class CreateWebAuthnTable < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ # disable_ddl_transaction!
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limits are added in subsequent migration
+ def change
+ create_table :webauthn_registrations do |t|
+ t.bigint :user_id, null: false, index: true
+
+ t.bigint :counter, default: 0, null: false
+ t.timestamps_with_timezone
+ t.text :credential_xid, null: false, index: { unique: true }
+ t.text :name, null: false
+ # The length of the public key is determined by the device
+ # and not specified. Thus we can't set a limit
+ t.text :public_key, null: false # rubocop:disable Migration/AddLimitToTextColumns
+ end
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20191118053631_add_group_deletion_schedules.rb b/db/migrate/20191118053631_add_group_deletion_schedules.rb
index bc18480e5b9..6f3ed27e156 100644
--- a/db/migrate/20191118053631_add_group_deletion_schedules.rb
+++ b/db/migrate/20191118053631_add_group_deletion_schedules.rb
@@ -23,8 +23,6 @@ class AddGroupDeletionSchedules < ActiveRecord::Migration[5.2]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :group_deletion_schedules
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20191127151619_create_gitlab_subscription_histories.rb b/db/migrate/20191127151619_create_gitlab_subscription_histories.rb
index db2617112a3..718f2c1b313 100644
--- a/db/migrate/20191127151619_create_gitlab_subscription_histories.rb
+++ b/db/migrate/20191127151619_create_gitlab_subscription_histories.rb
@@ -23,8 +23,6 @@ class CreateGitlabSubscriptionHistories < ActiveRecord::Migration[5.2]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :gitlab_subscription_histories
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200214025454_add_canonical_emails.rb b/db/migrate/20200214025454_add_canonical_emails.rb
index 70ab7208ade..0732d39169d 100644
--- a/db/migrate/20200214025454_add_canonical_emails.rb
+++ b/db/migrate/20200214025454_add_canonical_emails.rb
@@ -20,9 +20,7 @@ class AddCanonicalEmails < ActiveRecord::Migration[6.0]
def down
with_lock_retries do
- # rubocop:disable Migration/DropTable
drop_table(:user_canonical_emails)
- # rubocop:enable Migration/DropTable
end
end
end
diff --git a/db/migrate/20200227165129_create_user_details.rb b/db/migrate/20200227165129_create_user_details.rb
index 474dc357266..89258eadb9f 100644
--- a/db/migrate/20200227165129_create_user_details.rb
+++ b/db/migrate/20200227165129_create_user_details.rb
@@ -20,9 +20,7 @@ class CreateUserDetails < ActiveRecord::Migration[6.0]
def down
with_lock_retries do
- # rubocop:disable Migration/DropTable
drop_table :user_details
- # rubocop:enable Migration/DropTable
end
end
end
diff --git a/db/migrate/20200229171700_create_custom_emojis.rb b/db/migrate/20200229171700_create_custom_emojis.rb
new file mode 100644
index 00000000000..1a60d7c8a63
--- /dev/null
+++ b/db/migrate/20200229171700_create_custom_emojis.rb
@@ -0,0 +1,29 @@
+class CreateCustomEmojis < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:custom_emoji)
+ create_table :custom_emoji do |t|
+ t.references :namespace, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.datetime_with_timezone :created_at, null: false
+ t.datetime_with_timezone :updated_at, null: false
+ t.text :name, null: false
+ t.text :file, null: false
+ end
+ end
+
+ unless index_exists?(:custom_emoji, [:namespace_id, :name], unique: true)
+ add_index :custom_emoji, [:namespace_id, :name], unique: true
+ end
+
+ add_text_limit(:custom_emoji, :name, 36)
+ add_text_limit(:custom_emoji, :file, 255)
+ end
+
+ def down
+ drop_table :custom_emoji
+ end
+end
diff --git a/db/migrate/20200305020458_add_label_restore_table.rb b/db/migrate/20200305020458_add_label_restore_table.rb
new file mode 100644
index 00000000000..a5809cfe14b
--- /dev/null
+++ b/db/migrate/20200305020458_add_label_restore_table.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddLabelRestoreTable < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ # copy table
+ execute "CREATE TABLE #{backup_labels_table_name} (LIKE #{labels_table_name} INCLUDING ALL);"
+
+ # make the primary key a real functioning one rather than incremental
+ execute "ALTER TABLE #{backup_labels_table_name} ALTER COLUMN ID DROP DEFAULT;"
+
+ # add some fields that make changes trackable
+ execute "ALTER TABLE #{backup_labels_table_name} ADD COLUMN restore_action INTEGER;"
+ execute "ALTER TABLE #{backup_labels_table_name} ADD COLUMN new_title VARCHAR;"
+ end
+
+ def down
+ drop_table backup_labels_table_name
+ end
+
+ private
+
+ def labels_table_name
+ :labels
+ end
+
+ def backup_labels_table_name
+ :backup_labels
+ end
+end
diff --git a/db/migrate/20200305020459_add_label_restore_foreign_keys.rb b/db/migrate/20200305020459_add_label_restore_foreign_keys.rb
new file mode 100644
index 00000000000..4b7c68cb20b
--- /dev/null
+++ b/db/migrate/20200305020459_add_label_restore_foreign_keys.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class AddLabelRestoreForeignKeys < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # create foreign keys
+ connection.foreign_keys(labels_table_name).each do |fk|
+ fk_options = fk.options
+ add_concurrent_foreign_key(backup_labels_table_name, fk.to_table, name: fk.name, column: fk_options[:column])
+ end
+ end
+
+ def down
+ connection.foreign_keys(backup_labels_table_name).each do |fk|
+ with_lock_retries do
+ remove_foreign_key backup_labels_table_name, name: fk.name
+ end
+ end
+ end
+
+ private
+
+ def labels_table_name
+ :labels
+ end
+
+ def backup_labels_table_name
+ :backup_labels
+ end
+end
diff --git a/db/migrate/20200311093210_create_user_highest_roles.rb b/db/migrate/20200311093210_create_user_highest_roles.rb
index df2b02b7d91..36007f196d1 100644
--- a/db/migrate/20200311093210_create_user_highest_roles.rb
+++ b/db/migrate/20200311093210_create_user_highest_roles.rb
@@ -19,9 +19,7 @@ class CreateUserHighestRoles < ActiveRecord::Migration[6.0]
def down
with_lock_retries do
- # rubocop:disable Migration/DropTable
drop_table :user_highest_roles
- # rubocop:enable Migration/DropTable
end
end
end
diff --git a/db/migrate/20200326122700_create_diff_note_positions.rb b/db/migrate/20200326122700_create_diff_note_positions.rb
index 6c558516471..d37f7fef078 100644
--- a/db/migrate/20200326122700_create_diff_note_positions.rb
+++ b/db/migrate/20200326122700_create_diff_note_positions.rb
@@ -30,8 +30,6 @@ class CreateDiffNotePositions < ActiveRecord::Migration[6.0]
# rubocop:enable Migration/AddLimitToTextColumns
def down
- # rubocop:disable Migration/DropTable
drop_table :diff_note_positions
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200330203837_recreate_ci_ref.rb b/db/migrate/20200330203837_recreate_ci_ref.rb
index 5a7bede4dc8..734795f594f 100644
--- a/db/migrate/20200330203837_recreate_ci_ref.rb
+++ b/db/migrate/20200330203837_recreate_ci_ref.rb
@@ -25,9 +25,7 @@ class RecreateCiRef < ActiveRecord::Migration[6.0]
def down
with_lock_retries do
- # rubocop:disable Migration/DropTable
drop_table :ci_refs
- # rubocop:enable Migration/DropTable
create_table :ci_refs do |t|
t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }, type: :integer
diff --git a/db/migrate/20200331132103_add_project_compliance_framework_settings_table.rb b/db/migrate/20200331132103_add_project_compliance_framework_settings_table.rb
index 169c8602cab..6af8c6db939 100644
--- a/db/migrate/20200331132103_add_project_compliance_framework_settings_table.rb
+++ b/db/migrate/20200331132103_add_project_compliance_framework_settings_table.rb
@@ -16,9 +16,7 @@ class AddProjectComplianceFrameworkSettingsTable < ActiveRecord::Migration[6.0]
def down
with_lock_retries do
- # rubocop:disable Migration/DropTable
drop_table :project_compliance_framework_settings
- # rubocop:enable Migration/DropTable
end
end
end
diff --git a/db/migrate/20200407182205_create_partitioned_foreign_keys.rb b/db/migrate/20200407182205_create_partitioned_foreign_keys.rb
index 59e7d88b238..aca8116d2dd 100644
--- a/db/migrate/20200407182205_create_partitioned_foreign_keys.rb
+++ b/db/migrate/20200407182205_create_partitioned_foreign_keys.rb
@@ -26,8 +26,6 @@ class CreatePartitionedForeignKeys < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :partitioned_foreign_keys
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200407222647_create_project_repository_storage_moves.rb b/db/migrate/20200407222647_create_project_repository_storage_moves.rb
index 98e44aa2fc6..402a1cdd4a6 100644
--- a/db/migrate/20200407222647_create_project_repository_storage_moves.rb
+++ b/db/migrate/20200407222647_create_project_repository_storage_moves.rb
@@ -26,8 +26,6 @@ class CreateProjectRepositoryStorageMoves < ActiveRecord::Migration[6.0]
remove_check_constraint(:project_repository_storage_moves, 'project_repository_storage_moves_source_storage_name')
remove_check_constraint(:project_repository_storage_moves, 'project_repository_storage_moves_destination_storage_name')
- # rubocop:disable Migration/DropTable
drop_table :project_repository_storage_moves
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200408125046_create_ci_freeze_periods.rb b/db/migrate/20200408125046_create_ci_freeze_periods.rb
index 98f0e20b11b..42a385150b8 100644
--- a/db/migrate/20200408125046_create_ci_freeze_periods.rb
+++ b/db/migrate/20200408125046_create_ci_freeze_periods.rb
@@ -25,8 +25,6 @@ class CreateCiFreezePeriods < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :ci_freeze_periods
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200416005331_create_status_page_published_incidents.rb b/db/migrate/20200416005331_create_status_page_published_incidents.rb
index ea2ddcde925..75889cd5bb6 100644
--- a/db/migrate/20200416005331_create_status_page_published_incidents.rb
+++ b/db/migrate/20200416005331_create_status_page_published_incidents.rb
@@ -15,8 +15,6 @@ class CreateStatusPagePublishedIncidents < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :status_page_published_incidents
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200417044453_create_alert_management_alerts.rb b/db/migrate/20200417044453_create_alert_management_alerts.rb
index 3509f4946a7..6221eeeb24b 100644
--- a/db/migrate/20200417044453_create_alert_management_alerts.rb
+++ b/db/migrate/20200417044453_create_alert_management_alerts.rb
@@ -39,8 +39,6 @@ class CreateAlertManagementAlerts < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :alert_management_alerts
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200420104303_add_group_import_states_table.rb b/db/migrate/20200420104303_add_group_import_states_table.rb
index 10b8cd4aa49..a44a2ea75f3 100644
--- a/db/migrate/20200420104303_add_group_import_states_table.rb
+++ b/db/migrate/20200420104303_add_group_import_states_table.rb
@@ -20,8 +20,6 @@ class AddGroupImportStatesTable < ActiveRecord::Migration[6.0]
# rubocop:enable Migration/AddLimitToTextColumns
def down
- # rubocop:disable Migration/DropTable
drop_table :group_import_states
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200420115948_create_metrics_users_starred_dashboard.rb b/db/migrate/20200420115948_create_metrics_users_starred_dashboard.rb
index 8e9495f3a83..27130136e9d 100644
--- a/db/migrate/20200420115948_create_metrics_users_starred_dashboard.rb
+++ b/db/migrate/20200420115948_create_metrics_users_starred_dashboard.rb
@@ -20,8 +20,6 @@ class CreateMetricsUsersStarredDashboard < ActiveRecord::Migration[6.0]
# rubocop: enable Migration/AddLimitToTextColumns
def down
- # rubocop:disable Migration/DropTable
drop_table :metrics_users_starred_dashboards
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200422091541_create_ci_instance_variables.rb b/db/migrate/20200422091541_create_ci_instance_variables.rb
index d1c954b4020..ab2a4722f89 100644
--- a/db/migrate/20200422091541_create_ci_instance_variables.rb
+++ b/db/migrate/20200422091541_create_ci_instance_variables.rb
@@ -26,8 +26,6 @@ class CreateCiInstanceVariables < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :ci_instance_variables
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200424102023_add_shared_runners_enabled_and_override_to_namespaces.rb b/db/migrate/20200424102023_add_shared_runners_enabled_and_override_to_namespaces.rb
new file mode 100644
index 00000000000..2555a50be44
--- /dev/null
+++ b/db/migrate/20200424102023_add_shared_runners_enabled_and_override_to_namespaces.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSharedRunnersEnabledAndOverrideToNamespaces < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :namespaces, :shared_runners_enabled, :boolean, default: true, null: false
+ add_column :namespaces, :allow_descendants_override_disabled_shared_runners, :boolean, default: false, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespaces, :shared_runners_enabled, :boolean
+ remove_column :namespaces, :allow_descendants_override_disabled_shared_runners, :boolean
+ end
+ end
+end
diff --git a/db/migrate/20200424135319_create_nuget_dependency_link_metadata.rb b/db/migrate/20200424135319_create_nuget_dependency_link_metadata.rb
index 79adf41f973..1043616a1c7 100644
--- a/db/migrate/20200424135319_create_nuget_dependency_link_metadata.rb
+++ b/db/migrate/20200424135319_create_nuget_dependency_link_metadata.rb
@@ -21,8 +21,6 @@ class CreateNugetDependencyLinkMetadata < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :packages_nuget_dependency_link_metadata
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200430130048_create_packages_nuget_metadata.rb b/db/migrate/20200430130048_create_packages_nuget_metadata.rb
index 3c89a143932..0f0d490c93d 100644
--- a/db/migrate/20200430130048_create_packages_nuget_metadata.rb
+++ b/db/migrate/20200430130048_create_packages_nuget_metadata.rb
@@ -29,8 +29,6 @@ class CreatePackagesNugetMetadata < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :packages_nuget_metadata
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200430174637_create_group_deploy_keys.rb b/db/migrate/20200430174637_create_group_deploy_keys.rb
index 283c8769a80..9771ae013ea 100644
--- a/db/migrate/20200430174637_create_group_deploy_keys.rb
+++ b/db/migrate/20200430174637_create_group_deploy_keys.rb
@@ -31,8 +31,6 @@ class CreateGroupDeployKeys < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :group_deploy_keys
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200510181937_add_web_authn_xid_to_user_details.rb b/db/migrate/20200510181937_add_web_authn_xid_to_user_details.rb
new file mode 100644
index 00000000000..d41e6611c45
--- /dev/null
+++ b/db/migrate/20200510181937_add_web_authn_xid_to_user_details.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddWebAuthnXidToUserDetails < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in subsequent migration
+ def change
+ add_column :user_details, :webauthn_xid, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20200510182218_add_text_limit_to_user_details_webauthn_xid.rb b/db/migrate/20200510182218_add_text_limit_to_user_details_webauthn_xid.rb
new file mode 100644
index 00000000000..715cfd771f5
--- /dev/null
+++ b/db/migrate/20200510182218_add_text_limit_to_user_details_webauthn_xid.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToUserDetailsWebauthnXid < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :user_details, :webauthn_xid, 100
+ end
+
+ def down
+ remove_text_limit :user_details, :webauthn_xid
+ end
+end
diff --git a/db/migrate/20200510182556_add_text_limit_to_webauthn_registrations_name.rb b/db/migrate/20200510182556_add_text_limit_to_webauthn_registrations_name.rb
new file mode 100644
index 00000000000..28805505ba6
--- /dev/null
+++ b/db/migrate/20200510182556_add_text_limit_to_webauthn_registrations_name.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToWebauthnRegistrationsName < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :webauthn_registrations, :name, 255
+ end
+
+ def down
+ remove_text_limit :webauthn_registrations, :name
+ end
+end
diff --git a/db/migrate/20200510182824_add_text_limit_to_webauthn_registrations_credential_xid.rb b/db/migrate/20200510182824_add_text_limit_to_webauthn_registrations_credential_xid.rb
new file mode 100644
index 00000000000..51155f370ef
--- /dev/null
+++ b/db/migrate/20200510182824_add_text_limit_to_webauthn_registrations_credential_xid.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToWebauthnRegistrationsCredentialXid < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :webauthn_registrations, :credential_xid, 255
+ end
+
+ def down
+ remove_text_limit :webauthn_registrations, :credential_xid
+ end
+end
diff --git a/db/migrate/20200510183128_add_foreign_key_from_webauthn_registrations_to_users.rb b/db/migrate/20200510183128_add_foreign_key_from_webauthn_registrations_to_users.rb
new file mode 100644
index 00000000000..f71a5276dee
--- /dev/null
+++ b/db/migrate/20200510183128_add_foreign_key_from_webauthn_registrations_to_users.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddForeignKeyFromWebauthnRegistrationsToUsers < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ # disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_foreign_key :webauthn_registrations, :users, column: :user_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :webauthn_registrations, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20200521225327_create_alert_management_alert_assignees.rb b/db/migrate/20200521225327_create_alert_management_alert_assignees.rb
index 095b2fdfeee..99de2646b3d 100644
--- a/db/migrate/20200521225327_create_alert_management_alert_assignees.rb
+++ b/db/migrate/20200521225327_create_alert_management_alert_assignees.rb
@@ -17,8 +17,6 @@ class CreateAlertManagementAlertAssignees < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :alert_management_alert_assignees
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200522205606_create_group_deploy_keys_group.rb b/db/migrate/20200522205606_create_group_deploy_keys_group.rb
new file mode 100644
index 00000000000..85dbc14b0f5
--- /dev/null
+++ b/db/migrate/20200522205606_create_group_deploy_keys_group.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class CreateGroupDeployKeysGroup < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ create_table :group_deploy_keys_groups do |t|
+ t.timestamps_with_timezone
+
+ t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
+ t.references :group_deploy_key, null: false, foreign_key: { on_delete: :cascade }
+
+ t.index [:group_id, :group_deploy_key_id], unique: true, name: 'index_group_deploy_keys_group_on_group_deploy_key_and_group_ids'
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :group_deploy_keys_groups
+ end
+ end
+end
diff --git a/db/migrate/20200524104346_add_source_to_resource_state_event.rb b/db/migrate/20200524104346_add_source_to_resource_state_event.rb
new file mode 100644
index 00000000000..a1d1575bb02
--- /dev/null
+++ b/db/migrate/20200524104346_add_source_to_resource_state_event.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSourceToResourceStateEvent < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:resource_state_events, :source_commit)
+ add_column :resource_state_events, :source_commit, :text
+ end
+
+ add_text_limit :resource_state_events, :source_commit, 40
+ end
+
+ def down
+ remove_column :resource_state_events, :source_commit
+ end
+end
diff --git a/db/migrate/20200526193555_add_squash_option_to_project.rb b/db/migrate/20200526193555_add_squash_option_to_project.rb
new file mode 100644
index 00000000000..6dd4e1c7c8e
--- /dev/null
+++ b/db/migrate/20200526193555_add_squash_option_to_project.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSquashOptionToProject < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :project_settings, :squash_option, :integer, default: 3, limit: 2
+ end
+end
diff --git a/db/migrate/20200526231421_update_index_approval_rule_name_for_code_owners_rule_type.rb b/db/migrate/20200526231421_update_index_approval_rule_name_for_code_owners_rule_type.rb
new file mode 100644
index 00000000000..2483ff7f8fa
--- /dev/null
+++ b/db/migrate/20200526231421_update_index_approval_rule_name_for_code_owners_rule_type.rb
@@ -0,0 +1,116 @@
+# frozen_string_literal: true
+
+class UpdateIndexApprovalRuleNameForCodeOwnersRuleType < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ LEGACY_INDEX_NAME_RULE_TYPE = "index_approval_rule_name_for_code_owners_rule_type"
+ LEGACY_INDEX_NAME_CODE_OWNERS = "approval_rule_name_index_for_code_owners"
+
+ SECTIONAL_INDEX_NAME = "index_approval_rule_name_for_sectional_code_owners_rule_type"
+
+ CODE_OWNER_RULE_TYPE = 2
+
+ def up
+ unless index_exists_by_name?(:approval_merge_request_rules, SECTIONAL_INDEX_NAME)
+ # Ensure only 1 code_owner rule with the same name and section per merge_request
+ #
+ add_concurrent_index(
+ :approval_merge_request_rules,
+ [:merge_request_id, :name, :section],
+ unique: true,
+ where: "rule_type = #{CODE_OWNER_RULE_TYPE}",
+ name: SECTIONAL_INDEX_NAME
+ )
+ end
+
+ remove_concurrent_index_by_name :approval_merge_request_rules, LEGACY_INDEX_NAME_RULE_TYPE
+ remove_concurrent_index_by_name :approval_merge_request_rules, LEGACY_INDEX_NAME_CODE_OWNERS
+
+ add_concurrent_index(
+ :approval_merge_request_rules,
+ [:merge_request_id, :name],
+ unique: true,
+ where: "rule_type = #{CODE_OWNER_RULE_TYPE} AND section IS NULL",
+ name: LEGACY_INDEX_NAME_RULE_TYPE
+ )
+
+ add_concurrent_index(
+ :approval_merge_request_rules,
+ [:merge_request_id, :code_owner, :name],
+ unique: true,
+ where: "code_owner = true AND section IS NULL",
+ name: LEGACY_INDEX_NAME_CODE_OWNERS
+ )
+ end
+
+ def down
+ # In a rollback situation, we can't guarantee that there will not be
+ # records that were allowed under the more specific SECTIONAL_INDEX_NAME
+ # index but would cause uniqueness violations under both the
+ # LEGACY_INDEX_NAME_RULE_TYPE and LEGACY_INDEX_NAME_CODE_OWNERS indices.
+ # Therefore, we need to first find all the MergeRequests with
+ # ApprovalMergeRequestRules that would violate these "new" indices and
+ # delete those approval rules, then create the new index, then finally
+ # recreate the approval rules for those merge requests.
+ #
+
+ # First, find all MergeRequests with ApprovalMergeRequestRules that will
+ # violate the new index.
+ #
+ if Gitlab.ee?
+ merge_request_ids = ApprovalMergeRequestRule
+ .select(:merge_request_id)
+ .where(rule_type: CODE_OWNER_RULE_TYPE)
+ .group(:merge_request_id, :rule_type, :name)
+ .includes(:merge_request)
+ .having("count(*) > 1")
+ .collect(&:merge_request_id)
+
+ # Delete ALL their code_owner approval rules
+ #
+ merge_request_ids.each_slice(10) do |ids|
+ ApprovalMergeRequestRule.where(merge_request_id: ids).code_owner.delete_all
+ end
+ end
+
+ # Remove legacy partial indices that only apply to `section IS NULL` records
+ #
+ remove_concurrent_index_by_name :approval_merge_request_rules, LEGACY_INDEX_NAME_RULE_TYPE
+ remove_concurrent_index_by_name :approval_merge_request_rules, LEGACY_INDEX_NAME_CODE_OWNERS
+
+ # Reconstruct original "legacy" indices
+ #
+ add_concurrent_index(
+ :approval_merge_request_rules,
+ [:merge_request_id, :name],
+ unique: true,
+ where: "rule_type = #{CODE_OWNER_RULE_TYPE}",
+ name: LEGACY_INDEX_NAME_RULE_TYPE
+ )
+
+ add_concurrent_index(
+ :approval_merge_request_rules,
+ [:merge_request_id, :code_owner, :name],
+ unique: true,
+ where: "code_owner = true",
+ name: LEGACY_INDEX_NAME_CODE_OWNERS
+ )
+
+ # MergeRequest::SyncCodeOwnerApprovalRules recreates the code_owner rules
+ # from scratch, adding them to the index. Duplicates will be rejected.
+ #
+ if Gitlab.ee?
+ merge_request_ids.each_slice(10) do |ids|
+ MergeRequest.where(id: ids).each do |merge_request|
+ MergeRequests::SyncCodeOwnerApprovalRules.new(merge_request).execute
+ end
+ end
+ end
+
+ remove_concurrent_index_by_name :approval_merge_request_rules, SECTIONAL_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20200527211605_add_locked_to_ci_pipelines.rb b/db/migrate/20200527211605_add_locked_to_ci_pipelines.rb
new file mode 100644
index 00000000000..3587e6c4a08
--- /dev/null
+++ b/db/migrate/20200527211605_add_locked_to_ci_pipelines.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddLockedToCiPipelines < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :ci_pipelines, :locked, :integer, limit: 2, null: false, default: 0
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :ci_pipelines, :locked
+ end
+ end
+end
diff --git a/db/migrate/20200604001128_add_secrets_to_ci_builds_metadata.rb b/db/migrate/20200604001128_add_secrets_to_ci_builds_metadata.rb
new file mode 100644
index 00000000000..9a67993cf5c
--- /dev/null
+++ b/db/migrate/20200604001128_add_secrets_to_ci_builds_metadata.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddSecretsToCiBuildsMetadata < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :ci_builds_metadata, :secrets, :jsonb, default: {}, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :ci_builds_metadata, :secrets
+ end
+ end
+end
diff --git a/db/migrate/20200604143628_create_project_security_settings.rb b/db/migrate/20200604143628_create_project_security_settings.rb
index b1a08cf8781..f972cb509a7 100644
--- a/db/migrate/20200604143628_create_project_security_settings.rb
+++ b/db/migrate/20200604143628_create_project_security_settings.rb
@@ -21,9 +21,7 @@ class CreateProjectSecuritySettings < ActiveRecord::Migration[6.0]
def down
with_lock_retries do
- # rubocop:disable Migration/DropTable
drop_table :project_security_settings
- # rubocop:enable Migration/DropTable
end
end
end
diff --git a/db/migrate/20200604145731_create_board_user_preferences.rb b/db/migrate/20200604145731_create_board_user_preferences.rb
index 36e5014fdbe..e83f467d690 100644
--- a/db/migrate/20200604145731_create_board_user_preferences.rb
+++ b/db/migrate/20200604145731_create_board_user_preferences.rb
@@ -15,8 +15,6 @@ class CreateBoardUserPreferences < ActiveRecord::Migration[6.0]
end
def down
- # rubocop:disable Migration/DropTable
drop_table :board_user_preferences
- # rubocop:enable Migration/DropTable
end
end
diff --git a/db/migrate/20200605160806_add_index_on_repository_size_and_project_id_to_project_statistics.rb b/db/migrate/20200605160806_add_index_on_repository_size_and_project_id_to_project_statistics.rb
new file mode 100644
index 00000000000..2e7b75bcd17
--- /dev/null
+++ b/db/migrate/20200605160806_add_index_on_repository_size_and_project_id_to_project_statistics.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnRepositorySizeAndProjectIdToProjectStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :project_statistics, [:repository_size, :project_id]
+ end
+
+ def down
+ remove_concurrent_index :project_statistics, [:repository_size, :project_id]
+ end
+end
diff --git a/db/migrate/20200605160836_add_index_on_storage_size_and_project_id_to_project_statistics.rb b/db/migrate/20200605160836_add_index_on_storage_size_and_project_id_to_project_statistics.rb
new file mode 100644
index 00000000000..22f9dab634b
--- /dev/null
+++ b/db/migrate/20200605160836_add_index_on_storage_size_and_project_id_to_project_statistics.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnStorageSizeAndProjectIdToProjectStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :project_statistics, [:storage_size, :project_id]
+ end
+
+ def down
+ remove_concurrent_index :project_statistics, [:storage_size, :project_id]
+ end
+end
diff --git a/db/migrate/20200605160851_add_index_on_wiki_size_and_project_id_to_project_statistics.rb b/db/migrate/20200605160851_add_index_on_wiki_size_and_project_id_to_project_statistics.rb
new file mode 100644
index 00000000000..d32994afbfc
--- /dev/null
+++ b/db/migrate/20200605160851_add_index_on_wiki_size_and_project_id_to_project_statistics.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnWikiSizeAndProjectIdToProjectStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :project_statistics, [:wiki_size, :project_id]
+ end
+
+ def down
+ remove_concurrent_index :project_statistics, [:wiki_size, :project_id]
+ end
+end
diff --git a/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb b/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb
new file mode 100644
index 00000000000..d7f282b69f8
--- /dev/null
+++ b/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddTraversalIdsToNamespaces < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :namespaces, :traversal_ids, :integer, array: true, default: [], null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespaces, :traversal_ids
+ end
+ end
+end
diff --git a/db/migrate/20200610130002_create_vulnerability_statistics.rb b/db/migrate/20200610130002_create_vulnerability_statistics.rb
new file mode 100644
index 00000000000..77fd116230e
--- /dev/null
+++ b/db/migrate/20200610130002_create_vulnerability_statistics.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ create_table :vulnerability_statistics do |t|
+ t.timestamps_with_timezone null: false
+ t.references :project, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :total, default: 0, null: false
+ t.integer :critical, default: 0, null: false
+ t.integer :high, default: 0, null: false
+ t.integer :medium, default: 0, null: false
+ t.integer :low, default: 0, null: false
+ t.integer :unknown, default: 0, null: false
+ t.integer :info, default: 0, null: false
+ t.integer :letter_grade, limit: 1, index: true, null: false
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :vulnerability_statistics
+ end
+ end
+end
diff --git a/db/migrate/20200613104045_add_compliance_frameworks_to_application_settings.rb b/db/migrate/20200613104045_add_compliance_frameworks_to_application_settings.rb
new file mode 100644
index 00000000000..be6f14692e7
--- /dev/null
+++ b/db/migrate/20200613104045_add_compliance_frameworks_to_application_settings.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddComplianceFrameworksToApplicationSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :application_settings, :compliance_frameworks, :integer, limit: 2, array: true, default: [], null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :application_settings, :compliance_frameworks
+ end
+ end
+end
diff --git a/db/migrate/20200615141554_add_closed_by_fields_to_resource_state_events.rb b/db/migrate/20200615141554_add_closed_by_fields_to_resource_state_events.rb
new file mode 100644
index 00000000000..ba11e64e667
--- /dev/null
+++ b/db/migrate/20200615141554_add_closed_by_fields_to_resource_state_events.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddClosedByFieldsToResourceStateEvents < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ add_column :resource_state_events, :close_after_error_tracking_resolve, :boolean, default: false, null: false
+ add_column :resource_state_events, :close_auto_resolve_prometheus_alert, :boolean, default: false, null: false
+ end
+
+ def down
+ remove_column :resource_state_events, :close_auto_resolve_prometheus_alert, :boolean
+ remove_column :resource_state_events, :close_after_error_tracking_resolve, :boolean
+ end
+end
diff --git a/db/migrate/20200615193524_add_verify_known_sign_in_to_application_settings.rb b/db/migrate/20200615193524_add_verify_known_sign_in_to_application_settings.rb
new file mode 100644
index 00000000000..c50a17968a9
--- /dev/null
+++ b/db/migrate/20200615193524_add_verify_known_sign_in_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddVerifyKnownSignInToApplicationSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :notify_on_unknown_sign_in, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20200615234047_create_clusters_applications_cilium.rb b/db/migrate/20200615234047_create_clusters_applications_cilium.rb
new file mode 100644
index 00000000000..9f77ee71164
--- /dev/null
+++ b/db/migrate/20200615234047_create_clusters_applications_cilium.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateClustersApplicationsCilium < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :clusters_applications_cilium do |t|
+ t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.integer :status, null: false
+ t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
+ end
+ end
+end
diff --git a/db/migrate/20200616124338_add_plan_limits_for_max_size_per_artifact_type.rb b/db/migrate/20200616124338_add_plan_limits_for_max_size_per_artifact_type.rb
new file mode 100644
index 00000000000..28fadb495dd
--- /dev/null
+++ b/db/migrate/20200616124338_add_plan_limits_for_max_size_per_artifact_type.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class AddPlanLimitsForMaxSizePerArtifactType < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ # We need to set the 20mb default for lsif for backward compatibility
+ # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34767#note_371619075
+ add_column :plan_limits, "ci_max_artifact_size_lsif", :integer, default: 20, null: false
+
+ artifact_types.each do |type|
+ add_column :plan_limits, "ci_max_artifact_size_#{type}", :integer, default: 0, null: false
+ end
+ end
+
+ private
+
+ def artifact_types
+ # The list of artifact types (except lsif) from Ci::JobArtifact file_type enum as of this writing.
+ # Intentionally duplicated so that the migration won't change behavior
+ # if ever we remove or add more to the list later on.
+ %w[
+ archive
+ metadata
+ trace
+ junit
+ sast
+ dependency_scanning
+ container_scanning
+ dast
+ codequality
+ license_management
+ license_scanning
+ performance
+ metrics
+ metrics_referee
+ network_referee
+ dotenv
+ cobertura
+ terraform
+ accessibility
+ cluster_applications
+ secret_detection
+ requirements
+ coverage_fuzzing
+ ]
+ end
+end
diff --git a/db/migrate/20200616145031_add_author_id_index_to_audit_events.rb b/db/migrate/20200616145031_add_author_id_index_to_audit_events.rb
new file mode 100644
index 00000000000..cb06fbe2b11
--- /dev/null
+++ b/db/migrate/20200616145031_add_author_id_index_to_audit_events.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddAuthorIdIndexToAuditEvents < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_audit_events_on_entity_id_entity_type_id_desc_author_id'
+ OLD_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type_and_id_desc'
+
+ def up
+ add_concurrent_index(:audit_events, [:entity_id, :entity_type, :id, :author_id], order: { id: :desc }, name: INDEX_NAME)
+ remove_concurrent_index_by_name(:audit_events, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:audit_events, [:entity_id, :entity_type, :id], order: { id: :desc }, name: OLD_INDEX_NAME)
+ remove_concurrent_index_by_name(:audit_events, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200617000757_clean_up_file_store_lfs_objects.rb b/db/migrate/20200617000757_clean_up_file_store_lfs_objects.rb
new file mode 100644
index 00000000000..a1a86355d02
--- /dev/null
+++ b/db/migrate/20200617000757_clean_up_file_store_lfs_objects.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CleanUpFileStoreLfsObjects < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # rubocop:disable Migration/UpdateColumnInBatches
+ update_column_in_batches(:lfs_objects, :file_store, 1) do |table, query|
+ query.where(table[:file_store].eq(nil))
+ end
+ # rubocop:enable Migration/UpdateColumnInBatches
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200617001001_clean_up_store_uploads.rb b/db/migrate/20200617001001_clean_up_store_uploads.rb
new file mode 100644
index 00000000000..970d0485b0d
--- /dev/null
+++ b/db/migrate/20200617001001_clean_up_store_uploads.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CleanUpStoreUploads < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # rubocop:disable Migration/UpdateColumnInBatches
+ update_column_in_batches(:uploads, :store, 1) do |table, query|
+ query.where(table[:store].eq(nil))
+ end
+ # rubocop:enable Migration/UpdateColumnInBatches
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200617001118_clean_up_file_store_ci_job_artifacts.rb b/db/migrate/20200617001118_clean_up_file_store_ci_job_artifacts.rb
new file mode 100644
index 00000000000..e30f7e342e5
--- /dev/null
+++ b/db/migrate/20200617001118_clean_up_file_store_ci_job_artifacts.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class CleanUpFileStoreCiJobArtifacts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # rubocop:disable Migration/UpdateColumnInBatches
+ # rubocop:disable Migration/UpdateLargeTable
+ update_column_in_batches(:ci_job_artifacts, :file_store, 1) do |table, query|
+ query.where(table[:file_store].eq(nil))
+ end
+ # rubocop:enable Migration/UpdateColumnInBatches
+ # rubocop:enable Migration/UpdateLargeTable
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200617150041_create_namespace_limits.rb b/db/migrate/20200617150041_create_namespace_limits.rb
new file mode 100644
index 00000000000..59a014ff7ca
--- /dev/null
+++ b/db/migrate/20200617150041_create_namespace_limits.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateNamespaceLimits < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ create_table :namespace_limits, id: false do |t|
+ t.bigint :additional_purchased_storage_size, default: 0, null: false
+ t.date :additional_purchased_storage_ends_on, null: true
+
+ t.references :namespace, primary_key: true, default: nil, type: :integer, index: false, foreign_key: { on_delete: :cascade }
+ end
+ end
+ end
+
+ def down
+ drop_table :namespace_limits
+ end
+end
diff --git a/db/migrate/20200617205000_add_deploy_key_id_to_push_access_levels.rb b/db/migrate/20200617205000_add_deploy_key_id_to_push_access_levels.rb
new file mode 100644
index 00000000000..11b92c2a321
--- /dev/null
+++ b/db/migrate/20200617205000_add_deploy_key_id_to_push_access_levels.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddDeployKeyIdToPushAccessLevels < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:protected_branch_push_access_levels, :deploy_key_id)
+ add_column :protected_branch_push_access_levels, :deploy_key_id, :integer
+ end
+
+ add_concurrent_foreign_key :protected_branch_push_access_levels, :keys, column: :deploy_key_id, on_delete: :cascade
+ add_concurrent_index :protected_branch_push_access_levels, :deploy_key_id, name: 'index_deploy_key_id_on_protected_branch_push_access_levels'
+ end
+
+ def down
+ remove_column :protected_branch_push_access_levels, :deploy_key_id
+ end
+end
diff --git a/db/migrate/20200618105638_add_index_on_id_and_created_at_to_snippets.rb b/db/migrate/20200618105638_add_index_on_id_and_created_at_to_snippets.rb
new file mode 100644
index 00000000000..d9ef3b18e9b
--- /dev/null
+++ b/db/migrate/20200618105638_add_index_on_id_and_created_at_to_snippets.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnIdAndCreatedAtToSnippets < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :snippets, [:id, :created_at]
+ end
+
+ def down
+ remove_concurrent_index :snippets, [:id, :created_at]
+ end
+end
diff --git a/db/migrate/20200618134223_restore_previous_schema_without_lock_version_null_constraint.rb b/db/migrate/20200618134223_restore_previous_schema_without_lock_version_null_constraint.rb
new file mode 100644
index 00000000000..85e98d05d02
--- /dev/null
+++ b/db/migrate/20200618134223_restore_previous_schema_without_lock_version_null_constraint.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class RestorePreviousSchemaWithoutLockVersionNullConstraint < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ TABLES = %i(epics merge_requests issues ci_stages ci_builds ci_pipelines).freeze
+
+ disable_ddl_transaction!
+
+ def up
+ TABLES.each do |table|
+ remove_not_null_constraint table, :lock_version
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200618134723_restore_previous_schema_with_lock_version_indices.rb b/db/migrate/20200618134723_restore_previous_schema_with_lock_version_indices.rb
new file mode 100644
index 00000000000..64fdb373387
--- /dev/null
+++ b/db/migrate/20200618134723_restore_previous_schema_with_lock_version_indices.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class RestorePreviousSchemaWithLockVersionIndices < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :issues, :lock_version, where: "lock_version IS NULL"
+ add_concurrent_index :merge_requests, :lock_version, where: "lock_version IS NULL"
+ add_concurrent_index :epics, :lock_version, where: "lock_version IS NULL"
+ add_concurrent_index :ci_stages, :id, where: "lock_version IS NULL", name: "tmp_index_ci_stages_lock_version"
+ add_concurrent_index :ci_builds, :id, where: "lock_version IS NULL", name: "tmp_index_ci_builds_lock_version"
+ add_concurrent_index :ci_pipelines, :id, where: "lock_version IS NULL", name: "tmp_index_ci_pipelines_lock_version"
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200619000316_add_has_confluence_to_project_settings.rb b/db/migrate/20200619000316_add_has_confluence_to_project_settings.rb
new file mode 100644
index 00000000000..0f33e0bc47a
--- /dev/null
+++ b/db/migrate/20200619000316_add_has_confluence_to_project_settings.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddHasConfluenceToProjectSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :project_settings, :has_confluence, :boolean, default: false, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :project_settings, :has_confluence
+ end
+ end
+end
diff --git a/db/migrate/20200619154527_add_project_key_to_jira_tracker_data.rb b/db/migrate/20200619154527_add_project_key_to_jira_tracker_data.rb
new file mode 100644
index 00000000000..574eb99a6cc
--- /dev/null
+++ b/db/migrate/20200619154527_add_project_key_to_jira_tracker_data.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddProjectKeyToJiraTrackerData < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20200619154528_add_text_limit_to_jira_tracker_data_project_key
+ def change
+ add_column :jira_tracker_data, :project_key, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20200619154528_add_text_limit_to_jira_tracker_data_project_key.rb b/db/migrate/20200619154528_add_text_limit_to_jira_tracker_data_project_key.rb
new file mode 100644
index 00000000000..6cf8a787381
--- /dev/null
+++ b/db/migrate/20200619154528_add_text_limit_to_jira_tracker_data_project_key.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddTextLimitToJiraTrackerDataProjectKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :jira_tracker_data, :project_key, 255
+ end
+
+ def down
+ remove_text_limit :jira_tracker_data, :project_key
+ end
+end
diff --git a/db/migrate/20200622040750_add_prometheus_alert_id_to_alert_management_alerts.rb b/db/migrate/20200622040750_add_prometheus_alert_id_to_alert_management_alerts.rb
new file mode 100644
index 00000000000..e7669db0a28
--- /dev/null
+++ b/db/migrate/20200622040750_add_prometheus_alert_id_to_alert_management_alerts.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddPrometheusAlertIdToAlertManagementAlerts < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ add_column :alert_management_alerts, :prometheus_alert_id, :integer
+
+ add_column :alert_management_alerts, :environment_id, :integer
+ end
+
+ def down
+ remove_column :alert_management_alerts, :prometheus_alert_id
+ remove_column :alert_management_alerts, :environment_id
+ end
+end
diff --git a/db/migrate/20200622070606_add_vendor_to_vulnerability_scanners.rb b/db/migrate/20200622070606_add_vendor_to_vulnerability_scanners.rb
new file mode 100644
index 00000000000..2c9c0a9110d
--- /dev/null
+++ b/db/migrate/20200622070606_add_vendor_to_vulnerability_scanners.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddVendorToVulnerabilityScanners < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ DEFAULT_SCANNER_VENDOR = 'GitLab'
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20200622070620_add_limit_to_vulnerability_scanners_vendor
+ def up
+ with_lock_retries do
+ add_column :vulnerability_scanners, :vendor, :text, default: DEFAULT_SCANNER_VENDOR, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :vulnerability_scanners, :vendor
+ end
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20200622070620_add_limit_to_vulnerability_scanners_vendor.rb b/db/migrate/20200622070620_add_limit_to_vulnerability_scanners_vendor.rb
new file mode 100644
index 00000000000..efcbbde3e29
--- /dev/null
+++ b/db/migrate/20200622070620_add_limit_to_vulnerability_scanners_vendor.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddLimitToVulnerabilityScannersVendor < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :vulnerability_scanners, :vendor, 255, validate: false
+ end
+
+ def down
+ remove_text_limit :vulnerability_scanners, :vendor
+ end
+end
diff --git a/db/migrate/20200622095419_add_snippets_size_to_project_statistics.rb b/db/migrate/20200622095419_add_snippets_size_to_project_statistics.rb
new file mode 100644
index 00000000000..9fe470478b8
--- /dev/null
+++ b/db/migrate/20200622095419_add_snippets_size_to_project_statistics.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSnippetsSizeToProjectStatistics < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :project_statistics, :snippets_size, :bigint
+ end
+end
diff --git a/db/migrate/20200622103836_create_snippet_statistics.rb b/db/migrate/20200622103836_create_snippet_statistics.rb
new file mode 100644
index 00000000000..691a9acdc04
--- /dev/null
+++ b/db/migrate/20200622103836_create_snippet_statistics.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateSnippetStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ create_table :snippet_statistics, id: false do |t|
+ t.references :snippet, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade }
+ t.bigint :repository_size, default: 0, null: false
+ t.bigint :file_count, default: 0, null: false
+ t.bigint :commit_count, default: 0, null: false
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :snippet_statistics
+ end
+ end
+end
diff --git a/db/migrate/20200622104923_create_ci_pipeline_messages_table.rb b/db/migrate/20200622104923_create_ci_pipeline_messages_table.rb
new file mode 100644
index 00000000000..40d63b1189e
--- /dev/null
+++ b/db/migrate/20200622104923_create_ci_pipeline_messages_table.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class CreateCiPipelineMessagesTable < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ ERROR_SEVERITY = 0
+ MAX_CONTENT_LENGTH = 10_000
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :ci_pipeline_messages do |t|
+ t.integer :severity, null: false, default: ERROR_SEVERITY, limit: 2
+ t.references :pipeline, index: true, null: false, foreign_key: { to_table: :ci_pipelines, on_delete: :cascade }, type: :integer
+ t.text :content, null: false
+ end
+ end
+
+ add_text_limit :ci_pipeline_messages, :content, MAX_CONTENT_LENGTH
+ end
+
+ def down
+ drop_table :ci_pipeline_messages
+ end
+end
diff --git a/db/migrate/20200622235737_remove_index_ci_job_artifacts_file_store_is_null.rb b/db/migrate/20200622235737_remove_index_ci_job_artifacts_file_store_is_null.rb
new file mode 100644
index 00000000000..e293bcfa1ce
--- /dev/null
+++ b/db/migrate/20200622235737_remove_index_ci_job_artifacts_file_store_is_null.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveIndexCiJobArtifactsFileStoreIsNull < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_ci_job_artifacts_file_store_is_null'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name(:ci_job_artifacts, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:ci_job_artifacts, :id, where: "file_store IS NULL", name: INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200623000148_remove_index_lfs_objects_file_store_is_null.rb b/db/migrate/20200623000148_remove_index_lfs_objects_file_store_is_null.rb
new file mode 100644
index 00000000000..76faa5c4cd2
--- /dev/null
+++ b/db/migrate/20200623000148_remove_index_lfs_objects_file_store_is_null.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveIndexLfsObjectsFileStoreIsNull < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_lfs_objects_file_store_is_null'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name(:lfs_objects, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:lfs_objects, :id, where: "file_store IS NULL", name: INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200623000320_remove_index_uploads_store_is_null.rb b/db/migrate/20200623000320_remove_index_uploads_store_is_null.rb
new file mode 100644
index 00000000000..ad84cd5a649
--- /dev/null
+++ b/db/migrate/20200623000320_remove_index_uploads_store_is_null.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveIndexUploadsStoreIsNull < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_uploads_store_is_null'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name(:uploads, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:uploads, :id, where: "store IS NULL", name: INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200623073431_add_source_merge_request_id_to_resource_state_events.rb b/db/migrate/20200623073431_add_source_merge_request_id_to_resource_state_events.rb
new file mode 100644
index 00000000000..8970797d3c0
--- /dev/null
+++ b/db/migrate/20200623073431_add_source_merge_request_id_to_resource_state_events.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class AddSourceMergeRequestIdToResourceStateEvents < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'index_resource_state_events_on_source_merge_request_id'
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:resource_state_events, :source_merge_request_id)
+ add_column :resource_state_events, :source_merge_request_id, :bigint
+ end
+
+ unless index_exists?(:resource_state_events, :source_merge_request_id, name: INDEX_NAME)
+ add_index :resource_state_events, :source_merge_request_id, name: INDEX_NAME # rubocop: disable Migration/AddIndex
+ end
+
+ unless foreign_key_exists?(:resource_state_events, :merge_requests, column: :source_merge_request_id)
+ with_lock_retries do
+ add_foreign_key :resource_state_events, :merge_requests, column: :source_merge_request_id, on_delete: :nullify # rubocop:disable Migration/AddConcurrentForeignKey
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :resource_state_events, :source_merge_request_id
+ end
+ end
+end
diff --git a/db/migrate/20200623090030_add_author_name_to_audit_event.rb b/db/migrate/20200623090030_add_author_name_to_audit_event.rb
new file mode 100644
index 00000000000..8b45503189a
--- /dev/null
+++ b/db/migrate/20200623090030_add_author_name_to_audit_event.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddAuthorNameToAuditEvent < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:audit_events, :author_name)
+ with_lock_retries do
+ add_column :audit_events, :author_name, :text
+ end
+ end
+
+ add_text_limit :audit_events, :author_name, 255
+ end
+
+ def down
+ remove_column :audit_events, :author_name
+ end
+end
diff --git a/db/migrate/20200623121135_create_dynamic_partitions_schema.rb b/db/migrate/20200623121135_create_dynamic_partitions_schema.rb
new file mode 100644
index 00000000000..931a55ebcf4
--- /dev/null
+++ b/db/migrate/20200623121135_create_dynamic_partitions_schema.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateDynamicPartitionsSchema < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::SchemaHelpers
+
+ DOWNTIME = false
+
+ def up
+ execute 'CREATE SCHEMA gitlab_partitions_dynamic'
+
+ create_comment(:schema, :gitlab_partitions_dynamic, <<~EOS.strip)
+ Schema to hold partitions managed dynamically from the application, e.g. for time space partitioning.
+ EOS
+ end
+
+ def down
+ execute 'DROP SCHEMA gitlab_partitions_dynamic'
+ end
+end
diff --git a/db/migrate/20200623141217_add_view_diffs_file_by_file_to_user_preferences.rb b/db/migrate/20200623141217_add_view_diffs_file_by_file_to_user_preferences.rb
new file mode 100644
index 00000000000..9ea38bd4ab4
--- /dev/null
+++ b/db/migrate/20200623141217_add_view_diffs_file_by_file_to_user_preferences.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddViewDiffsFileByFileToUserPreferences < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :user_preferences, :view_diffs_file_by_file, :boolean, default: false, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :user_preferences, :view_diffs_file_by_file, :boolean
+ end
+ end
+end
diff --git a/db/migrate/20200623141544_create_elastic_reindexing_task.rb b/db/migrate/20200623141544_create_elastic_reindexing_task.rb
new file mode 100644
index 00000000000..7089df4f1ea
--- /dev/null
+++ b/db/migrate/20200623141544_create_elastic_reindexing_task.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class CreateElasticReindexingTask < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ create_table :elastic_reindexing_tasks do |t|
+ t.timestamps_with_timezone null: false
+ t.integer :documents_count
+ t.integer :state, null: false, default: 0, limit: 2, index: true
+ t.boolean :in_progress, null: false, default: true
+ t.text :index_name_from
+ t.text :index_name_to
+ t.text :elastic_task
+ t.text :error_message
+ end
+
+ add_text_limit :elastic_reindexing_tasks, :index_name_from, 255
+ add_text_limit :elastic_reindexing_tasks, :index_name_to, 255
+ add_text_limit :elastic_reindexing_tasks, :elastic_task, 255
+ add_text_limit :elastic_reindexing_tasks, :error_message, 255
+
+ add_index :elastic_reindexing_tasks, :in_progress, unique: true, where: 'in_progress'
+ end
+
+ def down
+ drop_table :elastic_reindexing_tasks
+ end
+end
diff --git a/db/migrate/20200623170000_create_static_partitions_schema.rb b/db/migrate/20200623170000_create_static_partitions_schema.rb
new file mode 100644
index 00000000000..d8878d2fe33
--- /dev/null
+++ b/db/migrate/20200623170000_create_static_partitions_schema.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateStaticPartitionsSchema < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::SchemaHelpers
+
+ DOWNTIME = false
+
+ def up
+ execute 'CREATE SCHEMA gitlab_partitions_static'
+
+ create_comment(:schema, :gitlab_partitions_static, <<~EOS.strip)
+ Schema to hold static partitions, e.g. for hash partitioning
+ EOS
+ end
+
+ def down
+ execute 'DROP SCHEMA gitlab_partitions_static'
+ end
+end
diff --git a/db/migrate/20200623185440_add_product_analytics_table.rb b/db/migrate/20200623185440_add_product_analytics_table.rb
new file mode 100644
index 00000000000..0a0d438bfb9
--- /dev/null
+++ b/db/migrate/20200623185440_add_product_analytics_table.rb
@@ -0,0 +1,202 @@
+# frozen_string_literal: true
+
+class AddProductAnalyticsTable < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ # Table is based on https://github.com/snowplow/snowplow/blob/master/4-storage/postgres-storage/sql/atomic-def.sql 6e07b1c, with the following differences:
+ # * app_id varchar -> project_id integer (+ FK)
+ # * Add `id bigserial`
+ # * Hash partitioning based on `project_id`
+ # * Timestamp columns: Change type to timestamp with time zone
+ #
+ # This table is part of the "product analytics experiment" and as such marked "experimental". The goal here is to
+ # explore the product analytics as a MVP feature more. We are explicitly not spending time on relational modeling
+ # here.
+ #
+ # We expect significant changes to the database part of this once the feature has been validated.
+ # Therefore, we expect to drop the table when feature validation is complete. All data will be lost.
+ def up
+ with_lock_retries do
+ execute <<~SQL
+ CREATE TABLE "product_analytics_events_experimental" (
+ id bigserial NOT NULL,
+ -- App
+ "project_id" integer NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
+ "platform" varchar(255),
+ -- Date/time
+ "etl_tstamp" timestamp with time zone,
+ "collector_tstamp" timestamp with time zone NOT NULL,
+ "dvce_created_tstamp" timestamp with time zone,
+ -- Date/time
+ "event" varchar(128),
+ "event_id" char(36) NOT NULL,
+ "txn_id" integer,
+ -- Versioning
+ "name_tracker" varchar(128),
+ "v_tracker" varchar(100),
+ "v_collector" varchar(100) NOT NULL,
+ "v_etl" varchar(100) NOT NULL,
+ -- User and visit
+ "user_id" varchar(255),
+ "user_ipaddress" varchar(45),
+ "user_fingerprint" varchar(50),
+ "domain_userid" varchar(36),
+ "domain_sessionidx" smallint,
+ "network_userid" varchar(38),
+ -- Location
+ "geo_country" char(2),
+ "geo_region" char(3),
+ "geo_city" varchar(75),
+ "geo_zipcode" varchar(15),
+ "geo_latitude" double precision,
+ "geo_longitude" double precision,
+ "geo_region_name" varchar(100),
+ -- IP lookups
+ "ip_isp" varchar(100),
+ "ip_organization" varchar(100),
+ "ip_domain" varchar(100),
+ "ip_netspeed" varchar(100),
+ -- Page
+ "page_url" text,
+ "page_title" varchar(2000),
+ "page_referrer" text,
+ -- Page URL components
+ "page_urlscheme" varchar(16),
+ "page_urlhost" varchar(255),
+ "page_urlport" integer,
+ "page_urlpath" varchar(3000),
+ "page_urlquery" varchar(6000),
+ "page_urlfragment" varchar(3000),
+ -- Referrer URL components
+ "refr_urlscheme" varchar(16),
+ "refr_urlhost" varchar(255),
+ "refr_urlport" integer,
+ "refr_urlpath" varchar(6000),
+ "refr_urlquery" varchar(6000),
+ "refr_urlfragment" varchar(3000),
+ -- Referrer details
+ "refr_medium" varchar(25),
+ "refr_source" varchar(50),
+ "refr_term" varchar(255),
+ -- Marketing
+ "mkt_medium" varchar(255),
+ "mkt_source" varchar(255),
+ "mkt_term" varchar(255),
+ "mkt_content" varchar(500),
+ "mkt_campaign" varchar(255),
+ -- Custom structured event
+ "se_category" varchar(1000),
+ "se_action" varchar(1000),
+ "se_label" varchar(1000),
+ "se_property" varchar(1000),
+ "se_value" double precision,
+ -- Ecommerce
+ "tr_orderid" varchar(255),
+ "tr_affiliation" varchar(255),
+ "tr_total" decimal(18,2),
+ "tr_tax" decimal(18,2),
+ "tr_shipping" decimal(18,2),
+ "tr_city" varchar(255),
+ "tr_state" varchar(255),
+ "tr_country" varchar(255),
+ "ti_orderid" varchar(255),
+ "ti_sku" varchar(255),
+ "ti_name" varchar(255),
+ "ti_category" varchar(255),
+ "ti_price" decimal(18,2),
+ "ti_quantity" integer,
+ -- Page ping
+ "pp_xoffset_min" integer,
+ "pp_xoffset_max" integer,
+ "pp_yoffset_min" integer,
+ "pp_yoffset_max" integer,
+ -- User Agent
+ "useragent" varchar(1000),
+ -- Browser
+ "br_name" varchar(50),
+ "br_family" varchar(50),
+ "br_version" varchar(50),
+ "br_type" varchar(50),
+ "br_renderengine" varchar(50),
+ "br_lang" varchar(255),
+ "br_features_pdf" boolean,
+ "br_features_flash" boolean,
+ "br_features_java" boolean,
+ "br_features_director" boolean,
+ "br_features_quicktime" boolean,
+ "br_features_realplayer" boolean,
+ "br_features_windowsmedia" boolean,
+ "br_features_gears" boolean,
+ "br_features_silverlight" boolean,
+ "br_cookies" boolean,
+ "br_colordepth" varchar(12),
+ "br_viewwidth" integer,
+ "br_viewheight" integer,
+ -- Operating System
+ "os_name" varchar(50),
+ "os_family" varchar(50),
+ "os_manufacturer" varchar(50),
+ "os_timezone" varchar(50),
+ -- Device/Hardware
+ "dvce_type" varchar(50),
+ "dvce_ismobile" boolean,
+ "dvce_screenwidth" integer,
+ "dvce_screenheight" integer,
+ -- Document
+ "doc_charset" varchar(128),
+ "doc_width" integer,
+ "doc_height" integer,
+ -- Currency
+ "tr_currency" char(3),
+ "tr_total_base" decimal(18, 2),
+ "tr_tax_base" decimal(18, 2),
+ "tr_shipping_base" decimal(18, 2),
+ "ti_currency" char(3),
+ "ti_price_base" decimal(18, 2),
+ "base_currency" char(3),
+ -- Geolocation
+ "geo_timezone" varchar(64),
+ -- Click ID
+ "mkt_clickid" varchar(128),
+ "mkt_network" varchar(64),
+ -- ETL tags
+ "etl_tags" varchar(500),
+ -- Time event was sent
+ "dvce_sent_tstamp" timestamp with time zone,
+ -- Referer
+ "refr_domain_userid" varchar(36),
+ "refr_dvce_tstamp" timestamp with time zone,
+ -- Session ID
+ "domain_sessionid" char(36),
+ -- Derived timestamp
+ "derived_tstamp" timestamp with time zone,
+ -- Event schema
+ "event_vendor" varchar(1000),
+ "event_name" varchar(1000),
+ "event_format" varchar(128),
+ "event_version" varchar(128),
+ -- Event fingerprint
+ "event_fingerprint" varchar(128),
+ -- True timestamp
+ "true_tstamp" timestamp with time zone,
+ PRIMARY KEY (id, project_id)
+ ) PARTITION BY HASH (project_id)
+ WITHOUT OIDS;
+
+ CREATE INDEX index_product_analytics_events_experimental_project_and_time ON product_analytics_events_experimental (project_id, collector_tstamp);
+ SQL
+
+ create_hash_partitions :product_analytics_events_experimental, 64
+ end
+ end
+
+ def down
+ with_lock_retries do
+ execute 'DROP TABLE product_analytics_events_experimental'
+ end
+ end
+end
diff --git a/db/migrate/20200624075411_add_storage_size_limit_to_plan_limit.rb b/db/migrate/20200624075411_add_storage_size_limit_to_plan_limit.rb
new file mode 100644
index 00000000000..7d1b081be02
--- /dev/null
+++ b/db/migrate/20200624075411_add_storage_size_limit_to_plan_limit.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddStorageSizeLimitToPlanLimit < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :plan_limits, :storage_size_limit, :integer, default: 0, null: false
+ end
+end
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
new file mode 100644
index 00000000000..24afe463684
--- /dev/null
+++ b/db/migrate/20200624142107_create_analytics_cycle_analytics_group_value_streams.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class CreateAnalyticsCycleAnalyticsGroupValueStreams < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_analytics_ca_group_value_streams_on_group_id_and_name'
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:analytics_cycle_analytics_group_value_streams)
+ with_lock_retries do
+ create_table :analytics_cycle_analytics_group_value_streams do |t|
+ t.timestamps_with_timezone
+ 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
+ end
+ end
+
+ add_text_limit :analytics_cycle_analytics_group_value_streams, :name, 100
+ end
+
+ def down
+ drop_table :analytics_cycle_analytics_group_value_streams
+ end
+end
diff --git a/db/migrate/20200624142207_add_group_value_stream_to_cycle_analytics_group_stages.rb b/db/migrate/20200624142207_add_group_value_stream_to_cycle_analytics_group_stages.rb
new file mode 100644
index 00000000000..3ce912eb440
--- /dev/null
+++ b/db/migrate/20200624142207_add_group_value_stream_to_cycle_analytics_group_stages.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddGroupValueStreamToCycleAnalyticsGroupStages < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :analytics_cycle_analytics_group_stages, :group_value_stream_id, :bigint
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :analytics_cycle_analytics_group_stages, :group_value_stream_id
+ end
+ end
+end
diff --git a/db/migrate/20200624222443_add_default_branch_name_to_application_settings.rb b/db/migrate/20200624222443_add_default_branch_name_to_application_settings.rb
new file mode 100644
index 00000000000..5da9006e9a0
--- /dev/null
+++ b/db/migrate/20200624222443_add_default_branch_name_to_application_settings.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddDefaultBranchNameToApplicationSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in db/migrate/20200625190458_add_limit_to_default_branch_name_to_application_settings
+ def change
+ add_column :application_settings, :default_branch_name, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20200625045442_add_idx_and_fk_for_prometheus_and_environment_to_alert_management_alerts.rb b/db/migrate/20200625045442_add_idx_and_fk_for_prometheus_and_environment_to_alert_management_alerts.rb
new file mode 100644
index 00000000000..f4869b15735
--- /dev/null
+++ b/db/migrate/20200625045442_add_idx_and_fk_for_prometheus_and_environment_to_alert_management_alerts.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddIdxAndFkForPrometheusAndEnvironmentToAlertManagementAlerts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :alert_management_alerts, :prometheus_alert_id, where: 'prometheus_alert_id is not null'
+ add_concurrent_foreign_key :alert_management_alerts, :prometheus_alerts, column: :prometheus_alert_id, on_delete: :cascade
+
+ add_concurrent_index :alert_management_alerts, :environment_id, where: 'environment_id is not null'
+ add_concurrent_foreign_key :alert_management_alerts, :environments, column: :environment_id, on_delete: :nullify
+ end
+
+ def down
+ remove_concurrent_index :alert_management_alerts, :prometheus_alert_id
+ remove_foreign_key_without_error :alert_management_alerts, column: :prometheus_alert_id
+
+ remove_concurrent_index :alert_management_alerts, :environment_id
+ remove_foreign_key_without_error :alert_management_alerts, column: :environment_id
+ end
+end
diff --git a/db/migrate/20200625082258_add_snippets_size_to_root_storage_statistics.rb b/db/migrate/20200625082258_add_snippets_size_to_root_storage_statistics.rb
new file mode 100644
index 00000000000..7dd0bd94805
--- /dev/null
+++ b/db/migrate/20200625082258_add_snippets_size_to_root_storage_statistics.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddSnippetsSizeToRootStorageStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :namespace_root_storage_statistics, :snippets_size, :bigint, default: 0, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespace_root_storage_statistics, :snippets_size
+ end
+ end
+end
diff --git a/db/migrate/20200625113337_add_last_used_to_personal_access_tokens.rb b/db/migrate/20200625113337_add_last_used_to_personal_access_tokens.rb
new file mode 100644
index 00000000000..c9d155eb628
--- /dev/null
+++ b/db/migrate/20200625113337_add_last_used_to_personal_access_tokens.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddLastUsedToPersonalAccessTokens < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ add_column :personal_access_tokens, :last_used_at, :datetime_with_timezone
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :personal_access_tokens, :last_used_at, :datetime_with_timezone
+ end
+ end
+end
diff --git a/db/migrate/20200625174052_add_partial_index_to_locked_pipelines.rb b/db/migrate/20200625174052_add_partial_index_to_locked_pipelines.rb
new file mode 100644
index 00000000000..85f706f5d31
--- /dev/null
+++ b/db/migrate/20200625174052_add_partial_index_to_locked_pipelines.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddPartialIndexToLockedPipelines < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_pipelines, [:ci_ref_id, :id], name: 'idx_ci_pipelines_artifacts_locked', where: 'locked = 1'
+ end
+
+ def down
+ remove_concurrent_index :ci_pipelines, 'idx_ci_pipelines_artifacts_locked'
+ end
+end
diff --git a/db/migrate/20200625190458_add_limit_to_default_branch_name_to_application_settings.rb b/db/migrate/20200625190458_add_limit_to_default_branch_name_to_application_settings.rb
new file mode 100644
index 00000000000..b11eb514577
--- /dev/null
+++ b/db/migrate/20200625190458_add_limit_to_default_branch_name_to_application_settings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddLimitToDefaultBranchNameToApplicationSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :application_settings, :default_branch_name, 255
+ end
+
+ def down
+ remove_text_limit :application_settings, :default_branch_name
+ end
+end
diff --git a/db/migrate/20200626130220_drop_partitions_dynamic_schema_if_exists.rb b/db/migrate/20200626130220_drop_partitions_dynamic_schema_if_exists.rb
new file mode 100644
index 00000000000..fa31bc8ff0e
--- /dev/null
+++ b/db/migrate/20200626130220_drop_partitions_dynamic_schema_if_exists.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class DropPartitionsDynamicSchemaIfExists < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ # This targets GitLab.com only - we deployed a migration to create this schema, but reverted the change
+ execute 'DROP SCHEMA IF EXISTS partitions_dynamic'
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb b/db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb
new file mode 100644
index 00000000000..6f1959a128f
--- /dev/null
+++ b/db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddMaintenanceModeApplicationToSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:application_settings, :maintenance_mode)
+ change_table :application_settings do |t|
+ t.boolean :maintenance_mode, default: false, null: false
+ t.text :maintenance_mode_message
+ end
+ end
+
+ add_text_limit(:application_settings, :maintenance_mode_message, 255)
+ end
+
+ def down
+ if column_exists?(:application_settings, :maintenance_mode)
+ remove_column :application_settings, :maintenance_mode
+ end
+
+ if column_exists?(:application_settings, :maintenance_mode_message)
+ remove_column :application_settings, :maintenance_mode_message
+ end
+ end
+end
diff --git a/db/migrate/20200629192638_add_uniq_index_on_metric_identifier_and_project_id.rb b/db/migrate/20200629192638_add_uniq_index_on_metric_identifier_and_project_id.rb
new file mode 100644
index 00000000000..3e77f80b5e8
--- /dev/null
+++ b/db/migrate/20200629192638_add_uniq_index_on_metric_identifier_and_project_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddUniqIndexOnMetricIdentifierAndProjectId < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :prometheus_metrics, [:identifier, :project_id], unique: true
+ end
+
+ def down
+ remove_concurrent_index :prometheus_metrics, [:identifier, :project_id]
+ end
+end
diff --git a/db/migrate/20200630091656_add_bio_html_to_user_details.rb b/db/migrate/20200630091656_add_bio_html_to_user_details.rb
new file mode 100644
index 00000000000..6a9df85d6a4
--- /dev/null
+++ b/db/migrate/20200630091656_add_bio_html_to_user_details.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddBioHtmlToUserDetails < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ # Note: bio_html is calculated from bio, the bio column is already constrained
+ add_column :user_details, :bio_html, :text # rubocop:disable Migration/AddLimitToTextColumns
+ add_column :user_details, :cached_markdown_version, :integer
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :user_details, :bio_html
+ remove_column :user_details, :cached_markdown_version
+ end
+ end
+end
diff --git a/db/migrate/20200630110826_add_documents_count_target_to_elastic_reindexing_tasks.rb b/db/migrate/20200630110826_add_documents_count_target_to_elastic_reindexing_tasks.rb
new file mode 100644
index 00000000000..dcb4ccc857d
--- /dev/null
+++ b/db/migrate/20200630110826_add_documents_count_target_to_elastic_reindexing_tasks.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDocumentsCountTargetToElasticReindexingTasks < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :elastic_reindexing_tasks, :documents_count_target, :integer
+ end
+end
diff --git a/db/migrate/20200701064756_add_not_valid_foreign_key_to_cycle_analytics_group_stages.rb b/db/migrate/20200701064756_add_not_valid_foreign_key_to_cycle_analytics_group_stages.rb
new file mode 100644
index 00000000000..e54cecc5af8
--- /dev/null
+++ b/db/migrate/20200701064756_add_not_valid_foreign_key_to_cycle_analytics_group_stages.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddNotValidForeignKeyToCycleAnalyticsGroupStages < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_analytics_cycle_analytics_group_stages_group_value_stream_id'
+ INDEX_NAME = 'index_analytics_ca_group_stages_on_value_stream_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :analytics_cycle_analytics_group_stages, :group_value_stream_id, name: INDEX_NAME
+ add_foreign_key :analytics_cycle_analytics_group_stages, :analytics_cycle_analytics_group_value_streams,
+ column: :group_value_stream_id, name: CONSTRAINT_NAME, on_delete: :cascade, validate: false
+ end
+
+ def down
+ remove_foreign_key_if_exists :analytics_cycle_analytics_group_stages, column: :group_value_stream_id, name: CONSTRAINT_NAME
+ remove_concurrent_index :analytics_cycle_analytics_group_stages, :group_value_stream_id
+ end
+end
diff --git a/db/migrate/20200701093859_add_import_export_limits_to_application_settings.rb b/db/migrate/20200701093859_add_import_export_limits_to_application_settings.rb
new file mode 100644
index 00000000000..6f40f439385
--- /dev/null
+++ b/db/migrate/20200701093859_add_import_export_limits_to_application_settings.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddImportExportLimitsToApplicationSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :project_import_limit, :integer, default: 6, null: false
+ add_column :application_settings, :project_export_limit, :integer, default: 6, null: false
+ add_column :application_settings, :project_download_export_limit, :integer, default: 1, null: false
+
+ add_column :application_settings, :group_import_limit, :integer, default: 6, null: false
+ add_column :application_settings, :group_export_limit, :integer, default: 6, null: false
+ add_column :application_settings, :group_download_export_limit, :integer, default: 1, null: false
+ end
+end
diff --git a/db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb b/db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb
new file mode 100644
index 00000000000..2d5bbc1cba1
--- /dev/null
+++ b/db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddDelayedProjectRemovalToNamespaces < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :namespaces, :delayed_project_removal, :boolean, default: false, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespaces, :delayed_project_removal
+ end
+ end
+end
diff --git a/db/migrate/20200701205710_create_background_migration_jobs.rb b/db/migrate/20200701205710_create_background_migration_jobs.rb
new file mode 100644
index 00000000000..706b8bd5abe
--- /dev/null
+++ b/db/migrate/20200701205710_create_background_migration_jobs.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateBackgroundMigrationJobs < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:background_migration_jobs)
+ create_table :background_migration_jobs do |t|
+ t.timestamps_with_timezone
+ t.integer :status, null: false, limit: 2, default: 0
+ t.text :class_name, null: false
+ t.jsonb :arguments, null: false
+
+ t.index [:class_name, :arguments]
+ t.index [:class_name, :status, :id]
+ end
+ end
+
+ add_text_limit :background_migration_jobs, :class_name, 200
+ end
+
+ def down
+ drop_table :background_migration_jobs
+ end
+end
diff --git a/db/migrate/20200702123805_change_project_id_index_to_be_unique_on_vulnerability_statistics_table.rb b/db/migrate/20200702123805_change_project_id_index_to_be_unique_on_vulnerability_statistics_table.rb
new file mode 100644
index 00000000000..7562a32a25e
--- /dev/null
+++ b/db/migrate/20200702123805_change_project_id_index_to_be_unique_on_vulnerability_statistics_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ChangeProjectIdIndexToBeUniqueOnVulnerabilityStatisticsTable < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ INDEX_NAME = 'index_vulnerability_statistics_on_unique_project_id'
+
+ def up
+ remove_index :vulnerability_statistics, :project_id # rubocop:disable Migration/RemoveIndex (table is empty)
+ add_index :vulnerability_statistics, :project_id, name: INDEX_NAME, unique: true # rubocop:disable Migration/AddIndex (table is empty)
+ end
+
+ def down
+ remove_index :vulnerability_statistics, name: INDEX_NAME # rubocop:disable Migration/RemoveIndex (table is empty)
+ add_index :vulnerability_statistics, :project_id # rubocop:disable Migration/AddIndex (table is empty)
+ end
+end
diff --git a/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb b/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb
new file mode 100644
index 00000000000..248195c8c75
--- /dev/null
+++ b/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ChangePrometheusMetricsIdentifierIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ NEW_INDEX = :index_prometheus_metrics_on_identifier_and_null_project
+ OLD_INDEX = :index_prometheus_metrics_on_identifier
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :prometheus_metrics, :identifier, name: NEW_INDEX, unique: true, where: 'project_id IS NULL'
+ remove_concurrent_index_by_name :prometheus_metrics, OLD_INDEX
+ end
+
+ def down
+ add_concurrent_index :prometheus_metrics, :identifier, name: OLD_INDEX, unique: true
+ remove_concurrent_index_by_name :prometheus_metrics, NEW_INDEX
+ end
+end
diff --git a/db/migrate/20200703121557_remove_f_keys_from_ci_daily_report_results_table.rb b/db/migrate/20200703121557_remove_f_keys_from_ci_daily_report_results_table.rb
new file mode 100644
index 00000000000..43b869b007d
--- /dev/null
+++ b/db/migrate/20200703121557_remove_f_keys_from_ci_daily_report_results_table.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveFKeysFromCiDailyReportResultsTable < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_daily_report_results, :projects
+ remove_foreign_key_if_exists :ci_daily_report_results, :ci_pipelines
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key :ci_daily_report_results, :projects, column: :project_id, on_delete: :cascade
+ add_concurrent_foreign_key :ci_daily_report_results, :ci_pipelines, column: :last_pipeline_id, on_delete: :cascade
+ end
+end
diff --git a/db/migrate/20200703124823_create_namespace_settings.rb b/db/migrate/20200703124823_create_namespace_settings.rb
new file mode 100644
index 00000000000..907b9d2ca8c
--- /dev/null
+++ b/db/migrate/20200703124823_create_namespace_settings.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateNamespaceSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :namespace_settings, id: false do |t|
+ t.timestamps_with_timezone null: false
+ t.references :namespace, primary_key: true, default: nil, type: :integer, index: false, foreign_key: { on_delete: :cascade }
+ end
+ end
+ end
+
+ def down
+ drop_table :namespace_settings
+ end
+end
diff --git a/db/migrate/20200703154822_add_issues_enabled_to_jira_tracker_data.rb b/db/migrate/20200703154822_add_issues_enabled_to_jira_tracker_data.rb
new file mode 100644
index 00000000000..e56f6f6ee11
--- /dev/null
+++ b/db/migrate/20200703154822_add_issues_enabled_to_jira_tracker_data.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddIssuesEnabledToJiraTrackerData < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :jira_tracker_data, :issues_enabled, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20200706005325_remove_elastic_batch_project_indexer_worker_queue.rb b/db/migrate/20200706005325_remove_elastic_batch_project_indexer_worker_queue.rb
new file mode 100644
index 00000000000..07854096a8b
--- /dev/null
+++ b/db/migrate/20200706005325_remove_elastic_batch_project_indexer_worker_queue.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveElasticBatchProjectIndexerWorkerQueue < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ Sidekiq.redis do |conn|
+ conn.del "queue:elastic_batch_project_indexer"
+ end
+ end
+end
diff --git a/db/migrate/20200706035141_adjust_unique_index_alert_management_alerts.rb b/db/migrate/20200706035141_adjust_unique_index_alert_management_alerts.rb
new file mode 100644
index 00000000000..0a6e614be9a
--- /dev/null
+++ b/db/migrate/20200706035141_adjust_unique_index_alert_management_alerts.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class AdjustUniqueIndexAlertManagementAlerts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_alert_management_alerts_on_project_id_and_fingerprint'
+ NEW_INDEX_NAME = 'index_partial_am_alerts_on_project_id_and_fingerprint'
+ RESOLVED_STATUS = 2
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:alert_management_alerts, %w(project_id fingerprint), where: "status <> #{RESOLVED_STATUS}", name: NEW_INDEX_NAME, unique: true, using: :btree)
+ remove_concurrent_index_by_name :alert_management_alerts, INDEX_NAME
+ end
+
+ def down
+ # Nullify duplicate fingerprints, except for the newest of each match (project_id, fingerprint).
+ query = <<-SQL
+ UPDATE alert_management_alerts am
+ SET fingerprint = NULL
+ WHERE am.created_at <>
+ (SELECT MAX(created_at)
+ FROM alert_management_alerts am2
+ WHERE am.fingerprint = am2.fingerprint AND am.project_id = am2.project_id)
+ AND am.fingerprint IS NOT NULL;
+ SQL
+
+ execute(query)
+
+ remove_concurrent_index_by_name :alert_management_alerts, NEW_INDEX_NAME
+ add_concurrent_index(:alert_management_alerts, %w(project_id fingerprint), name: INDEX_NAME, unique: true, using: :btree)
+ end
+end
diff --git a/db/migrate/20200706170536_add_temporary_storage_increase_to_namespace_limits.rb b/db/migrate/20200706170536_add_temporary_storage_increase_to_namespace_limits.rb
new file mode 100644
index 00000000000..0b6d57831c7
--- /dev/null
+++ b/db/migrate/20200706170536_add_temporary_storage_increase_to_namespace_limits.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddTemporaryStorageIncreaseToNamespaceLimits < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :namespace_limits, :temporary_storage_increase_ends_on, :date, null: true
+ end
+end
diff --git a/db/migrate/20200707071941_drop_old_non_unique_index_on_mr_metrics.rb b/db/migrate/20200707071941_drop_old_non_unique_index_on_mr_metrics.rb
new file mode 100644
index 00000000000..aa90a0c5915
--- /dev/null
+++ b/db/migrate/20200707071941_drop_old_non_unique_index_on_mr_metrics.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class DropOldNonUniqueIndexOnMrMetrics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_merge_request_metrics'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name(:merge_request_metrics, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :merge_request_metrics, :merge_request_id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20200707094341_add_browser_performance_to_plan_limits.rb b/db/migrate/20200707094341_add_browser_performance_to_plan_limits.rb
new file mode 100644
index 00000000000..ef0bea88ead
--- /dev/null
+++ b/db/migrate/20200707094341_add_browser_performance_to_plan_limits.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddBrowserPerformanceToPlanLimits < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :plan_limits, "ci_max_artifact_size_browser_performance", :integer, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20200707095849_add_load_performance_to_plan_limits.rb b/db/migrate/20200707095849_add_load_performance_to_plan_limits.rb
new file mode 100644
index 00000000000..df95956f089
--- /dev/null
+++ b/db/migrate/20200707095849_add_load_performance_to_plan_limits.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddLoadPerformanceToPlanLimits < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :plan_limits, "ci_max_artifact_size_load_performance", :integer, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20200708080631_add_pager_duty_integration_columns_to_project_incident_management_settings.rb b/db/migrate/20200708080631_add_pager_duty_integration_columns_to_project_incident_management_settings.rb
new file mode 100644
index 00000000000..ab56a863f51
--- /dev/null
+++ b/db/migrate/20200708080631_add_pager_duty_integration_columns_to_project_incident_management_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddPagerDutyIntegrationColumnsToProjectIncidentManagementSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # limit constraints added in a separate migration:
+ # 20200710130234_add_limit_constraints_to_project_incident_management_settings_token.rb
+ def change
+ add_column :project_incident_management_settings, :pagerduty_active, :boolean, null: false, default: false
+ add_column :project_incident_management_settings, :encrypted_pagerduty_token, :binary, null: true
+ add_column :project_incident_management_settings, :encrypted_pagerduty_token_iv, :binary, null: true
+ end
+end
diff --git a/db/migrate/20200710105332_change_issues_create_limit_default.rb b/db/migrate/20200710105332_change_issues_create_limit_default.rb
new file mode 100644
index 00000000000..9fbd5375395
--- /dev/null
+++ b/db/migrate/20200710105332_change_issues_create_limit_default.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class ChangeIssuesCreateLimitDefault < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ change_column_default :application_settings, :issues_create_limit, from: 300, to: 0
+ end
+ end
+
+ def down
+ with_lock_retries do
+ change_column_default :application_settings, :issues_create_limit, from: 0, to: 300
+ end
+ end
+end
diff --git a/db/migrate/20200710130234_add_limit_constraints_to_project_incident_management_settings_token.rb b/db/migrate/20200710130234_add_limit_constraints_to_project_incident_management_settings_token.rb
new file mode 100644
index 00000000000..8af927d0959
--- /dev/null
+++ b/db/migrate/20200710130234_add_limit_constraints_to_project_incident_management_settings_token.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddLimitConstraintsToProjectIncidentManagementSettingsToken < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint :project_incident_management_settings, 'octet_length(encrypted_pagerduty_token) <= 255', 'pagerduty_token_length_constraint'
+ add_check_constraint :project_incident_management_settings, 'octet_length(encrypted_pagerduty_token_iv) <= 12', 'pagerduty_token_iv_length_constraint'
+ end
+
+ def down
+ remove_check_constraint :project_incident_management_settings, 'pagerduty_token_length_constraint'
+ remove_check_constraint :project_incident_management_settings, 'pagerduty_token_iv_length_constraint'
+ end
+end
diff --git a/db/migrate/20200712084655_create_dast_sites.rb b/db/migrate/20200712084655_create_dast_sites.rb
new file mode 100644
index 00000000000..fc8d423ffb2
--- /dev/null
+++ b/db/migrate/20200712084655_create_dast_sites.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class CreateDastSites < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :dast_sites do |t|
+ t.references :project, foreign_key: { on_delete: :cascade }, null: false, index: false
+ t.timestamps_with_timezone null: false
+
+ t.text :url, null: false
+ end
+ end
+
+ add_concurrent_index :dast_sites, [:project_id, :url], unique: true
+ add_text_limit :dast_sites, :url, 255
+ end
+
+ def down
+ drop_table :dast_sites
+ end
+end
diff --git a/db/migrate/20200712235622_create_dast_site_profiles.rb b/db/migrate/20200712235622_create_dast_site_profiles.rb
new file mode 100644
index 00000000000..593cccd450a
--- /dev/null
+++ b/db/migrate/20200712235622_create_dast_site_profiles.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class CreateDastSiteProfiles < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :dast_site_profiles do |t|
+ t.references :project, foreign_key: { on_delete: :cascade }, null: false, index: false
+ t.references :dast_site, foreign_key: { on_delete: :cascade }, null: false
+ t.timestamps_with_timezone null: false
+
+ t.text :name, null: false
+ end
+ end
+
+ add_concurrent_index :dast_site_profiles, [:project_id, :name], unique: true
+ add_text_limit :dast_site_profiles, :name, 255
+ end
+
+ def down
+ drop_table :dast_site_profiles
+ end
+end
diff --git a/db/migrate/20200713152443_add_background_migration_job_index_for_partitioning_migrations.rb b/db/migrate/20200713152443_add_background_migration_job_index_for_partitioning_migrations.rb
new file mode 100644
index 00000000000..5ca9b6536ee
--- /dev/null
+++ b/db/migrate/20200713152443_add_background_migration_job_index_for_partitioning_migrations.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddBackgroundMigrationJobIndexForPartitioningMigrations < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ INDEX_NAME = 'index_background_migration_jobs_for_partitioning_migrations'
+
+ def up
+ # rubocop:disable Migration/AddIndex
+ add_index :background_migration_jobs, '((arguments ->> 2))', name: INDEX_NAME,
+ where: "class_name = 'Gitlab::Database::PartitioningMigrationHelpers::BackfillPartitionedTable'"
+ # rubocop:enable Migration/AddIndex
+ end
+
+ def down
+ remove_index :background_migration_jobs, name: INDEX_NAME # rubocop:disable Migration/RemoveIndex
+ end
+end
diff --git a/db/migrate/20200716044023_add_entity_path_to_audit_events.rb b/db/migrate/20200716044023_add_entity_path_to_audit_events.rb
new file mode 100644
index 00000000000..d16bfaa0beb
--- /dev/null
+++ b/db/migrate/20200716044023_add_entity_path_to_audit_events.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddEntityPathToAuditEvents < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ # rubocop:disable Migration/AddLimitToTextColumns
+ add_column(:audit_events, :entity_path, :text)
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column(:audit_events, :entity_path)
+ end
+ end
+end
diff --git a/db/migrate/20200716120419_add_text_limit_on_entity_path_to_audit_events.rb b/db/migrate/20200716120419_add_text_limit_on_entity_path_to_audit_events.rb
new file mode 100644
index 00000000000..0dea811f41c
--- /dev/null
+++ b/db/migrate/20200716120419_add_text_limit_on_entity_path_to_audit_events.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddTextLimitOnEntityPathToAuditEvents < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :audit_events, :entity_path, 5_500
+ end
+
+ def down
+ remove_text_limit :audit_events, :entity_path
+ end
+end