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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/25_api_personal_access_token.rb2
-rw-r--r--db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb2
-rw-r--r--db/migrate/20190606014128_add_last_ci_minutes_notification_at_to_namespaces.rb2
-rw-r--r--db/migrate/20190621022810_add_last_ci_minutes_usage_notification_level_to_namespaces.rb2
-rw-r--r--db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb2
-rw-r--r--db/migrate/20190715215549_add_group_emails_disabled.rb2
-rw-r--r--db/migrate/20190911115109_add_namespaces_max_pages_size.rb2
-rw-r--r--db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb2
-rw-r--r--db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb2
-rw-r--r--db/migrate/20200207062728_add_default_branch_protection_to_namespaces.rb2
-rw-r--r--db/migrate/20200304124406_add_unlock_membership_to_ldap_of_groups.rb2
-rw-r--r--db/migrate/20200323075043_add_max_personal_access_token_lifetime_to_namespaces.rb2
-rw-r--r--db/migrate/20200407120000_add_push_rule_id_to_groups.rb2
-rw-r--r--db/migrate/20200424102023_add_shared_runners_enabled_and_override_to_namespaces.rb4
-rw-r--r--db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb2
-rw-r--r--db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb2
-rw-r--r--db/migrate/20201120144823_create_tokens_with_iv.rb18
-rw-r--r--db/migrate/20201127104228_add_index_to_security_scans_on_created_at_and_id.rb18
-rw-r--r--db/migrate/20201204111200_create_packages_debian_project_components.rb35
-rw-r--r--db/migrate/20201204111300_create_packages_debian_group_components.rb35
-rw-r--r--db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb21
-rw-r--r--db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb16
-rw-r--r--db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb23
-rw-r--r--db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb22
-rw-r--r--db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb31
-rw-r--r--db/migrate/20210107154615_add_merge_request_context_commit_trailers.rb12
-rw-r--r--db/migrate/20210111051045_create_dast_profiles.rb35
-rw-r--r--db/migrate/20210111053308_add_project_fk_for_dast_profile.rb19
-rw-r--r--db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb18
-rw-r--r--db/migrate/20210112202949_create_composer_cache_file.rb34
-rw-r--r--db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb16
-rw-r--r--db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb9
-rw-r--r--db/migrate/20210113231546_add_context_to_experiment_subjects.rb9
-rw-r--r--db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb27
-rw-r--r--db/migrate/20210115090452_create_group_repository_storage_move.rb34
-rw-r--r--db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb61
-rw-r--r--db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb9
-rw-r--r--db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb17
-rw-r--r--db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb18
-rw-r--r--db/migrate/20210121093618_remove_repository_read_only_to_groups.rb23
-rw-r--r--db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb19
-rw-r--r--db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb11
-rw-r--r--db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb25
-rw-r--r--db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb20
-rw-r--r--db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb19
-rw-r--r--db/migrate/20210126092102_remove_index_services_project_id_and_type.rb20
-rw-r--r--db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb9
-rw-r--r--db/migrate/20210127143025_add_oldest_merge_requests_index.rb13
-rw-r--r--db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb9
-rw-r--r--db/migrate/20210128114526_add_auto_delete_at_to_environments.rb19
-rw-r--r--db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb12
-rw-r--r--db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb16
-rw-r--r--db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb24
-rw-r--r--db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb59
-rw-r--r--db/migrate/20210203002331_drop_backup_label_index.rb19
-rw-r--r--db/migrate/20210203092540_remove_has_external_wiki_constraint.rb20
-rw-r--r--db/migrate/20210203092549_restore_has_external_wiki_default_value.rb31
-rw-r--r--db/post_migrate/20190606175050_encrypt_feature_flags_clients_tokens.rb2
-rw-r--r--db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb2
-rw-r--r--db/post_migrate/20200408132152_remove_namespaces_trial_ends_on.rb2
-rw-r--r--db/post_migrate/20200424043515_drop_namespaces_plan_id.rb2
-rw-r--r--db/post_migrate/20201112130710_schedule_remove_duplicate_vulnerabilities_findings.rb38
-rw-r--r--db/post_migrate/20210105052229_clean_up_asset_proxy_whitelist_rename_on_application_settings.rb21
-rw-r--r--db/post_migrate/20210111075105_schedule_uuid_population_for_security_findings.rb26
-rw-r--r--db/post_migrate/20210115220610_schedule_artifact_expiry_backfill.rb48
-rw-r--r--db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb34
-rw-r--r--db/schema_migrations/202011121307101
-rw-r--r--db/schema_migrations/202011201448231
-rw-r--r--db/schema_migrations/202011271042281
-rw-r--r--db/schema_migrations/202012041112001
-rw-r--r--db/schema_migrations/202012041113001
-rw-r--r--db/schema_migrations/202101050520341
-rw-r--r--db/schema_migrations/202101050522291
-rw-r--r--db/schema_migrations/202101051533421
-rw-r--r--db/schema_migrations/202101051543211
-rw-r--r--db/schema_migrations/202101061552091
-rw-r--r--db/schema_migrations/202101071053061
-rw-r--r--db/schema_migrations/202101071546151
-rw-r--r--db/schema_migrations/202101110510451
-rw-r--r--db/schema_migrations/202101110533081
-rw-r--r--db/schema_migrations/202101110751041
-rw-r--r--db/schema_migrations/202101110751051
-rw-r--r--db/schema_migrations/202101122029491
-rw-r--r--db/schema_migrations/202101132249091
-rw-r--r--db/schema_migrations/202101132315321
-rw-r--r--db/schema_migrations/202101132315461
-rw-r--r--db/schema_migrations/202101141424431
-rw-r--r--db/schema_migrations/202101150904521
-rw-r--r--db/schema_migrations/202101152206101
-rw-r--r--db/schema_migrations/202101172102261
-rw-r--r--db/schema_migrations/202101181113071
-rw-r--r--db/schema_migrations/202101191223541
-rw-r--r--db/schema_migrations/202101191628121
-rw-r--r--db/schema_migrations/202101202217431
-rw-r--r--db/schema_migrations/202101210936181
-rw-r--r--db/schema_migrations/202101220738051
-rw-r--r--db/schema_migrations/202101221532591
-rw-r--r--db/schema_migrations/202101221551581
-rw-r--r--db/schema_migrations/202101260302491
-rw-r--r--db/schema_migrations/202101260917131
-rw-r--r--db/schema_migrations/202101260921021
-rw-r--r--db/schema_migrations/202101270522261
-rw-r--r--db/schema_migrations/202101271430251
-rw-r--r--db/schema_migrations/202101280449301
-rw-r--r--db/schema_migrations/202101281145261
-rw-r--r--db/schema_migrations/202101281401571
-rw-r--r--db/schema_migrations/202101281402321
-rw-r--r--db/schema_migrations/202101292252441
-rw-r--r--db/schema_migrations/202102011404341
-rw-r--r--db/schema_migrations/202102030023311
-rw-r--r--db/schema_migrations/202102030925401
-rw-r--r--db/schema_migrations/202102030925491
-rw-r--r--db/structure.sql288
113 files changed, 1410 insertions, 38 deletions
diff --git a/db/fixtures/development/25_api_personal_access_token.rb b/db/fixtures/development/25_api_personal_access_token.rb
index 9b0427b3a88..1413f468be1 100644
--- a/db/fixtures/development/25_api_personal_access_token.rb
+++ b/db/fixtures/development/25_api_personal_access_token.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require './spec/support/sidekiq_middleware'
-
# Create an api access token for root user with the value:
token = 'ypCa3Dzb23o5nvsixwPA'
scopes = Gitlab::Auth.all_available_scopes
diff --git a/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb b/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb
index 93e7a84fb02..e4757b6bada 100644
--- a/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb
+++ b/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb
@@ -4,6 +4,6 @@ class AddAutoDevOpsEnabledToNamespaces < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
- add_column :namespaces, :auto_devops_enabled, :boolean
+ add_column :namespaces, :auto_devops_enabled, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20190606014128_add_last_ci_minutes_notification_at_to_namespaces.rb b/db/migrate/20190606014128_add_last_ci_minutes_notification_at_to_namespaces.rb
index c264a23cda0..53b2e9f01fe 100644
--- a/db/migrate/20190606014128_add_last_ci_minutes_notification_at_to_namespaces.rb
+++ b/db/migrate/20190606014128_add_last_ci_minutes_notification_at_to_namespaces.rb
@@ -7,6 +7,6 @@ class AddLastCiMinutesNotificationAtToNamespaces < ActiveRecord::Migration[5.1]
DOWNTIME = false
def change
- add_column :namespaces, :last_ci_minutes_notification_at, :datetime_with_timezone
+ add_column :namespaces, :last_ci_minutes_notification_at, :datetime_with_timezone # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20190621022810_add_last_ci_minutes_usage_notification_level_to_namespaces.rb b/db/migrate/20190621022810_add_last_ci_minutes_usage_notification_level_to_namespaces.rb
index 1611340284c..02e06703acc 100644
--- a/db/migrate/20190621022810_add_last_ci_minutes_usage_notification_level_to_namespaces.rb
+++ b/db/migrate/20190621022810_add_last_ci_minutes_usage_notification_level_to_namespaces.rb
@@ -4,6 +4,6 @@ class AddLastCiMinutesUsageNotificationLevelToNamespaces < ActiveRecord::Migrati
DOWNTIME = false
def change
- add_column :namespaces, :last_ci_minutes_usage_notification_level, :integer
+ add_column :namespaces, :last_ci_minutes_usage_notification_level, :integer # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb b/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb
index 3b75c92e518..6fcadc0c82c 100644
--- a/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb
+++ b/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb
@@ -6,7 +6,7 @@ class AddGroupCreationLevelToNamespaces < ActiveRecord::Migration[5.1]
DOWNTIME = false
def up
- add_column(:namespaces, :subgroup_creation_level, :integer)
+ add_column(:namespaces, :subgroup_creation_level, :integer) # rubocop:disable Migration/AddColumnsToWideTables
change_column_default(:namespaces,
:subgroup_creation_level,
::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
diff --git a/db/migrate/20190715215549_add_group_emails_disabled.rb b/db/migrate/20190715215549_add_group_emails_disabled.rb
index d3fd4d2d923..63a815cb880 100644
--- a/db/migrate/20190715215549_add_group_emails_disabled.rb
+++ b/db/migrate/20190715215549_add_group_emails_disabled.rb
@@ -4,6 +4,6 @@ class AddGroupEmailsDisabled < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
- add_column :namespaces, :emails_disabled, :boolean
+ add_column :namespaces, :emails_disabled, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20190911115109_add_namespaces_max_pages_size.rb b/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
index c14dfa74a5a..d3054714188 100644
--- a/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
+++ b/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
@@ -4,6 +4,6 @@ class AddNamespacesMaxPagesSize < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
- add_column :namespaces, :max_pages_size, :integer
+ add_column :namespaces, :max_pages_size, :integer # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb b/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
index 60c594c47a6..bec81d6c7e1 100644
--- a/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
+++ b/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
@@ -4,6 +4,6 @@ class AddNamespacesMaxArtifactsSize < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
- add_column :namespaces, :max_artifacts_size, :integer
+ add_column :namespaces, :max_artifacts_size, :integer # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb b/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb
index dbd69568ef2..a67d032795d 100644
--- a/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb
+++ b/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb
@@ -4,6 +4,6 @@ class AddMentionsDisabledToNamespaces < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
- add_column :namespaces, :mentions_disabled, :boolean
+ add_column :namespaces, :mentions_disabled, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20200207062728_add_default_branch_protection_to_namespaces.rb b/db/migrate/20200207062728_add_default_branch_protection_to_namespaces.rb
index 6eb650e6b6a..56a30b02290 100644
--- a/db/migrate/20200207062728_add_default_branch_protection_to_namespaces.rb
+++ b/db/migrate/20200207062728_add_default_branch_protection_to_namespaces.rb
@@ -7,7 +7,7 @@ class AddDefaultBranchProtectionToNamespaces < ActiveRecord::Migration[6.0]
def up
with_lock_retries do
- add_column :namespaces, :default_branch_protection, :integer, limit: 2
+ add_column :namespaces, :default_branch_protection, :integer, limit: 2 # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20200304124406_add_unlock_membership_to_ldap_of_groups.rb b/db/migrate/20200304124406_add_unlock_membership_to_ldap_of_groups.rb
index 2aa58c92c3e..19e6573af9b 100644
--- a/db/migrate/20200304124406_add_unlock_membership_to_ldap_of_groups.rb
+++ b/db/migrate/20200304124406_add_unlock_membership_to_ldap_of_groups.rb
@@ -7,7 +7,7 @@ class AddUnlockMembershipToLdapOfGroups < ActiveRecord::Migration[5.2]
def up
with_lock_retries do
- add_column(:namespaces, :unlock_membership_to_ldap, :boolean)
+ add_column(:namespaces, :unlock_membership_to_ldap, :boolean) # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20200323075043_add_max_personal_access_token_lifetime_to_namespaces.rb b/db/migrate/20200323075043_add_max_personal_access_token_lifetime_to_namespaces.rb
index 907c832ce46..7388d6bbc13 100644
--- a/db/migrate/20200323075043_add_max_personal_access_token_lifetime_to_namespaces.rb
+++ b/db/migrate/20200323075043_add_max_personal_access_token_lifetime_to_namespaces.rb
@@ -7,7 +7,7 @@ class AddMaxPersonalAccessTokenLifetimeToNamespaces < ActiveRecord::Migration[6.
def up
with_lock_retries do
- add_column :namespaces, :max_personal_access_token_lifetime, :integer
+ add_column :namespaces, :max_personal_access_token_lifetime, :integer # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20200407120000_add_push_rule_id_to_groups.rb b/db/migrate/20200407120000_add_push_rule_id_to_groups.rb
index 4b4e99052aa..738f0a4c605 100644
--- a/db/migrate/20200407120000_add_push_rule_id_to_groups.rb
+++ b/db/migrate/20200407120000_add_push_rule_id_to_groups.rb
@@ -7,7 +7,7 @@ class AddPushRuleIdToGroups < ActiveRecord::Migration[6.0]
def up
with_lock_retries do
- add_column :namespaces, :push_rule_id, :bigint
+ add_column :namespaces, :push_rule_id, :bigint # rubocop:disable Migration/AddColumnsToWideTables
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
index 2555a50be44..1adc421b9af 100644
--- 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
@@ -7,8 +7,8 @@ class AddSharedRunnersEnabledAndOverrideToNamespaces < ActiveRecord::Migration[6
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
+ add_column :namespaces, :shared_runners_enabled, :boolean, default: true, null: false # rubocop:disable Migration/AddColumnsToWideTables
+ add_column :namespaces, :allow_descendants_override_disabled_shared_runners, :boolean, default: false, null: false # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb b/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb
index d7f282b69f8..3041d7a8e58 100644
--- a/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb
+++ b/db/migrate/20200609012539_add_traversal_ids_to_namespaces.rb
@@ -7,7 +7,7 @@ class AddTraversalIdsToNamespaces < ActiveRecord::Migration[6.0]
def up
with_lock_retries do
- add_column :namespaces, :traversal_ids, :integer, array: true, default: [], null: false
+ add_column :namespaces, :traversal_ids, :integer, array: true, default: [], null: false # rubocop:disable Migration/AddColumnsToWideTables
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
index 2d5bbc1cba1..fcc08723520 100644
--- a/db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb
+++ b/db/migrate/20200701190523_add_delayed_project_removal_to_namespaces.rb
@@ -7,7 +7,7 @@ class AddDelayedProjectRemovalToNamespaces < ActiveRecord::Migration[6.0]
def up
with_lock_retries do
- add_column :namespaces, :delayed_project_removal, :boolean, default: false, null: false
+ add_column :namespaces, :delayed_project_removal, :boolean, default: false, null: false # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/migrate/20201120144823_create_tokens_with_iv.rb b/db/migrate/20201120144823_create_tokens_with_iv.rb
new file mode 100644
index 00000000000..f8dc75513fb
--- /dev/null
+++ b/db/migrate/20201120144823_create_tokens_with_iv.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateTokensWithIv < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :token_with_ivs do |t|
+ t.binary :hashed_token, null: false
+ t.binary :hashed_plaintext_token, null: false
+ t.binary :iv, null: false
+
+ t.index :hashed_token, name: 'index_token_with_ivs_on_hashed_token', unique: true, using: :btree
+ t.index :hashed_plaintext_token, name: 'index_token_with_ivs_on_hashed_plaintext_token', unique: true, using: :btree
+ end
+ end
+end
diff --git a/db/migrate/20201127104228_add_index_to_security_scans_on_created_at_and_id.rb b/db/migrate/20201127104228_add_index_to_security_scans_on_created_at_and_id.rb
new file mode 100644
index 00000000000..c9bbe8ab77d
--- /dev/null
+++ b/db/migrate/20201127104228_add_index_to_security_scans_on_created_at_and_id.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexToSecurityScansOnCreatedAtAndId < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_security_scans_on_date_created_at_and_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :security_scans, "date(timezone('UTC', created_at)), id", name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name(:security_scans, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20201204111200_create_packages_debian_project_components.rb b/db/migrate/20201204111200_create_packages_debian_project_components.rb
new file mode 100644
index 00000000000..76946967357
--- /dev/null
+++ b/db/migrate/20201204111200_create_packages_debian_project_components.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class CreatePackagesDebianProjectComponents < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ UNIQUE_NAME = 'uniq_pkgs_deb_proj_components_on_distribution_id_and_name'
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:packages_debian_project_components)
+ create_table :packages_debian_project_components do |t|
+ t.timestamps_with_timezone
+ t.references :distribution,
+ foreign_key: { to_table: :packages_debian_project_distributions, on_delete: :cascade },
+ null: false,
+ index: false
+ t.text :name, null: false
+
+ t.index %w(distribution_id name),
+ name: UNIQUE_NAME,
+ unique: true,
+ using: :btree
+ end
+ end
+
+ add_text_limit :packages_debian_project_components, :name, 255
+ end
+
+ def down
+ drop_table :packages_debian_project_components
+ end
+end
diff --git a/db/migrate/20201204111300_create_packages_debian_group_components.rb b/db/migrate/20201204111300_create_packages_debian_group_components.rb
new file mode 100644
index 00000000000..c69f8d10c2b
--- /dev/null
+++ b/db/migrate/20201204111300_create_packages_debian_group_components.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class CreatePackagesDebianGroupComponents < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ UNIQUE_NAME = 'uniq_pkgs_deb_grp_components_on_distribution_id_and_name'
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:packages_debian_group_components)
+ create_table :packages_debian_group_components do |t|
+ t.timestamps_with_timezone
+ t.references :distribution,
+ foreign_key: { to_table: :packages_debian_group_distributions, on_delete: :cascade },
+ null: false,
+ index: false
+ t.text :name, null: false
+
+ t.index %w(distribution_id name),
+ name: UNIQUE_NAME,
+ unique: true,
+ using: :btree
+ end
+ end
+
+ add_text_limit :packages_debian_group_components, :name, 255
+ end
+
+ def down
+ drop_table :packages_debian_group_components
+ end
+end
diff --git a/db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb b/db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb
new file mode 100644
index 00000000000..cdfbd368070
--- /dev/null
+++ b/db/migrate/20210105052034_rename_asset_proxy_whitelist_on_application_settings.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RenameAssetProxyWhitelistOnApplicationSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers::V2
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :application_settings,
+ :asset_proxy_whitelist,
+ :asset_proxy_allowlist
+ end
+
+ def down
+ undo_rename_column_concurrently :application_settings,
+ :asset_proxy_whitelist,
+ :asset_proxy_allowlist
+ end
+end
diff --git a/db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb b/db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..3b5ffff7645
--- /dev/null
+++ b/db/migrate/20210105153342_add_entity_columns_to_vulnerability_occurrences.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddEntityColumnsToVulnerabilityOccurrences < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20200501000002_add_text_limit_to_sprints_extended_title
+ def change
+ add_column :vulnerability_occurrences, :description, :text
+ add_column :vulnerability_occurrences, :message, :text
+ add_column :vulnerability_occurrences, :solution, :text
+ add_column :vulnerability_occurrences, :cve, :text
+ add_column :vulnerability_occurrences, :location, :jsonb
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb b/db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb
new file mode 100644
index 00000000000..c2e138303d8
--- /dev/null
+++ b/db/migrate/20210105154321_add_text_limit_to_vulnerability_occurrences_entity_columns.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddTextLimitToVulnerabilityOccurrencesEntityColumns < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :vulnerability_occurrences, :description, 15000
+ add_text_limit :vulnerability_occurrences, :message, 3000
+ add_text_limit :vulnerability_occurrences, :solution, 7000
+ add_text_limit :vulnerability_occurrences, :cve, 48400
+ end
+
+ def down
+ remove_text_limit :vulnerability_occurrences, :description
+ remove_text_limit :vulnerability_occurrences, :message
+ remove_text_limit :vulnerability_occurrences, :solution
+ remove_text_limit :vulnerability_occurrences, :cve
+ end
+end
diff --git a/db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb b/db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb
new file mode 100644
index 00000000000..906efa58bcd
--- /dev/null
+++ b/db/migrate/20210106155209_add_merge_request_diff_commit_trailers.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddMergeRequestDiffCommitTrailers < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :merge_request_diff_commits, :trailers, :jsonb, default: {}, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :merge_request_diff_commits, :trailers
+ end
+ end
+end
diff --git a/db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb b/db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb
new file mode 100644
index 00000000000..0b9b5e93054
--- /dev/null
+++ b/db/migrate/20210107105306_add_diff_type_to_merge_request_diffs.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddDiffTypeToMergeRequestDiffs < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ UNIQUE_INDEX_NAME = 'index_merge_request_diffs_on_unique_merge_request_id'
+
+ def up
+ unless column_exists?(:merge_request_diffs, :diff_type)
+ with_lock_retries do
+ add_column :merge_request_diffs, :diff_type, :integer, null: false, limit: 2, default: 1
+ end
+ end
+
+ add_concurrent_index :merge_request_diffs, :merge_request_id, unique: true, where: 'diff_type = 2', name: UNIQUE_INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name(:merge_request_diffs, UNIQUE_INDEX_NAME)
+
+ if column_exists?(:merge_request_diffs, :diff_type)
+ with_lock_retries do
+ remove_column :merge_request_diffs, :diff_type
+ end
+ end
+ end
+end
diff --git a/db/migrate/20210107154615_add_merge_request_context_commit_trailers.rb b/db/migrate/20210107154615_add_merge_request_context_commit_trailers.rb
new file mode 100644
index 00000000000..e7bd7c2ea56
--- /dev/null
+++ b/db/migrate/20210107154615_add_merge_request_context_commit_trailers.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddMergeRequestContextCommitTrailers < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :merge_request_context_commits, :trailers, :jsonb, default: {}, null: false
+ end
+end
diff --git a/db/migrate/20210111051045_create_dast_profiles.rb b/db/migrate/20210111051045_create_dast_profiles.rb
new file mode 100644
index 00000000000..f2667e1222e
--- /dev/null
+++ b/db/migrate/20210111051045_create_dast_profiles.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class CreateDastProfiles < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ table_comment = { owner: 'group::dynamic analysis', description: 'Profile used to run a DAST on-demand scan' }
+
+ create_table_with_constraints :dast_profiles, comment: table_comment.to_json do |t| # rubocop:disable Migration/AddLimitToTextColumns
+ t.references :project, null: false, foreign_key: false, index: false
+ t.references :dast_site_profile, null: false, foreign_key: { on_delete: :cascade }
+ t.references :dast_scanner_profile, null: false, foreign_key: { on_delete: :cascade }
+
+ t.timestamps_with_timezone
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ t.text :name, null: false
+ t.text :description, null: false
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ t.index [:project_id, :name], unique: true
+
+ t.text_limit :name, 255
+ t.text_limit :description, 255
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :dast_profiles
+ end
+ end
+end
diff --git a/db/migrate/20210111053308_add_project_fk_for_dast_profile.rb b/db/migrate/20210111053308_add_project_fk_for_dast_profile.rb
new file mode 100644
index 00000000000..5dc057b5f70
--- /dev/null
+++ b/db/migrate/20210111053308_add_project_fk_for_dast_profile.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddProjectFkForDastProfile < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :dast_profiles, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :dast_profiles, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb b/db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb
new file mode 100644
index 00000000000..a8f4e130f07
--- /dev/null
+++ b/db/migrate/20210111075104_add_temporary_index_on_security_findings_scan_id.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddTemporaryIndexOnSecurityFindingsScanId < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'tmp_index_on_security_findings_scan_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :security_findings, :scan_id, where: 'uuid is null', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :security_findings, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210112202949_create_composer_cache_file.rb b/db/migrate/20210112202949_create_composer_cache_file.rb
new file mode 100644
index 00000000000..b1c2a1608dd
--- /dev/null
+++ b/db/migrate/20210112202949_create_composer_cache_file.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class CreateComposerCacheFile < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ # rubocop:disable Migration/AddLimitToTextColumns
+ create_table_with_constraints :packages_composer_cache_files do |t|
+ t.timestamps_with_timezone
+
+ # record can be deleted after `delete_at`
+ t.datetime_with_timezone :delete_at
+
+ # which namespace it belongs to
+ t.integer :namespace_id, null: true
+
+ # file storage related fields
+ t.integer :file_store, limit: 2, null: false, default: 1
+ t.text :file, null: false
+ t.binary :file_sha256, null: false
+
+ t.index [:namespace_id, :file_sha256], name: "index_packages_composer_cache_namespace_and_sha", using: :btree, unique: true
+ t.foreign_key :namespaces, column: :namespace_id, on_delete: :nullify
+
+ t.text_limit :file, 255
+ end
+ end
+
+ def down
+ drop_table :packages_composer_cache_files
+ end
+end
diff --git a/db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb b/db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb
new file mode 100644
index 00000000000..408d0579031
--- /dev/null
+++ b/db/migrate/20210113224909_add_pipeline_configuration_full_path_to_compliance_pipeline.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddPipelineConfigurationFullPathToCompliancePipeline < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb
+ def up
+ add_column :compliance_management_frameworks, :pipeline_configuration_full_path, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ def down
+ remove_column :compliance_management_frameworks, :pipeline_configuration_full_path
+ end
+end
diff --git a/db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb b/db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb
new file mode 100644
index 00000000000..25571b25af9
--- /dev/null
+++ b/db/migrate/20210113231532_add_converted_at_to_experiment_subjects.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddConvertedAtToExperimentSubjects < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :experiment_subjects, :converted_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20210113231546_add_context_to_experiment_subjects.rb b/db/migrate/20210113231546_add_context_to_experiment_subjects.rb
new file mode 100644
index 00000000000..7fac45e9952
--- /dev/null
+++ b/db/migrate/20210113231546_add_context_to_experiment_subjects.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddContextToExperimentSubjects < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :experiment_subjects, :context, :jsonb, default: {}, null: false
+ end
+end
diff --git a/db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb b/db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb
new file mode 100644
index 00000000000..39964047e7f
--- /dev/null
+++ b/db/migrate/20210114142443_add_indexes_to_onboarding_progresses.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class AddIndexesToOnboardingProgresses < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CREATE_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_create_track'
+ VERIFY_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_verify_track'
+ TRIAL_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_trial_track'
+ TEAM_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_team_track'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :onboarding_progresses, :created_at, where: 'git_write_at IS NULL', name: CREATE_TRACK_INDEX_NAME
+ add_concurrent_index :onboarding_progresses, :git_write_at, where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NULL', name: VERIFY_TRACK_INDEX_NAME
+ add_concurrent_index :onboarding_progresses, 'GREATEST(git_write_at, pipeline_created_at)', where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NOT NULL AND trial_started_at IS NULL', name: TRIAL_TRACK_INDEX_NAME
+ add_concurrent_index :onboarding_progresses, 'GREATEST(git_write_at, pipeline_created_at, trial_started_at)', where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NOT NULL AND trial_started_at IS NOT NULL AND user_added_at IS NULL', name: TEAM_TRACK_INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :onboarding_progresses, CREATE_TRACK_INDEX_NAME
+ remove_concurrent_index_by_name :onboarding_progresses, VERIFY_TRACK_INDEX_NAME
+ remove_concurrent_index_by_name :onboarding_progresses, TRIAL_TRACK_INDEX_NAME
+ remove_concurrent_index_by_name :onboarding_progresses, TEAM_TRACK_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210115090452_create_group_repository_storage_move.rb b/db/migrate/20210115090452_create_group_repository_storage_move.rb
new file mode 100644
index 00000000000..bd168dce5ac
--- /dev/null
+++ b/db/migrate/20210115090452_create_group_repository_storage_move.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class CreateGroupRepositoryStorageMove < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:group_repository_storage_moves)
+ with_lock_retries do
+ create_table :group_repository_storage_moves do |t|
+ t.timestamps_with_timezone
+ t.references :group, references: :namespace, column: :group_id, index: true, null: false
+ t.integer :state, limit: 2, default: 1, null: false
+ t.text :source_storage_name, null: false
+ t.text :destination_storage_name, null: false
+
+ t.foreign_key :namespaces, column: :group_id, on_delete: :cascade
+ end
+ end
+ end
+
+ add_text_limit(:group_repository_storage_moves, :source_storage_name, 255, constraint_name: 'group_repository_storage_moves_source_storage_name')
+ add_text_limit(:group_repository_storage_moves, :destination_storage_name, 255, constraint_name: 'group_repository_storage_moves_destination_storage_name')
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :group_repository_storage_moves
+ end
+ end
+end
diff --git a/db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb b/db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb
new file mode 100644
index 00000000000..20fe0ee0fd1
--- /dev/null
+++ b/db/migrate/20210117210226_add_has_external_issue_tracker_trigger.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+class AddHasExternalIssueTrackerTrigger < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::SchemaHelpers
+
+ DOWNTIME = false
+ FUNCTION_NAME = 'set_has_external_issue_tracker'
+ TRIGGER_ON_INSERT_NAME = 'trigger_has_external_issue_tracker_on_insert'
+ TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_issue_tracker_on_update'
+ TRIGGER_ON_DELETE_NAME = 'trigger_has_external_issue_tracker_on_delete'
+
+ def up
+ create_trigger_function(FUNCTION_NAME, replace: true) do
+ <<~SQL
+ UPDATE projects SET has_external_issue_tracker = (
+ EXISTS
+ (
+ SELECT 1
+ FROM services
+ WHERE project_id = COALESCE(NEW.project_id, OLD.project_id)
+ AND active = TRUE
+ AND category = 'issue_tracker'
+ )
+ )
+ WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id);
+ RETURN NULL;
+ SQL
+ end
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME}
+ AFTER INSERT ON services
+ FOR EACH ROW
+ WHEN (NEW.category = 'issue_tracker' AND NEW.active = TRUE AND NEW.project_id IS NOT NULL)
+ EXECUTE FUNCTION #{FUNCTION_NAME}();
+ SQL
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_ON_UPDATE_NAME}
+ AFTER UPDATE ON services
+ FOR EACH ROW
+ WHEN (NEW.category = 'issue_tracker' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL)
+ EXECUTE FUNCTION #{FUNCTION_NAME}();
+ SQL
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_ON_DELETE_NAME}
+ AFTER DELETE ON services
+ FOR EACH ROW
+ WHEN (OLD.category = 'issue_tracker' AND OLD.active = TRUE AND OLD.project_id IS NOT NULL)
+ EXECUTE FUNCTION #{FUNCTION_NAME}();
+ SQL
+ end
+
+ def down
+ drop_trigger(:services, TRIGGER_ON_INSERT_NAME)
+ drop_trigger(:services, TRIGGER_ON_UPDATE_NAME)
+ drop_trigger(:services, TRIGGER_ON_DELETE_NAME)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb b/db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb
new file mode 100644
index 00000000000..fd1ed4f207b
--- /dev/null
+++ b/db/migrate/20210118111307_add_enforce_ssh_key_expiration_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddEnforceSshKeyExpirationToApplicationSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :enforce_ssh_key_expiration, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb b/db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb
new file mode 100644
index 00000000000..2958dc8d0ec
--- /dev/null
+++ b/db/migrate/20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddTextLimitToCompliancePipelineConfigurationFullPath < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :compliance_management_frameworks, :pipeline_configuration_full_path, 255
+ end
+
+ def down
+ remove_text_limit :compliance_management_frameworks, :pipeline_configuration_full_path
+ end
+end
diff --git a/db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb b/db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb
new file mode 100644
index 00000000000..d29e63ba5da
--- /dev/null
+++ b/db/migrate/20210120221743_delete_oauth_applications_tmp_index.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class DeleteOauthApplicationsTmpIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'tmp_index_oauth_applications_on_id_where_trusted'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :oauth_applications, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :oauth_applications, :id, where: 'trusted = true', name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210121093618_remove_repository_read_only_to_groups.rb b/db/migrate/20210121093618_remove_repository_read_only_to_groups.rb
new file mode 100644
index 00000000000..0b353ba5d88
--- /dev/null
+++ b/db/migrate/20210121093618_remove_repository_read_only_to_groups.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class RemoveRepositoryReadOnlyToGroups < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ if column_exists?(:namespaces, :repository_read_only)
+ with_lock_retries do
+ remove_column :namespaces, :repository_read_only # rubocop:disable Migration/RemoveColumn
+ end
+ end
+ end
+
+ def down
+ unless column_exists?(:namespaces, :repository_read_only)
+ with_lock_retries do
+ add_column :namespaces, :repository_read_only, :boolean, default: false, null: false # rubocop:disable Migration/AddColumnsToWideTables
+ end
+ end
+ end
+end
diff --git a/db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb b/db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb
new file mode 100644
index 00000000000..f6479bdb3a4
--- /dev/null
+++ b/db/migrate/20210122073805_add_repository_read_only_to_namespace_settings.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddRepositoryReadOnlyToNamespaceSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :namespace_settings, :repository_read_only, :boolean, default: false, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespace_settings, :repository_read_only
+ end
+ end
+end
diff --git a/db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb b/db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb
new file mode 100644
index 00000000000..dd0c98615f7
--- /dev/null
+++ b/db/migrate/20210122153259_add_state_to_merge_request_reviewers.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddStateToMergeRequestReviewers < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ REVIEW_DEFAULT_STATE = 0
+
+ def change
+ add_column :merge_request_reviewers, :state, :smallint, default: REVIEW_DEFAULT_STATE, null: false
+ end
+end
diff --git a/db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb b/db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb
new file mode 100644
index 00000000000..749e0b16eaf
--- /dev/null
+++ b/db/migrate/20210122155158_add_pipeline_step_to_bulk_imports_failures.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddPipelineStepToBulkImportsFailures < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:bulk_import_failures, :pipeline_step, :text)
+ with_lock_retries do
+ add_column :bulk_import_failures, :pipeline_step, :text
+ end
+ end
+
+ add_text_limit :bulk_import_failures, :pipeline_step, 255
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :bulk_import_failures, :pipeline_step
+ end
+ end
+end
diff --git a/db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb b/db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb
new file mode 100644
index 00000000000..cd325747282
--- /dev/null
+++ b/db/migrate/20210126030249_add_security_dashboard_access_level_into_project_features.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddSecurityDashboardAccessLevelIntoProjectFeatures < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ PRIVATE_ACCESS_LEVEL = 10
+
+ def up
+ with_lock_retries do
+ add_column :project_features, :security_and_compliance_access_level, :integer, default: PRIVATE_ACCESS_LEVEL, null: false
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :project_features, :security_and_compliance_access_level
+ end
+ end
+end
diff --git a/db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb b/db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb
new file mode 100644
index 00000000000..272dca70a8b
--- /dev/null
+++ b/db/migrate/20210126091713_add_unique_index_services_project_id_and_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexServicesProjectIdAndType < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_services_on_project_id_and_type_unique'
+
+ def up
+ add_concurrent_index :services, [:project_id, :type], name: INDEX_NAME, unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :services, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210126092102_remove_index_services_project_id_and_type.rb b/db/migrate/20210126092102_remove_index_services_project_id_and_type.rb
new file mode 100644
index 00000000000..49780d03b7b
--- /dev/null
+++ b/db/migrate/20210126092102_remove_index_services_project_id_and_type.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class RemoveIndexServicesProjectIdAndType < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_services_on_project_id_and_type'
+
+ # Replaced by the index added in 20210126091713_add_unique_index_services_project_id_and_type.rb
+ def up
+ remove_concurrent_index_by_name :services, name: INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :services, [:project_id, :type], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb b/db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb
new file mode 100644
index 00000000000..fe2b2ef412d
--- /dev/null
+++ b/db/migrate/20210127052226_add_subgroup_events_to_web_hooks.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSubgroupEventsToWebHooks < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :web_hooks, :subgroup_events, :boolean, null: false, default: false
+ end
+end
diff --git a/db/migrate/20210127143025_add_oldest_merge_requests_index.rb b/db/migrate/20210127143025_add_oldest_merge_requests_index.rb
new file mode 100644
index 00000000000..c25e12d89af
--- /dev/null
+++ b/db/migrate/20210127143025_add_oldest_merge_requests_index.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddOldestMergeRequestsIndex < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ # replaced by db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb
+ end
+
+ def down
+ # replaced by db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb
+ end
+end
diff --git a/db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb b/db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb
new file mode 100644
index 00000000000..77a1dd2131b
--- /dev/null
+++ b/db/migrate/20210128044930_add_git_two_factor_session_expiry_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddGitTwoFactorSessionExpiryToApplicationSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :git_two_factor_session_expiry, :integer, default: 15, null: false
+ end
+end
diff --git a/db/migrate/20210128114526_add_auto_delete_at_to_environments.rb b/db/migrate/20210128114526_add_auto_delete_at_to_environments.rb
new file mode 100644
index 00000000000..8f89c2f2ad0
--- /dev/null
+++ b/db/migrate/20210128114526_add_auto_delete_at_to_environments.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddAutoDeleteAtToEnvironments < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :environments, :auto_delete_at, :datetime_with_timezone
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :environments, :auto_delete_at
+ end
+ end
+end
diff --git a/db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb b/db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb
new file mode 100644
index 00000000000..d016e3c20e2
--- /dev/null
+++ b/db/migrate/20210128140157_add_content_type_to_dependency_proxy_manifests.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddContentTypeToDependencyProxyManifests < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb
+ def change
+ add_column :dependency_proxy_manifests, :content_type, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb b/db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb
new file mode 100644
index 00000000000..035e4795ce0
--- /dev/null
+++ b/db/migrate/20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToDependencyProxyManifestsContentType < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :dependency_proxy_manifests, :content_type, 255
+ end
+
+ def down
+ remove_text_limit :dependency_proxy_manifests, :content_type
+ end
+end
diff --git a/db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb b/db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb
new file mode 100644
index 00000000000..8285aceb24a
--- /dev/null
+++ b/db/migrate/20210129225244_add_index_to_oncall_shfts_on_starts_at_and_ends_at.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddIndexToOncallShftsOnStartsAtAndEndsAt < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ NEW_NAME = 'index_oncall_shifts_on_rotation_id_and_starts_at_and_ends_at'
+ OLD_NAME = 'index_incident_management_oncall_shifts_on_rotation_id'
+
+ def up
+ add_concurrent_index :incident_management_oncall_shifts, %i[rotation_id starts_at ends_at], name: NEW_NAME
+
+ remove_concurrent_index_by_name :incident_management_oncall_shifts, OLD_NAME
+ end
+
+ def down
+ add_concurrent_index :incident_management_oncall_shifts, :rotation_id, name: OLD_NAME
+
+ remove_concurrent_index_by_name :incident_management_oncall_shifts, NEW_NAME
+ end
+end
diff --git a/db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb b/db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb
new file mode 100644
index 00000000000..a3fed9e576a
--- /dev/null
+++ b/db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+class AddOldestMergeRequestsIndexAgain < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::SchemaHelpers
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ INDEX = 'index_on_merge_requests_for_latest_diffs'
+
+ def up
+ execute "DROP INDEX CONCURRENTLY #{INDEX}" if invalid_index?
+
+ return if index_exists_by_name?('merge_requests', INDEX)
+
+ begin
+ disable_statement_timeout do
+ execute "CREATE INDEX CONCURRENTLY #{INDEX} ON merge_requests " \
+ 'USING btree (target_project_id) INCLUDE (id, latest_merge_request_diff_id)'
+ end
+ rescue ActiveRecord::StatementInvalid => ex
+ # Due to https://github.com/lfittl/pg_query/issues/184, if the CREATE
+ # INDEX statement fails, we trigger a separate error due to the Gem not
+ # supporting the INCLUDE syntax.
+ #
+ # To work around this, we raise a custom error instead, as these won't
+ # have a query context injected.
+ raise "The index #{INDEX} couldn't be added: #{ex.message}"
+ end
+
+ create_comment(
+ 'INDEX',
+ INDEX,
+ 'Index used to efficiently obtain the oldest merge request for a commit SHA'
+ )
+ end
+
+ def down
+ return unless index_exists_by_name?('merge_requests', INDEX)
+
+ disable_statement_timeout do
+ execute "DROP INDEX CONCURRENTLY #{INDEX}"
+ end
+ end
+
+ def invalid_index?
+ result = execute(<<~SQL)
+ SELECT pg_class.relname
+ FROM pg_class, pg_index
+ WHERE pg_index.indisvalid = false
+ AND pg_index.indexrelid = pg_class.oid
+ AND pg_class.relname = '#{INDEX}';
+ SQL
+
+ result.values.any?
+ end
+end
diff --git a/db/migrate/20210203002331_drop_backup_label_index.rb b/db/migrate/20210203002331_drop_backup_label_index.rb
new file mode 100644
index 00000000000..430d2d0fb79
--- /dev/null
+++ b/db/migrate/20210203002331_drop_backup_label_index.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class DropBackupLabelIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'backup_labels_project_id_title_idx'
+
+ def up
+ remove_concurrent_index_by_name(:backup_labels, name: INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :backup_labels, [:project_id, :title], name: INDEX_NAME, unique: true, where: 'group_id = NULL::integer'
+ end
+end
diff --git a/db/migrate/20210203092540_remove_has_external_wiki_constraint.rb b/db/migrate/20210203092540_remove_has_external_wiki_constraint.rb
new file mode 100644
index 00000000000..80b0cc11685
--- /dev/null
+++ b/db/migrate/20210203092540_remove_has_external_wiki_constraint.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class RemoveHasExternalWikiConstraint < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # This reverts the following migration: add_not_null_constraint :projects, :has_external_wiki, validate: false
+ if check_not_null_constraint_exists?(:projects, :has_external_wiki)
+ remove_not_null_constraint :projects, :has_external_wiki
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb b/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb
new file mode 100644
index 00000000000..37111b370a5
--- /dev/null
+++ b/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class RestoreHasExternalWikiDefaultValue < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ class TmpProject < ActiveRecord::Base
+ self.table_name = 'projects'
+ end
+
+ # This reverts the following migration: change_column_default(:projects, :has_external_wiki, from: nil, to: false)
+ # We only change the column when the current default value is false
+ def up
+ # Find out the current default value
+ column = TmpProject.columns.find { |c| c.name == 'has_external_wiki' }
+ return unless column
+
+ if column.default == 'false'
+ with_lock_retries do
+ change_column_default(:projects, :has_external_wiki, from: false, to: nil)
+ end
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20190606175050_encrypt_feature_flags_clients_tokens.rb b/db/post_migrate/20190606175050_encrypt_feature_flags_clients_tokens.rb
index cb7d723670f..b8df41767f0 100644
--- a/db/post_migrate/20190606175050_encrypt_feature_flags_clients_tokens.rb
+++ b/db/post_migrate/20190606175050_encrypt_feature_flags_clients_tokens.rb
@@ -10,7 +10,7 @@ class EncryptFeatureFlagsClientsTokens < ActiveRecord::Migration[5.1]
def up
say_with_time("Encrypting tokens from operations_feature_flags_clients") do
FeatureFlagsClient.where('token_encrypted is NULL AND token IS NOT NULL').find_each do |feature_flags_client|
- token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(feature_flags_client.token)
+ token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(feature_flags_client.token, nonce: Gitlab::CryptoHelper::AES256_GCM_IV_STATIC)
feature_flags_client.update!(token_encrypted: token_encrypted)
end
end
diff --git a/db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb b/db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb
index 2eb8d1ee11c..b2de98118b7 100644
--- a/db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb
+++ b/db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb
@@ -10,7 +10,7 @@ class EncryptDeployTokensTokens < ActiveRecord::Migration[5.1]
def up
say_with_time("Encrypting tokens from deploy_tokens") do
DeploymentTokens.where('token_encrypted is NULL AND token IS NOT NULL').find_each(batch_size: 10000) do |deploy_token|
- token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(deploy_token.token)
+ token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(deploy_token.token, nonce: Gitlab::CryptoHelper::AES256_GCM_IV_STATIC)
deploy_token.update!(token_encrypted: token_encrypted)
end
end
diff --git a/db/post_migrate/20200408132152_remove_namespaces_trial_ends_on.rb b/db/post_migrate/20200408132152_remove_namespaces_trial_ends_on.rb
index cfe0daaf50f..a303b9d1869 100644
--- a/db/post_migrate/20200408132152_remove_namespaces_trial_ends_on.rb
+++ b/db/post_migrate/20200408132152_remove_namespaces_trial_ends_on.rb
@@ -18,7 +18,7 @@ class RemoveNamespacesTrialEndsOn < ActiveRecord::Migration[6.0]
def down
unless column_exists?(:namespaces, :trial_ends_on)
with_lock_retries do
- add_column :namespaces, :trial_ends_on, :datetime_with_timezone
+ add_column :namespaces, :trial_ends_on, :datetime_with_timezone # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb b/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb
index 16a56b16e5a..b05f2da648a 100644
--- a/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb
+++ b/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb
@@ -16,7 +16,7 @@ class DropNamespacesPlanId < ActiveRecord::Migration[6.0]
def down
unless column_exists?(:namespaces, :plan_id)
with_lock_retries do
- add_column :namespaces, :plan_id, :integer
+ add_column :namespaces, :plan_id, :integer # rubocop:disable Migration/AddColumnsToWideTables
end
end
diff --git a/db/post_migrate/20201112130710_schedule_remove_duplicate_vulnerabilities_findings.rb b/db/post_migrate/20201112130710_schedule_remove_duplicate_vulnerabilities_findings.rb
new file mode 100644
index 00000000000..d05516bd255
--- /dev/null
+++ b/db/post_migrate/20201112130710_schedule_remove_duplicate_vulnerabilities_findings.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+class ScheduleRemoveDuplicateVulnerabilitiesFindings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ INDEX_NAME = 'tmp_idx_deduplicate_vulnerability_occurrences'
+
+ MIGRATION = 'RemoveDuplicateVulnerabilitiesFindings'
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 5_000
+
+ disable_ddl_transaction!
+
+ class VulnerabilitiesFinding < ActiveRecord::Base
+ include ::EachBatch
+ self.table_name = "vulnerability_occurrences"
+ end
+
+ def up
+ add_concurrent_index :vulnerability_occurrences,
+ %i[project_id report_type location_fingerprint primary_identifier_id id],
+ name: INDEX_NAME
+
+ say "Scheduling #{MIGRATION} jobs"
+ queue_background_migration_jobs_by_range_at_intervals(
+ VulnerabilitiesFinding,
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name(:vulnerability_occurrences, INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20210105052229_clean_up_asset_proxy_whitelist_rename_on_application_settings.rb b/db/post_migrate/20210105052229_clean_up_asset_proxy_whitelist_rename_on_application_settings.rb
new file mode 100644
index 00000000000..8f6d312ae5e
--- /dev/null
+++ b/db/post_migrate/20210105052229_clean_up_asset_proxy_whitelist_rename_on_application_settings.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CleanUpAssetProxyWhitelistRenameOnApplicationSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers::V2
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :application_settings,
+ :asset_proxy_whitelist,
+ :asset_proxy_allowlist
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :application_settings,
+ :asset_proxy_whitelist,
+ :asset_proxy_allowlist
+ end
+end
diff --git a/db/post_migrate/20210111075105_schedule_uuid_population_for_security_findings.rb b/db/post_migrate/20210111075105_schedule_uuid_population_for_security_findings.rb
new file mode 100644
index 00000000000..92241378495
--- /dev/null
+++ b/db/post_migrate/20210111075105_schedule_uuid_population_for_security_findings.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class ScheduleUuidPopulationForSecurityFindings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ MIGRATION_CLASS = 'PopulateUuidsForSecurityFindings'
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 25
+
+ disable_ddl_transaction!
+
+ def up
+ Gitlab::BackgroundMigration::PopulateUuidsForSecurityFindings.security_findings.each_batch(column: :scan_id, of: BATCH_SIZE) do |batch, index|
+ migrate_in(
+ DELAY_INTERVAL * index,
+ MIGRATION_CLASS,
+ batch.pluck(:scan_id)
+ )
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210115220610_schedule_artifact_expiry_backfill.rb b/db/post_migrate/20210115220610_schedule_artifact_expiry_backfill.rb
new file mode 100644
index 00000000000..44a76321495
--- /dev/null
+++ b/db/post_migrate/20210115220610_schedule_artifact_expiry_backfill.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class ScheduleArtifactExpiryBackfill < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ MIGRATION = 'BackfillArtifactExpiryDate'.freeze
+ SWITCH_DATE = Date.new(2020, 06, 22).freeze
+ INDEX_NAME = 'expired_artifacts_temp_index'.freeze
+ OLD_INDEX_CONDITION = "expire_at IS NULL AND created_at < '#{SWITCH_DATE}'"
+ INDEX_CONDITION = "expire_at IS NULL AND date(created_at AT TIME ZONE 'UTC') < '2020-06-22'::date".freeze
+
+ disable_ddl_transaction!
+
+ class JobArtifact < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'ci_job_artifacts'
+
+ scope :without_expiry_date, -> { where(expire_at: nil) }
+ scope :before_switch, -> { where("date(created_at AT TIME ZONE 'UTC') < ?::date", SWITCH_DATE) }
+ end
+
+ def up
+ # Create temporary index for expired artifacts
+ # Needs to be removed in a later migration
+ remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME
+ add_concurrent_index(:ci_job_artifacts, %i(id created_at), where: INDEX_CONDITION, name: INDEX_NAME)
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ JobArtifact.without_expiry_date.before_switch,
+ MIGRATION,
+ 2.minutes,
+ batch_size: 200_000
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME
+ add_concurrent_index(:ci_job_artifacts, %i(id created_at), where: OLD_INDEX_CONDITION, name: INDEX_NAME)
+
+ Gitlab::BackgroundMigration.steal(MIGRATION) do |job|
+ job.delete
+
+ false
+ end
+ end
+end
diff --git a/db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb b/db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb
new file mode 100644
index 00000000000..132d72e180b
--- /dev/null
+++ b/db/post_migrate/20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class AlterVsaIssueFirstMentionedInCommitValue < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS = 2
+ ISSUE_FIRST_MENTIONED_IN_COMMIT_EE = 6
+
+ class GroupStage < ActiveRecord::Base
+ self.table_name = 'analytics_cycle_analytics_group_stages'
+
+ include EachBatch
+ end
+
+ def up
+ GroupStage.each_batch(of: 100) do |relation|
+ relation
+ .where(start_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_EE)
+ .update_all(start_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS)
+
+ relation
+ .where(end_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_EE)
+ .update_all(end_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS)
+ end
+ end
+
+ def down
+ # rollback is not needed, the identifier "6" is the same as identifier "2" on the application level
+ end
+end
diff --git a/db/schema_migrations/20201112130710 b/db/schema_migrations/20201112130710
new file mode 100644
index 00000000000..a13668cf3ce
--- /dev/null
+++ b/db/schema_migrations/20201112130710
@@ -0,0 +1 @@
+322d7270e942c161cc8b50b8c3f531c93b6e6e938e415c1b6010a70b630bf82e \ No newline at end of file
diff --git a/db/schema_migrations/20201120144823 b/db/schema_migrations/20201120144823
new file mode 100644
index 00000000000..4f0c5c43978
--- /dev/null
+++ b/db/schema_migrations/20201120144823
@@ -0,0 +1 @@
+dde424c434c78e22087123fa30eec75c07268a9079fea44339915747aae235e0 \ No newline at end of file
diff --git a/db/schema_migrations/20201127104228 b/db/schema_migrations/20201127104228
new file mode 100644
index 00000000000..9a582600854
--- /dev/null
+++ b/db/schema_migrations/20201127104228
@@ -0,0 +1 @@
+a66f13cf62740c590aa195dd510f1e9f4a36e12d29fd0c824fbd0ace03717706 \ No newline at end of file
diff --git a/db/schema_migrations/20201204111200 b/db/schema_migrations/20201204111200
new file mode 100644
index 00000000000..34628516bf8
--- /dev/null
+++ b/db/schema_migrations/20201204111200
@@ -0,0 +1 @@
+2aad94b0577882df4fec3df3806993858dad9f4eb20db71c94f8590c6640d62e \ No newline at end of file
diff --git a/db/schema_migrations/20201204111300 b/db/schema_migrations/20201204111300
new file mode 100644
index 00000000000..69a114bed98
--- /dev/null
+++ b/db/schema_migrations/20201204111300
@@ -0,0 +1 @@
+e1265a293640d0d067672cb0426987c4a308025cf5a15b17bac8e30267dc8eaf \ No newline at end of file
diff --git a/db/schema_migrations/20210105052034 b/db/schema_migrations/20210105052034
new file mode 100644
index 00000000000..d2c1eacddf6
--- /dev/null
+++ b/db/schema_migrations/20210105052034
@@ -0,0 +1 @@
+4eef64fb237f783cdb07e012356d48a4ec9afc349721de1c53cf3def95e83858 \ No newline at end of file
diff --git a/db/schema_migrations/20210105052229 b/db/schema_migrations/20210105052229
new file mode 100644
index 00000000000..19b7f359482
--- /dev/null
+++ b/db/schema_migrations/20210105052229
@@ -0,0 +1 @@
+ef994f0c65154825906fb0952b9b3073f4cb0692f01c90280edf06a4ea2ec339 \ No newline at end of file
diff --git a/db/schema_migrations/20210105153342 b/db/schema_migrations/20210105153342
new file mode 100644
index 00000000000..cb970b9b3cc
--- /dev/null
+++ b/db/schema_migrations/20210105153342
@@ -0,0 +1 @@
+7a252c5d76c1e71421c3aa3e01584cdeeec6a5002ba6ef0824674c64f92e2764 \ No newline at end of file
diff --git a/db/schema_migrations/20210105154321 b/db/schema_migrations/20210105154321
new file mode 100644
index 00000000000..2f7f2477526
--- /dev/null
+++ b/db/schema_migrations/20210105154321
@@ -0,0 +1 @@
+9327676097c49bb1a221d79dd351ad8c57a434f19e32f49951c0d6d655c2fa4e \ No newline at end of file
diff --git a/db/schema_migrations/20210106155209 b/db/schema_migrations/20210106155209
new file mode 100644
index 00000000000..10dde1cf874
--- /dev/null
+++ b/db/schema_migrations/20210106155209
@@ -0,0 +1 @@
+4aeff45663a9f5a41a8dd92298afb4b0b57aa6f190f4648455df2fa1e39e174f \ No newline at end of file
diff --git a/db/schema_migrations/20210107105306 b/db/schema_migrations/20210107105306
new file mode 100644
index 00000000000..fe66a041837
--- /dev/null
+++ b/db/schema_migrations/20210107105306
@@ -0,0 +1 @@
+f76ce27a82f4773dcda324d79cc93a044f21317dbb9fdff035879502b5752da3 \ No newline at end of file
diff --git a/db/schema_migrations/20210107154615 b/db/schema_migrations/20210107154615
new file mode 100644
index 00000000000..f8b6f97d3fe
--- /dev/null
+++ b/db/schema_migrations/20210107154615
@@ -0,0 +1 @@
+3e867ceefcab4f043b89d3c04e6e0a1182423039e1a9245e611128efe77c0e88 \ No newline at end of file
diff --git a/db/schema_migrations/20210111051045 b/db/schema_migrations/20210111051045
new file mode 100644
index 00000000000..842c164fc20
--- /dev/null
+++ b/db/schema_migrations/20210111051045
@@ -0,0 +1 @@
+6075e469081fcca124c0c4b485071a086545b502c398314cca05052765072caf \ No newline at end of file
diff --git a/db/schema_migrations/20210111053308 b/db/schema_migrations/20210111053308
new file mode 100644
index 00000000000..b7968a03c32
--- /dev/null
+++ b/db/schema_migrations/20210111053308
@@ -0,0 +1 @@
+a98ca25378df3fc798b6ae361b3a47b697f6b853796975221329db023cb98466 \ No newline at end of file
diff --git a/db/schema_migrations/20210111075104 b/db/schema_migrations/20210111075104
new file mode 100644
index 00000000000..f0d8f6da529
--- /dev/null
+++ b/db/schema_migrations/20210111075104
@@ -0,0 +1 @@
+3568bda1b43710880c8bfe2777d346aba1172217c27b5e690e7151aec9da2288 \ No newline at end of file
diff --git a/db/schema_migrations/20210111075105 b/db/schema_migrations/20210111075105
new file mode 100644
index 00000000000..d058560ead2
--- /dev/null
+++ b/db/schema_migrations/20210111075105
@@ -0,0 +1 @@
+d48f5e042f3f919041f0c93e6492bcf56c19f4268d4819bd231ddffe70ba7c6b \ No newline at end of file
diff --git a/db/schema_migrations/20210112202949 b/db/schema_migrations/20210112202949
new file mode 100644
index 00000000000..5926b701b1a
--- /dev/null
+++ b/db/schema_migrations/20210112202949
@@ -0,0 +1 @@
+56595e67e9e78a9558e6874d75bdcc295b89ab0096d1b37e4d9366e1574d241c \ No newline at end of file
diff --git a/db/schema_migrations/20210113224909 b/db/schema_migrations/20210113224909
new file mode 100644
index 00000000000..ab03538f520
--- /dev/null
+++ b/db/schema_migrations/20210113224909
@@ -0,0 +1 @@
+e6841491cd7d2cc015fd628f5c14270720d59cbb17b7efb160937963f074f5c2 \ No newline at end of file
diff --git a/db/schema_migrations/20210113231532 b/db/schema_migrations/20210113231532
new file mode 100644
index 00000000000..eb39ac161ba
--- /dev/null
+++ b/db/schema_migrations/20210113231532
@@ -0,0 +1 @@
+1a430ce6d137ee896cbd37bb822ccd18c9e87204b765b1192928dd82efb28602 \ No newline at end of file
diff --git a/db/schema_migrations/20210113231546 b/db/schema_migrations/20210113231546
new file mode 100644
index 00000000000..3286727b72c
--- /dev/null
+++ b/db/schema_migrations/20210113231546
@@ -0,0 +1 @@
+5d7bbf376acbf5679d111866e70b69eebba26a487a9e7d6bd571f15dc423e3e3 \ No newline at end of file
diff --git a/db/schema_migrations/20210114142443 b/db/schema_migrations/20210114142443
new file mode 100644
index 00000000000..d4e771a56f5
--- /dev/null
+++ b/db/schema_migrations/20210114142443
@@ -0,0 +1 @@
+7ef5cb1f167c133c67fc98c0abe929516ec700179747d3353d19cf8219ebd0ef \ No newline at end of file
diff --git a/db/schema_migrations/20210115090452 b/db/schema_migrations/20210115090452
new file mode 100644
index 00000000000..92c5574e71f
--- /dev/null
+++ b/db/schema_migrations/20210115090452
@@ -0,0 +1 @@
+5415850ae27c507fd8b1df20951e25b42352f4f9ec8e1402019533170edabdb8 \ No newline at end of file
diff --git a/db/schema_migrations/20210115220610 b/db/schema_migrations/20210115220610
new file mode 100644
index 00000000000..002c37e54ec
--- /dev/null
+++ b/db/schema_migrations/20210115220610
@@ -0,0 +1 @@
+541a6626d3afd4fd421fd59fe5eb8ab7764952ae780c83c3805fd4a29e3f42fb \ No newline at end of file
diff --git a/db/schema_migrations/20210117210226 b/db/schema_migrations/20210117210226
new file mode 100644
index 00000000000..a68f7f6d93e
--- /dev/null
+++ b/db/schema_migrations/20210117210226
@@ -0,0 +1 @@
+c0d22d00d52a516347930e1a36f350113c0949214925176f08ceed81999746bd \ No newline at end of file
diff --git a/db/schema_migrations/20210118111307 b/db/schema_migrations/20210118111307
new file mode 100644
index 00000000000..036d909f5ad
--- /dev/null
+++ b/db/schema_migrations/20210118111307
@@ -0,0 +1 @@
+f33cc3eebc9197db381d81150a140582e30905d3964d6fb444caad6c9eff1b31 \ No newline at end of file
diff --git a/db/schema_migrations/20210119122354 b/db/schema_migrations/20210119122354
new file mode 100644
index 00000000000..a17b2dab2df
--- /dev/null
+++ b/db/schema_migrations/20210119122354
@@ -0,0 +1 @@
+e8264993f6503268cd99e8ca26ccdc0e986f31a2818b9bbef2a9cef36191e686 \ No newline at end of file
diff --git a/db/schema_migrations/20210119162812 b/db/schema_migrations/20210119162812
new file mode 100644
index 00000000000..dfbf33a9fcf
--- /dev/null
+++ b/db/schema_migrations/20210119162812
@@ -0,0 +1 @@
+cd7643fc762d8b9236ef5ac7cc285ffbd29f1953178b9b6e129082efd7b9e07b \ No newline at end of file
diff --git a/db/schema_migrations/20210120221743 b/db/schema_migrations/20210120221743
new file mode 100644
index 00000000000..ce54788b86c
--- /dev/null
+++ b/db/schema_migrations/20210120221743
@@ -0,0 +1 @@
+4bf1d277affdfa9ee772d69cb713f49f257140fb58c40bc8659d563b4cc3de29 \ No newline at end of file
diff --git a/db/schema_migrations/20210121093618 b/db/schema_migrations/20210121093618
new file mode 100644
index 00000000000..f12566f1aa9
--- /dev/null
+++ b/db/schema_migrations/20210121093618
@@ -0,0 +1 @@
+e2be30f71b2a4a410b21e57ee53c3b54cf0214a08bc65cd92b2cb4b93bde9451 \ No newline at end of file
diff --git a/db/schema_migrations/20210122073805 b/db/schema_migrations/20210122073805
new file mode 100644
index 00000000000..322c90eb820
--- /dev/null
+++ b/db/schema_migrations/20210122073805
@@ -0,0 +1 @@
+f5231b1eec17ea1a67f2d2f4ca759314afb85b2c8fb431e3303d530d44bdb1ef \ No newline at end of file
diff --git a/db/schema_migrations/20210122153259 b/db/schema_migrations/20210122153259
new file mode 100644
index 00000000000..887f0ac4a5c
--- /dev/null
+++ b/db/schema_migrations/20210122153259
@@ -0,0 +1 @@
+4c697cc183a000ee8c18b516e4b1d77d0f8d2d3d7abe11121f2240a60c03216c \ No newline at end of file
diff --git a/db/schema_migrations/20210122155158 b/db/schema_migrations/20210122155158
new file mode 100644
index 00000000000..f521f910346
--- /dev/null
+++ b/db/schema_migrations/20210122155158
@@ -0,0 +1 @@
+5f326f101ff06993e9160b0486d24d615abd6d5027b375e422f776181ad8a193 \ No newline at end of file
diff --git a/db/schema_migrations/20210126030249 b/db/schema_migrations/20210126030249
new file mode 100644
index 00000000000..068f5eeb9c5
--- /dev/null
+++ b/db/schema_migrations/20210126030249
@@ -0,0 +1 @@
+b5c219d1b1443ddf482f26d8280a1c7318456affce3ad57a082eb8f9efc32206 \ No newline at end of file
diff --git a/db/schema_migrations/20210126091713 b/db/schema_migrations/20210126091713
new file mode 100644
index 00000000000..b75636bd437
--- /dev/null
+++ b/db/schema_migrations/20210126091713
@@ -0,0 +1 @@
+3906739d07514e6e59f79a4a81d28859a2481614a299c95ec1b1d9825a07ec64 \ No newline at end of file
diff --git a/db/schema_migrations/20210126092102 b/db/schema_migrations/20210126092102
new file mode 100644
index 00000000000..803643389f6
--- /dev/null
+++ b/db/schema_migrations/20210126092102
@@ -0,0 +1 @@
+124c5ae1a1ccade5dec01f72b726e03febc8f56411d7d8990f976bb2a9516037 \ No newline at end of file
diff --git a/db/schema_migrations/20210127052226 b/db/schema_migrations/20210127052226
new file mode 100644
index 00000000000..ca7d44edff8
--- /dev/null
+++ b/db/schema_migrations/20210127052226
@@ -0,0 +1 @@
+e978687e9b27db5288862ea85053f3fc04a8e841702b16ca17c01398a86654d0 \ No newline at end of file
diff --git a/db/schema_migrations/20210127143025 b/db/schema_migrations/20210127143025
new file mode 100644
index 00000000000..a4875304c0b
--- /dev/null
+++ b/db/schema_migrations/20210127143025
@@ -0,0 +1 @@
+c173ba86340efe39977f1b319d1ebcead634e3bfe819a30e230fb4f81766f28a \ No newline at end of file
diff --git a/db/schema_migrations/20210128044930 b/db/schema_migrations/20210128044930
new file mode 100644
index 00000000000..4965cd9a9c6
--- /dev/null
+++ b/db/schema_migrations/20210128044930
@@ -0,0 +1 @@
+6164ef91c60bd614310cbda6ad8ab1a205cae17c4d037fafa89eaf95d06323e4 \ No newline at end of file
diff --git a/db/schema_migrations/20210128114526 b/db/schema_migrations/20210128114526
new file mode 100644
index 00000000000..107c86913ba
--- /dev/null
+++ b/db/schema_migrations/20210128114526
@@ -0,0 +1 @@
+ad83205a0203427ccad1c25933e28cf13ebfb0274865ce5f0f2d578e84bb07a3 \ No newline at end of file
diff --git a/db/schema_migrations/20210128140157 b/db/schema_migrations/20210128140157
new file mode 100644
index 00000000000..2b71db39920
--- /dev/null
+++ b/db/schema_migrations/20210128140157
@@ -0,0 +1 @@
+0fa84b2038f33e27e549bdb3eb137e1813f604b6e81abc67a49a54d3e1e4bcf5 \ No newline at end of file
diff --git a/db/schema_migrations/20210128140232 b/db/schema_migrations/20210128140232
new file mode 100644
index 00000000000..ee335323fce
--- /dev/null
+++ b/db/schema_migrations/20210128140232
@@ -0,0 +1 @@
+93f337364eb5ca5c67f4d4767d1aee9972bfe0596c89f006317dd6103558e35c \ No newline at end of file
diff --git a/db/schema_migrations/20210129225244 b/db/schema_migrations/20210129225244
new file mode 100644
index 00000000000..1b05096b07f
--- /dev/null
+++ b/db/schema_migrations/20210129225244
@@ -0,0 +1 @@
+6cb54c71a9835ec1b3cf801a19c2cd385d224e0438c7924b6a29d298ecebe8a7 \ No newline at end of file
diff --git a/db/schema_migrations/20210201140434 b/db/schema_migrations/20210201140434
new file mode 100644
index 00000000000..00671276b1c
--- /dev/null
+++ b/db/schema_migrations/20210201140434
@@ -0,0 +1 @@
+71220cfc36215f6c22d22d1fb0b74389e90c58733214b5fa36dcb8da0377a120 \ No newline at end of file
diff --git a/db/schema_migrations/20210203002331 b/db/schema_migrations/20210203002331
new file mode 100644
index 00000000000..f1ed6bf23f6
--- /dev/null
+++ b/db/schema_migrations/20210203002331
@@ -0,0 +1 @@
+b8a19b2ebf648a1b79a488a7a2847f6a392e594464c1ba0ae96f274f583559e3 \ No newline at end of file
diff --git a/db/schema_migrations/20210203092540 b/db/schema_migrations/20210203092540
new file mode 100644
index 00000000000..12367417d44
--- /dev/null
+++ b/db/schema_migrations/20210203092540
@@ -0,0 +1 @@
+fa0b69df96069dd29971f69a51ce4eb691480904c5693fa480f6daa83b042e77 \ No newline at end of file
diff --git a/db/schema_migrations/20210203092549 b/db/schema_migrations/20210203092549
new file mode 100644
index 00000000000..967b0d3acc7
--- /dev/null
+++ b/db/schema_migrations/20210203092549
@@ -0,0 +1 @@
+096d13548e156a13b9ccdbb39ed83b3be7ef64a57df5daea2e3cd870f3e2b448 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index de4218ed405..16abc737975 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -10,6 +10,26 @@ CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
+CREATE FUNCTION set_has_external_issue_tracker() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+UPDATE projects SET has_external_issue_tracker = (
+ EXISTS
+ (
+ SELECT 1
+ FROM services
+ WHERE project_id = COALESCE(NEW.project_id, OLD.project_id)
+ AND active = TRUE
+ AND category = 'issue_tracker'
+ )
+)
+WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id);
+RETURN NULL;
+
+END
+$$;
+
CREATE FUNCTION set_has_external_wiki() RETURNS trigger
LANGUAGE plpgsql
AS $$
@@ -9273,7 +9293,6 @@ CREATE TABLE application_settings (
instance_administration_project_id bigint,
asset_proxy_enabled boolean DEFAULT false NOT NULL,
asset_proxy_url character varying,
- asset_proxy_whitelist text,
encrypted_asset_proxy_secret_key text,
encrypted_asset_proxy_secret_key_iv character varying,
static_objects_external_storage_url character varying(255),
@@ -9390,6 +9409,9 @@ CREATE TABLE application_settings (
rate_limiting_response_text text,
invisible_captcha_enabled boolean DEFAULT false NOT NULL,
container_registry_cleanup_tags_service_max_list_size integer DEFAULT 200 NOT NULL,
+ enforce_ssh_key_expiration boolean DEFAULT false NOT NULL,
+ git_two_factor_session_expiry integer DEFAULT 15 NOT NULL,
+ asset_proxy_allowlist text,
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
CONSTRAINT check_17d9558205 CHECK ((char_length((kroki_url)::text) <= 1024)),
@@ -10054,8 +10076,10 @@ CREATE TABLE bulk_import_failures (
exception_class text NOT NULL,
exception_message text NOT NULL,
correlation_id_value text,
+ pipeline_step text,
CONSTRAINT check_053d65c7a4 CHECK ((char_length(pipeline_class) <= 255)),
CONSTRAINT check_6eca8f972e CHECK ((char_length(exception_message) <= 255)),
+ CONSTRAINT check_721a422375 CHECK ((char_length(pipeline_step) <= 255)),
CONSTRAINT check_c7dba8398e CHECK ((char_length(exception_class) <= 255)),
CONSTRAINT check_e787285882 CHECK ((char_length(correlation_id_value) <= 255))
);
@@ -11437,9 +11461,11 @@ CREATE TABLE compliance_management_frameworks (
color text NOT NULL,
namespace_id integer NOT NULL,
regulated boolean DEFAULT true NOT NULL,
+ pipeline_configuration_full_path text,
CONSTRAINT check_08cd34b2c2 CHECK ((char_length(color) <= 10)),
CONSTRAINT check_1617e0b87e CHECK ((char_length(description) <= 255)),
- CONSTRAINT check_ab00bc2193 CHECK ((char_length(name) <= 255))
+ CONSTRAINT check_ab00bc2193 CHECK ((char_length(name) <= 255)),
+ CONSTRAINT check_e7a9972435 CHECK ((char_length(pipeline_configuration_full_path) <= 255))
);
CREATE SEQUENCE compliance_management_frameworks_id_seq
@@ -11569,6 +11595,30 @@ CREATE SEQUENCE custom_emoji_id_seq
ALTER SEQUENCE custom_emoji_id_seq OWNED BY custom_emoji.id;
+CREATE TABLE dast_profiles (
+ id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ dast_site_profile_id bigint NOT NULL,
+ dast_scanner_profile_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ name text NOT NULL,
+ description text NOT NULL,
+ CONSTRAINT check_5fcf73bf61 CHECK ((char_length(name) <= 255)),
+ CONSTRAINT check_c34e505c24 CHECK ((char_length(description) <= 255))
+);
+
+COMMENT ON TABLE dast_profiles IS '{"owner":"group::dynamic analysis","description":"Profile used to run a DAST on-demand scan"}';
+
+CREATE SEQUENCE dast_profiles_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE dast_profiles_id_seq OWNED BY dast_profiles.id;
+
CREATE TABLE dast_scanner_profiles (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -11725,7 +11775,9 @@ CREATE TABLE dependency_proxy_manifests (
file_name text NOT NULL,
file text NOT NULL,
digest text NOT NULL,
+ content_type text,
CONSTRAINT check_079b293a7b CHECK ((char_length(file) <= 255)),
+ CONSTRAINT check_167a9a8a91 CHECK ((char_length(content_type) <= 255)),
CONSTRAINT check_c579e3f586 CHECK ((char_length(file_name) <= 255)),
CONSTRAINT check_f5d9996bf1 CHECK ((char_length(digest) <= 255))
);
@@ -12057,7 +12109,8 @@ CREATE TABLE environments (
environment_type character varying,
state character varying DEFAULT 'available'::character varying NOT NULL,
slug character varying NOT NULL,
- auto_stop_at timestamp with time zone
+ auto_stop_at timestamp with time zone,
+ auto_delete_at timestamp with time zone
);
CREATE SEQUENCE environments_id_seq
@@ -12215,6 +12268,8 @@ CREATE TABLE experiment_subjects (
variant smallint DEFAULT 0 NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
+ converted_at timestamp with time zone,
+ context jsonb DEFAULT '{}'::jsonb NOT NULL,
CONSTRAINT chk_has_one_subject CHECK ((num_nonnulls(user_id, group_id, project_id) = 1))
);
@@ -12998,6 +13053,27 @@ CREATE TABLE group_merge_request_approval_settings (
allow_author_approval boolean DEFAULT false NOT NULL
);
+CREATE TABLE group_repository_storage_moves (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ group_id bigint NOT NULL,
+ state smallint DEFAULT 1 NOT NULL,
+ source_storage_name text NOT NULL,
+ destination_storage_name text NOT NULL,
+ CONSTRAINT group_repository_storage_moves_destination_storage_name CHECK ((char_length(destination_storage_name) <= 255)),
+ CONSTRAINT group_repository_storage_moves_source_storage_name CHECK ((char_length(source_storage_name) <= 255))
+);
+
+CREATE SEQUENCE group_repository_storage_moves_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE group_repository_storage_moves_id_seq OWNED BY group_repository_storage_moves.id;
+
CREATE TABLE group_wiki_repositories (
shard_id bigint NOT NULL,
group_id bigint NOT NULL,
@@ -13863,7 +13939,8 @@ CREATE TABLE merge_request_context_commits (
committer_name text,
committer_email text,
message text,
- merge_request_id bigint
+ merge_request_id bigint,
+ trailers jsonb DEFAULT '{}'::jsonb NOT NULL
);
CREATE SEQUENCE merge_request_context_commits_id_seq
@@ -13885,7 +13962,8 @@ CREATE TABLE merge_request_diff_commits (
author_email text,
committer_name text,
committer_email text,
- message text
+ message text,
+ trailers jsonb DEFAULT '{}'::jsonb NOT NULL
);
CREATE TABLE merge_request_diff_details (
@@ -13940,6 +14018,7 @@ CREATE TABLE merge_request_diffs (
stored_externally boolean,
files_count smallint,
sorted boolean DEFAULT false NOT NULL,
+ diff_type smallint DEFAULT 1 NOT NULL,
CONSTRAINT check_93ee616ac9 CHECK ((external_diff_store IS NOT NULL))
);
@@ -13992,7 +14071,8 @@ CREATE TABLE merge_request_reviewers (
id bigint NOT NULL,
user_id bigint NOT NULL,
merge_request_id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL
+ created_at timestamp with time zone NOT NULL,
+ state smallint DEFAULT 0 NOT NULL
);
CREATE SEQUENCE merge_request_reviewers_id_seq
@@ -14241,6 +14321,7 @@ CREATE TABLE namespace_settings (
prevent_forking_outside_group boolean DEFAULT false NOT NULL,
allow_mfa_for_subgroups boolean DEFAULT true NOT NULL,
default_branch_name text,
+ repository_read_only boolean DEFAULT false NOT NULL,
CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255))
);
@@ -14709,6 +14790,27 @@ CREATE SEQUENCE packages_build_infos_id_seq
ALTER SEQUENCE packages_build_infos_id_seq OWNED BY packages_build_infos.id;
+CREATE TABLE packages_composer_cache_files (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ delete_at timestamp with time zone,
+ namespace_id integer,
+ file_store smallint DEFAULT 1 NOT NULL,
+ file text NOT NULL,
+ file_sha256 bytea NOT NULL,
+ CONSTRAINT check_84f5ba81f5 CHECK ((char_length(file) <= 255))
+);
+
+CREATE SEQUENCE packages_composer_cache_files_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE packages_composer_cache_files_id_seq OWNED BY packages_composer_cache_files.id;
+
CREATE TABLE packages_composer_metadata (
package_id bigint NOT NULL,
target_sha bytea NOT NULL,
@@ -14784,6 +14886,24 @@ CREATE SEQUENCE packages_debian_group_architectures_id_seq
ALTER SEQUENCE packages_debian_group_architectures_id_seq OWNED BY packages_debian_group_architectures.id;
+CREATE TABLE packages_debian_group_components (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ distribution_id bigint NOT NULL,
+ name text NOT NULL,
+ CONSTRAINT check_a9bc7d85be CHECK ((char_length(name) <= 255))
+);
+
+CREATE SEQUENCE packages_debian_group_components_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE packages_debian_group_components_id_seq OWNED BY packages_debian_group_components.id;
+
CREATE TABLE packages_debian_group_distributions (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -14843,6 +14963,24 @@ CREATE SEQUENCE packages_debian_project_architectures_id_seq
ALTER SEQUENCE packages_debian_project_architectures_id_seq OWNED BY packages_debian_project_architectures.id;
+CREATE TABLE packages_debian_project_components (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ distribution_id bigint NOT NULL,
+ name text NOT NULL,
+ CONSTRAINT check_517559f298 CHECK ((char_length(name) <= 255))
+);
+
+CREATE SEQUENCE packages_debian_project_components_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE packages_debian_project_components_id_seq OWNED BY packages_debian_project_components.id;
+
CREATE TABLE packages_debian_project_distributions (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -15701,7 +15839,8 @@ CREATE TABLE project_features (
metrics_dashboard_access_level integer,
requirements_access_level integer DEFAULT 20 NOT NULL,
operations_access_level integer DEFAULT 20 NOT NULL,
- analytics_access_level integer DEFAULT 20 NOT NULL
+ analytics_access_level integer DEFAULT 20 NOT NULL,
+ security_and_compliance_access_level integer DEFAULT 10 NOT NULL
);
CREATE SEQUENCE project_features_id_seq
@@ -17326,6 +17465,22 @@ CREATE SEQUENCE todos_id_seq
ALTER SEQUENCE todos_id_seq OWNED BY todos.id;
+CREATE TABLE token_with_ivs (
+ id bigint NOT NULL,
+ hashed_token bytea NOT NULL,
+ hashed_plaintext_token bytea NOT NULL,
+ iv bytea NOT NULL
+);
+
+CREATE SEQUENCE token_with_ivs_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE token_with_ivs_id_seq OWNED BY token_with_ivs.id;
+
CREATE TABLE trending_projects (
id integer NOT NULL,
project_id integer NOT NULL
@@ -18009,7 +18164,16 @@ CREATE TABLE vulnerability_occurrences (
metadata_version character varying NOT NULL,
raw_metadata text NOT NULL,
vulnerability_id bigint,
- details jsonb DEFAULT '{}'::jsonb NOT NULL
+ details jsonb DEFAULT '{}'::jsonb NOT NULL,
+ description text,
+ message text,
+ solution text,
+ cve text,
+ location jsonb,
+ CONSTRAINT check_4a3a60f2ba CHECK ((char_length(solution) <= 7000)),
+ CONSTRAINT check_ade261da6b CHECK ((char_length(description) <= 15000)),
+ CONSTRAINT check_df6dd20219 CHECK ((char_length(message) <= 3000)),
+ CONSTRAINT check_f602da68dd CHECK ((char_length(cve) <= 48400))
);
CREATE SEQUENCE vulnerability_occurrences_id_seq
@@ -18159,7 +18323,8 @@ CREATE TABLE web_hooks (
deployment_events boolean DEFAULT false NOT NULL,
releases_events boolean DEFAULT false NOT NULL,
feature_flag_events boolean DEFAULT false NOT NULL,
- member_events boolean DEFAULT false NOT NULL
+ member_events boolean DEFAULT false NOT NULL,
+ subgroup_events boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE web_hooks_id_seq
@@ -18542,6 +18707,8 @@ ALTER TABLE ONLY csv_issue_imports ALTER COLUMN id SET DEFAULT nextval('csv_issu
ALTER TABLE ONLY custom_emoji ALTER COLUMN id SET DEFAULT nextval('custom_emoji_id_seq'::regclass);
+ALTER TABLE ONLY dast_profiles ALTER COLUMN id SET DEFAULT nextval('dast_profiles_id_seq'::regclass);
+
ALTER TABLE ONLY dast_scanner_profiles ALTER COLUMN id SET DEFAULT nextval('dast_scanner_profiles_id_seq'::regclass);
ALTER TABLE ONLY dast_site_profiles ALTER COLUMN id SET DEFAULT nextval('dast_site_profiles_id_seq'::regclass);
@@ -18674,6 +18841,8 @@ ALTER TABLE ONLY group_group_links ALTER COLUMN id SET DEFAULT nextval('group_gr
ALTER TABLE ONLY group_import_states ALTER COLUMN group_id SET DEFAULT nextval('group_import_states_group_id_seq'::regclass);
+ALTER TABLE ONLY group_repository_storage_moves ALTER COLUMN id SET DEFAULT nextval('group_repository_storage_moves_id_seq'::regclass);
+
ALTER TABLE ONLY historical_data ALTER COLUMN id SET DEFAULT nextval('historical_data_id_seq'::regclass);
ALTER TABLE ONLY identities ALTER COLUMN id SET DEFAULT nextval('identities_id_seq'::regclass);
@@ -18820,16 +18989,22 @@ ALTER TABLE ONLY operations_user_lists ALTER COLUMN id SET DEFAULT nextval('oper
ALTER TABLE ONLY packages_build_infos ALTER COLUMN id SET DEFAULT nextval('packages_build_infos_id_seq'::regclass);
+ALTER TABLE ONLY packages_composer_cache_files ALTER COLUMN id SET DEFAULT nextval('packages_composer_cache_files_id_seq'::regclass);
+
ALTER TABLE ONLY packages_conan_file_metadata ALTER COLUMN id SET DEFAULT nextval('packages_conan_file_metadata_id_seq'::regclass);
ALTER TABLE ONLY packages_conan_metadata ALTER COLUMN id SET DEFAULT nextval('packages_conan_metadata_id_seq'::regclass);
ALTER TABLE ONLY packages_debian_group_architectures ALTER COLUMN id SET DEFAULT nextval('packages_debian_group_architectures_id_seq'::regclass);
+ALTER TABLE ONLY packages_debian_group_components ALTER COLUMN id SET DEFAULT nextval('packages_debian_group_components_id_seq'::regclass);
+
ALTER TABLE ONLY packages_debian_group_distributions ALTER COLUMN id SET DEFAULT nextval('packages_debian_group_distributions_id_seq'::regclass);
ALTER TABLE ONLY packages_debian_project_architectures ALTER COLUMN id SET DEFAULT nextval('packages_debian_project_architectures_id_seq'::regclass);
+ALTER TABLE ONLY packages_debian_project_components ALTER COLUMN id SET DEFAULT nextval('packages_debian_project_components_id_seq'::regclass);
+
ALTER TABLE ONLY packages_debian_project_distributions ALTER COLUMN id SET DEFAULT nextval('packages_debian_project_distributions_id_seq'::regclass);
ALTER TABLE ONLY packages_dependencies ALTER COLUMN id SET DEFAULT nextval('packages_dependencies_id_seq'::regclass);
@@ -19030,6 +19205,8 @@ ALTER TABLE ONLY timelogs ALTER COLUMN id SET DEFAULT nextval('timelogs_id_seq':
ALTER TABLE ONLY todos ALTER COLUMN id SET DEFAULT nextval('todos_id_seq'::regclass);
+ALTER TABLE ONLY token_with_ivs ALTER COLUMN id SET DEFAULT nextval('token_with_ivs_id_seq'::regclass);
+
ALTER TABLE ONLY trending_projects ALTER COLUMN id SET DEFAULT nextval('trending_projects_id_seq'::regclass);
ALTER TABLE ONLY u2f_registrations ALTER COLUMN id SET DEFAULT nextval('u2f_registrations_id_seq'::regclass);
@@ -19691,6 +19868,9 @@ ALTER TABLE ONLY csv_issue_imports
ALTER TABLE ONLY custom_emoji
ADD CONSTRAINT custom_emoji_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY dast_profiles
+ ADD CONSTRAINT dast_profiles_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY dast_scanner_profiles
ADD CONSTRAINT dast_scanner_profiles_pkey PRIMARY KEY (id);
@@ -19907,6 +20087,9 @@ ALTER TABLE ONLY group_import_states
ALTER TABLE ONLY group_merge_request_approval_settings
ADD CONSTRAINT group_merge_request_approval_settings_pkey PRIMARY KEY (group_id);
+ALTER TABLE ONLY group_repository_storage_moves
+ ADD CONSTRAINT group_repository_storage_moves_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY group_wiki_repositories
ADD CONSTRAINT group_wiki_repositories_pkey PRIMARY KEY (group_id);
@@ -20174,6 +20357,9 @@ ALTER TABLE ONLY operations_user_lists
ALTER TABLE ONLY packages_build_infos
ADD CONSTRAINT packages_build_infos_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY packages_composer_cache_files
+ ADD CONSTRAINT packages_composer_cache_files_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY packages_composer_metadata
ADD CONSTRAINT packages_composer_metadata_pkey PRIMARY KEY (package_id);
@@ -20189,12 +20375,18 @@ ALTER TABLE ONLY packages_debian_file_metadata
ALTER TABLE ONLY packages_debian_group_architectures
ADD CONSTRAINT packages_debian_group_architectures_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY packages_debian_group_components
+ ADD CONSTRAINT packages_debian_group_components_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY packages_debian_group_distributions
ADD CONSTRAINT packages_debian_group_distributions_pkey PRIMARY KEY (id);
ALTER TABLE ONLY packages_debian_project_architectures
ADD CONSTRAINT packages_debian_project_architectures_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY packages_debian_project_components
+ ADD CONSTRAINT packages_debian_project_components_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY packages_debian_project_distributions
ADD CONSTRAINT packages_debian_project_distributions_pkey PRIMARY KEY (id);
@@ -20546,6 +20738,9 @@ ALTER TABLE ONLY timelogs
ALTER TABLE ONLY todos
ADD CONSTRAINT todos_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY token_with_ivs
+ ADD CONSTRAINT token_with_ivs_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY trending_projects
ADD CONSTRAINT trending_projects_pkey PRIMARY KEY (id);
@@ -20830,8 +21025,6 @@ CREATE INDEX backup_labels_group_id_title_idx ON backup_labels USING btree (grou
CREATE INDEX backup_labels_project_id_idx ON backup_labels USING btree (project_id);
-CREATE UNIQUE INDEX backup_labels_project_id_title_idx ON backup_labels USING btree (project_id, title) WHERE (group_id = NULL::integer);
-
CREATE INDEX backup_labels_template_idx ON backup_labels USING btree (template) WHERE template;
CREATE INDEX backup_labels_title_idx ON backup_labels USING btree (title);
@@ -20854,7 +21047,7 @@ CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_and_note_id_index ON epic_user
CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_index ON epic_user_mentions USING btree (epic_id) WHERE (note_id IS NULL);
-CREATE INDEX expired_artifacts_temp_index ON ci_job_artifacts USING btree (id, created_at) WHERE ((expire_at IS NULL) AND (created_at < '2020-06-22 00:00:00+00'::timestamp with time zone));
+CREATE INDEX expired_artifacts_temp_index ON ci_job_artifacts USING btree (id, created_at) WHERE ((expire_at IS NULL) AND (date(timezone('UTC'::text, created_at)) < '2020-06-22'::date));
CREATE INDEX finding_links_on_vulnerability_occurrence_id ON vulnerability_finding_links USING btree (vulnerability_occurrence_id);
@@ -21514,6 +21707,12 @@ CREATE UNIQUE INDEX index_custom_emoji_on_namespace_id_and_name ON custom_emoji
CREATE UNIQUE INDEX index_daily_build_group_report_results_unique_columns ON ci_daily_build_group_report_results USING btree (project_id, ref_path, date, group_name);
+CREATE INDEX index_dast_profiles_on_dast_scanner_profile_id ON dast_profiles USING btree (dast_scanner_profile_id);
+
+CREATE INDEX index_dast_profiles_on_dast_site_profile_id ON dast_profiles USING btree (dast_site_profile_id);
+
+CREATE UNIQUE INDEX index_dast_profiles_on_project_id_and_name ON dast_profiles USING btree (project_id, name);
+
CREATE UNIQUE INDEX index_dast_scanner_profiles_on_project_id_and_name ON dast_scanner_profiles USING btree (project_id, name);
CREATE INDEX index_dast_site_profiles_on_dast_site_id ON dast_site_profiles USING btree (dast_site_id);
@@ -21882,6 +22081,8 @@ CREATE INDEX index_group_import_states_on_group_id ON group_import_states USING
CREATE INDEX index_group_import_states_on_user_id ON group_import_states USING btree (user_id) WHERE (user_id IS NOT NULL);
+CREATE INDEX index_group_repository_storage_moves_on_group_id ON group_repository_storage_moves USING btree (group_id);
+
CREATE UNIQUE INDEX index_group_stages_on_group_id_group_value_stream_id_and_name ON analytics_cycle_analytics_group_stages USING btree (group_id, group_value_stream_id, name);
CREATE UNIQUE INDEX index_group_wiki_repositories_on_disk_path ON group_wiki_repositories USING btree (disk_path);
@@ -21926,8 +22127,6 @@ CREATE INDEX index_incident_management_oncall_schedules_on_project_id ON inciden
CREATE INDEX index_incident_management_oncall_shifts_on_participant_id ON incident_management_oncall_shifts USING btree (participant_id);
-CREATE INDEX index_incident_management_oncall_shifts_on_rotation_id ON incident_management_oncall_shifts USING btree (rotation_id);
-
CREATE UNIQUE INDEX index_index_statuses_on_project_id ON index_statuses USING btree (project_id);
CREATE INDEX index_insights_on_namespace_id ON insights USING btree (namespace_id);
@@ -22122,6 +22321,8 @@ CREATE INDEX index_merge_request_diffs_on_external_diff_store ON merge_request_d
CREATE INDEX index_merge_request_diffs_on_merge_request_id_and_id ON merge_request_diffs USING btree (merge_request_id, id);
+CREATE UNIQUE INDEX index_merge_request_diffs_on_unique_merge_request_id ON merge_request_diffs USING btree (merge_request_id) WHERE (diff_type = 2);
+
CREATE INDEX index_merge_request_metrics_on_first_deployed_to_production_at ON merge_request_metrics USING btree (first_deployed_to_production_at);
CREATE INDEX index_merge_request_metrics_on_latest_closed_at ON merge_request_metrics USING btree (latest_closed_at) WHERE (latest_closed_at IS NOT NULL);
@@ -22334,6 +22535,10 @@ CREATE UNIQUE INDEX index_on_instance_statistics_recorded_at_and_identifier ON a
CREATE INDEX index_on_label_links_all_columns ON label_links USING btree (target_id, label_id, target_type);
+CREATE INDEX index_on_merge_requests_for_latest_diffs ON merge_requests USING btree (target_project_id) INCLUDE (id, latest_merge_request_diff_id);
+
+COMMENT ON INDEX index_on_merge_requests_for_latest_diffs IS 'Index used to efficiently obtain the oldest merge request for a commit SHA';
+
CREATE INDEX index_on_namespaces_lower_name ON namespaces USING btree (lower((name)::text));
CREATE INDEX index_on_namespaces_lower_path ON namespaces USING btree (lower((path)::text));
@@ -22358,8 +22563,18 @@ CREATE INDEX index_on_users_lower_username ON users USING btree (lower((username
CREATE INDEX index_on_users_name_lower ON users USING btree (lower((name)::text));
+CREATE INDEX index_onboarding_progresses_for_create_track ON onboarding_progresses USING btree (created_at) WHERE (git_write_at IS NULL);
+
+CREATE INDEX index_onboarding_progresses_for_team_track ON onboarding_progresses USING btree (GREATEST(git_write_at, pipeline_created_at, trial_started_at)) WHERE ((git_write_at IS NOT NULL) AND (pipeline_created_at IS NOT NULL) AND (trial_started_at IS NOT NULL) AND (user_added_at IS NULL));
+
+CREATE INDEX index_onboarding_progresses_for_trial_track ON onboarding_progresses USING btree (GREATEST(git_write_at, pipeline_created_at)) WHERE ((git_write_at IS NOT NULL) AND (pipeline_created_at IS NOT NULL) AND (trial_started_at IS NULL));
+
+CREATE INDEX index_onboarding_progresses_for_verify_track ON onboarding_progresses USING btree (git_write_at) WHERE ((git_write_at IS NOT NULL) AND (pipeline_created_at IS NULL));
+
CREATE UNIQUE INDEX index_onboarding_progresses_on_namespace_id ON onboarding_progresses USING btree (namespace_id);
+CREATE INDEX index_oncall_shifts_on_rotation_id_and_starts_at_and_ends_at ON incident_management_oncall_shifts USING btree (rotation_id, starts_at, ends_at);
+
CREATE INDEX index_open_project_tracker_data_on_service_id ON open_project_tracker_data USING btree (service_id);
CREATE INDEX index_operations_feature_flags_issues_on_issue_id ON operations_feature_flags_issues USING btree (issue_id);
@@ -22384,6 +22599,8 @@ CREATE UNIQUE INDEX index_ops_strategies_user_lists_on_strategy_id_and_user_list
CREATE INDEX index_packages_build_infos_on_pipeline_id ON packages_build_infos USING btree (pipeline_id);
+CREATE UNIQUE INDEX index_packages_composer_cache_namespace_and_sha ON packages_composer_cache_files USING btree (namespace_id, file_sha256);
+
CREATE UNIQUE INDEX index_packages_composer_metadata_on_package_id_and_target_sha ON packages_composer_metadata USING btree (package_id, target_sha);
CREATE UNIQUE INDEX index_packages_conan_file_metadata_on_package_file_id ON packages_conan_file_metadata USING btree (package_file_id);
@@ -22884,6 +23101,8 @@ CREATE INDEX index_security_findings_on_severity ON security_findings USING btre
CREATE UNIQUE INDEX index_security_findings_on_uuid_and_scan_id ON security_findings USING btree (uuid, scan_id);
+CREATE INDEX index_security_scans_on_date_created_at_and_id ON security_scans USING btree (date(timezone('UTC'::text, created_at)), id);
+
CREATE INDEX index_self_managed_prometheus_alert_events_on_environment_id ON self_managed_prometheus_alert_events USING btree (environment_id);
CREATE INDEX index_sent_notifications_on_noteable_type_noteable_id ON sent_notifications USING btree (noteable_id) WHERE ((noteable_type)::text = 'Issue'::text);
@@ -22902,7 +23121,7 @@ CREATE INDEX index_service_desk_enabled_projects_on_id_creator_id_created_at ON
CREATE INDEX index_services_on_inherit_from_id ON services USING btree (inherit_from_id);
-CREATE INDEX index_services_on_project_id_and_type ON services USING btree (project_id, type);
+CREATE UNIQUE INDEX index_services_on_project_id_and_type_unique ON services USING btree (project_id, type);
CREATE INDEX index_services_on_template ON services USING btree (template);
@@ -23058,6 +23277,10 @@ CREATE INDEX index_todos_on_user_id_and_id_done ON todos USING btree (user_id, i
CREATE INDEX index_todos_on_user_id_and_id_pending ON todos USING btree (user_id, id) WHERE ((state)::text = 'pending'::text);
+CREATE UNIQUE INDEX index_token_with_ivs_on_hashed_plaintext_token ON token_with_ivs USING btree (hashed_plaintext_token);
+
+CREATE UNIQUE INDEX index_token_with_ivs_on_hashed_token ON token_with_ivs USING btree (hashed_token);
+
CREATE UNIQUE INDEX index_trending_projects_on_project_id ON trending_projects USING btree (project_id);
CREATE INDEX index_u2f_registrations_on_key_handle ON u2f_registrations USING btree (key_handle);
@@ -23348,14 +23571,20 @@ CREATE INDEX temporary_index_vulnerabilities_on_id ON vulnerabilities USING btre
CREATE UNIQUE INDEX term_agreements_unique_index ON term_agreements USING btree (user_id, term_id);
-CREATE INDEX tmp_index_oauth_applications_on_id_where_trusted ON oauth_applications USING btree (id) WHERE (trusted = true);
+CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occurrences USING btree (project_id, report_type, location_fingerprint, primary_identifier_id, id);
+
+CREATE INDEX tmp_index_on_security_findings_scan_id ON security_findings USING btree (scan_id) WHERE (uuid IS NULL);
CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2);
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name);
+CREATE UNIQUE INDEX uniq_pkgs_deb_grp_components_on_distribution_id_and_name ON packages_debian_group_components USING btree (distribution_id, name);
+
CREATE UNIQUE INDEX uniq_pkgs_deb_proj_architectures_on_distribution_id_and_name ON packages_debian_project_architectures USING btree (distribution_id, name);
+CREATE UNIQUE INDEX uniq_pkgs_deb_proj_components_on_distribution_id_and_name ON packages_debian_project_components USING btree (distribution_id, name);
+
CREATE UNIQUE INDEX uniq_pkgs_debian_group_distributions_group_id_and_codename ON packages_debian_group_distributions USING btree (group_id, codename);
CREATE UNIQUE INDEX uniq_pkgs_debian_group_distributions_group_id_and_suite ON packages_debian_group_distributions USING btree (group_id, suite);
@@ -23628,6 +23857,12 @@ ALTER INDEX product_analytics_events_experimental_pkey ATTACH PARTITION gitlab_p
CREATE TRIGGER table_sync_trigger_ee39a25f9d AFTER INSERT OR DELETE OR UPDATE ON audit_events FOR EACH ROW EXECUTE PROCEDURE table_sync_function_2be879775d();
+CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON services FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker();
+
+CREATE TRIGGER trigger_has_external_issue_tracker_on_insert AFTER INSERT ON services FOR EACH ROW WHEN ((((new.category)::text = 'issue_tracker'::text) AND (new.active = true) AND (new.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker();
+
+CREATE TRIGGER trigger_has_external_issue_tracker_on_update AFTER UPDATE ON services FOR EACH ROW WHEN ((((new.category)::text = 'issue_tracker'::text) AND (old.active <> new.active) AND (new.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker();
+
CREATE TRIGGER trigger_has_external_wiki_on_delete AFTER DELETE ON services FOR EACH ROW WHEN ((((old.type)::text = 'ExternalWikiService'::text) AND (old.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_wiki();
CREATE TRIGGER trigger_has_external_wiki_on_insert AFTER INSERT ON services FOR EACH ROW WHEN (((new.active = true) AND ((new.type)::text = 'ExternalWikiService'::text) AND (new.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_wiki();
@@ -24057,6 +24292,9 @@ ALTER TABLE ONLY merge_requests
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_aa5798e761 FOREIGN KEY (closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY dast_profiles
+ ADD CONSTRAINT fk_aa76ef30e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY alert_management_alerts
ADD CONSTRAINT fk_aad61aedca FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL;
@@ -24531,6 +24769,9 @@ ALTER TABLE ONLY service_desk_settings
ALTER TABLE ONLY saml_group_links
ADD CONSTRAINT fk_rails_22e312c530 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY dast_profiles
+ ADD CONSTRAINT fk_rails_23cae5abe1 FOREIGN KEY (dast_scanner_profile_id) REFERENCES dast_scanner_profiles(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY group_custom_attributes
ADD CONSTRAINT fk_rails_246e0db83a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -25176,6 +25417,9 @@ ALTER TABLE ONLY packages_pypi_metadata
ALTER TABLE ONLY packages_dependency_links
ADD CONSTRAINT fk_rails_96ef1c00d3 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
+ALTER TABLE ONLY group_repository_storage_moves
+ ADD CONSTRAINT fk_rails_982bb5daf1 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY resource_label_events
ADD CONSTRAINT fk_rails_9851a00031 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
@@ -25200,6 +25444,9 @@ ALTER TABLE ONLY users_ops_dashboard_projects
ALTER TABLE ONLY project_incident_management_settings
ADD CONSTRAINT fk_rails_9c2ea1b7dd FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY packages_debian_project_components
+ ADD CONSTRAINT fk_rails_9d072b5073 FOREIGN KEY (distribution_id) REFERENCES packages_debian_project_distributions(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY gpg_keys
ADD CONSTRAINT fk_rails_9d1f5d8719 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -25341,6 +25588,9 @@ ALTER TABLE ONLY namespace_aggregation_schedules
ALTER TABLE ONLY approval_project_rules_protected_branches
ADD CONSTRAINT fk_rails_b7567b031b FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE;
+ALTER TABLE ONLY packages_composer_cache_files
+ ADD CONSTRAINT fk_rails_b82cea43a0 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY alerts_service_data
ADD CONSTRAINT fk_rails_b93215a42c FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE;
@@ -25605,6 +25855,9 @@ ALTER TABLE ONLY alert_management_alert_user_mentions
ALTER TABLE ONLY snippet_statistics
ADD CONSTRAINT fk_rails_ebc283ccf1 FOREIGN KEY (snippet_id) REFERENCES snippets(id) ON DELETE CASCADE;
+ALTER TABLE ONLY dast_profiles
+ ADD CONSTRAINT fk_rails_ed1e66fbbf FOREIGN KEY (dast_site_profile_id) REFERENCES dast_site_profiles(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY project_security_settings
ADD CONSTRAINT fk_rails_ed4abe1338 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -25659,6 +25912,9 @@ ALTER TABLE ONLY board_group_recent_visits
ALTER TABLE ONLY resource_state_events
ADD CONSTRAINT fk_rails_f5827a7ccd FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY packages_debian_group_components
+ ADD CONSTRAINT fk_rails_f5f1ef54c6 FOREIGN KEY (distribution_id) REFERENCES packages_debian_group_distributions(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY incident_management_oncall_shifts
ADD CONSTRAINT fk_rails_f6eef06841 FOREIGN KEY (participant_id) REFERENCES incident_management_oncall_participants(id) ON DELETE CASCADE;