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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-13 21:09:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-13 21:09:35 +0300
commit7e064974b92de60a3ef4642905e8af98a364a7a0 (patch)
treeea95222e8b6040cd959dfe3404ee83a069bae2c7 /db
parenta88c31d0ea1a79ca93fad357c3eb536b5e013e44 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20220708142744_add_composite_index_for_protected_environments.rb16
-rw-r--r--db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb16
-rw-r--r--db/post_migrate/20220617142124_add_index_on_installable_package_files.rb20
-rw-r--r--db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb22
-rw-r--r--db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb46
-rw-r--r--db/schema_migrations/202206171421241
-rw-r--r--db/schema_migrations/202206171432281
-rw-r--r--db/schema_migrations/202206291844021
-rw-r--r--db/schema_migrations/202207081427441
-rw-r--r--db/schema_migrations/202207081428031
-rw-r--r--db/structure.sql8
11 files changed, 132 insertions, 1 deletions
diff --git a/db/migrate/20220708142744_add_composite_index_for_protected_environments.rb b/db/migrate/20220708142744_add_composite_index_for_protected_environments.rb
new file mode 100644
index 00000000000..ab93f5ca9ca
--- /dev/null
+++ b/db/migrate/20220708142744_add_composite_index_for_protected_environments.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddCompositeIndexForProtectedEnvironments < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ # skips the `required_` part because index limit is 63 characters
+ INDEX_NAME = 'index_protected_environments_on_approval_count_and_created_at'
+
+ def up
+ add_concurrent_index :protected_environments, %i[required_approval_count created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :protected_environments, %i[required_approval_count created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb b/db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb
new file mode 100644
index 00000000000..6952489588d
--- /dev/null
+++ b/db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddCompositeIndexForProtectedEnvironmentApprovalRules < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ # uses `pe_` instead of `protected_environment_` because index limit is 63 characters
+ INDEX_NAME = 'index_pe_approval_rules_on_required_approvals_and_created_at'
+
+ def up
+ add_concurrent_index :protected_environment_approval_rules, %i[required_approvals created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :protected_environment_approval_rules, %i[required_approvals created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb b/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb
new file mode 100644
index 00000000000..e74c6c0935e
--- /dev/null
+++ b/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddIndexOnInstallablePackageFiles < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_pkgs_installable_package_files_on_package_id_id_file_name'
+ # See https://gitlab.com/gitlab-org/gitlab/-/blob/e3ed2c1f65df2e137fc714485d7d42264a137968/app/models/packages/package_file.rb#L16
+ DEFAULT_STATUS = 0
+
+ def up
+ add_concurrent_index :packages_package_files,
+ [:package_id, :id, :file_name],
+ where: "(status = #{DEFAULT_STATUS})",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_package_files, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb b/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb
new file mode 100644
index 00000000000..d1e70f04468
--- /dev/null
+++ b/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ReplacePackagesIndexOnProjectIdAndStatus < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'index_packages_packages_on_project_id_and_status_and_id'
+ OLD_INDEX_NAME = 'index_packages_packages_on_project_id_and_status'
+
+ def up
+ add_concurrent_index :packages_packages,
+ [:project_id, :status, :id],
+ name: NEW_INDEX_NAME
+ remove_concurrent_index_by_name :packages_packages, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :packages_packages,
+ [:project_id, :status],
+ name: OLD_INDEX_NAME
+ remove_concurrent_index_by_name :packages_packages, NEW_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb b/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb
new file mode 100644
index 00000000000..89adc4b2703
--- /dev/null
+++ b/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+class UnsetEscalationPoliciesForAlertIncidents < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class EscalationStatus < MigrationRecord
+ include EachBatch
+
+ self.table_name = 'incident_management_issuable_escalation_statuses'
+
+ scope :having_alert_policy, -> do
+ joins(
+ 'INNER JOIN alert_management_alerts ' \
+ 'ON alert_management_alerts.issue_id ' \
+ '= incident_management_issuable_escalation_statuses.issue_id'
+ )
+ end
+ end
+
+ def up
+ EscalationStatus.each_batch do |escalation_statuses|
+ escalation_statuses
+ .where.not(policy_id: nil)
+ .having_alert_policy
+ .update_all(policy_id: nil, escalations_started_at: nil)
+ end
+ end
+
+ def down
+ # no-op
+ #
+ # We cannot retrieve the exact nullified values. We could
+ # approximately guess what the values are via the alert's
+ # escalation policy. However, that may not be accurate
+ # in all cases, as an alert's escalation policy is implictly
+ # inferred from the project rather than explicit, like an incident.
+ # So we won't backfill potentially incorrect data.
+ #
+ # This data is functionally safe to delete, as the relevant
+ # fields are read-only, and exclusively informational.
+ #
+ # Re-running the migration will have no effect.
+ end
+end
diff --git a/db/schema_migrations/20220617142124 b/db/schema_migrations/20220617142124
new file mode 100644
index 00000000000..c8fd06f2c10
--- /dev/null
+++ b/db/schema_migrations/20220617142124
@@ -0,0 +1 @@
+668404076e9cfc91817b8ae3ec995a69ec0db283153bbe497a81eb83c2188ceb \ No newline at end of file
diff --git a/db/schema_migrations/20220617143228 b/db/schema_migrations/20220617143228
new file mode 100644
index 00000000000..cb4ac555bc3
--- /dev/null
+++ b/db/schema_migrations/20220617143228
@@ -0,0 +1 @@
+547fc0071177395133497cbcec9a9d9ed058fe74f632f5e84d9a6416047503f2 \ No newline at end of file
diff --git a/db/schema_migrations/20220629184402 b/db/schema_migrations/20220629184402
new file mode 100644
index 00000000000..7e8b0c47bd1
--- /dev/null
+++ b/db/schema_migrations/20220629184402
@@ -0,0 +1 @@
+9414b08c3eacadffd8759739da163eb378776d3ecdb06dab7c66e259ff1bed29 \ No newline at end of file
diff --git a/db/schema_migrations/20220708142744 b/db/schema_migrations/20220708142744
new file mode 100644
index 00000000000..980c0b43c52
--- /dev/null
+++ b/db/schema_migrations/20220708142744
@@ -0,0 +1 @@
+b93ab540270a4b743c12fe5d1d6963cfeb29ee3b0a1e4e012cd4b3d1b3a08cde \ No newline at end of file
diff --git a/db/schema_migrations/20220708142803 b/db/schema_migrations/20220708142803
new file mode 100644
index 00000000000..4eb59905dd0
--- /dev/null
+++ b/db/schema_migrations/20220708142803
@@ -0,0 +1 @@
+7929540cf382f282f75f2f9c9dd6196d426ed1edb1f6744da1f0a627e7fb0cfc \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 9ad896d801c..14b1a1ba862 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -27116,6 +27116,8 @@ CREATE INDEX idx_pkgs_debian_project_distribution_keys_on_distribution_id ON pac
CREATE UNIQUE INDEX idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type ON packages_dependency_links USING btree (package_id, dependency_id, dependency_type);
+CREATE INDEX idx_pkgs_installable_package_files_on_package_id_id_file_name ON packages_package_files USING btree (package_id, id, file_name) WHERE (status = 0);
+
CREATE INDEX idx_proj_feat_usg_on_jira_dvcs_cloud_last_sync_at_and_proj_id ON project_feature_usages USING btree (jira_dvcs_cloud_last_sync_at, project_id) WHERE (jira_dvcs_cloud_last_sync_at IS NOT NULL);
CREATE INDEX idx_proj_feat_usg_on_jira_dvcs_server_last_sync_at_and_proj_id ON project_feature_usages USING btree (jira_dvcs_server_last_sync_at, project_id) WHERE (jira_dvcs_server_last_sync_at IS NOT NULL);
@@ -29096,7 +29098,7 @@ CREATE INDEX index_packages_packages_on_project_id_and_created_at ON packages_pa
CREATE INDEX index_packages_packages_on_project_id_and_package_type ON packages_packages USING btree (project_id, package_type);
-CREATE INDEX index_packages_packages_on_project_id_and_status ON packages_packages USING btree (project_id, status);
+CREATE INDEX index_packages_packages_on_project_id_and_status_and_id ON packages_packages USING btree (project_id, status, id);
CREATE INDEX index_packages_packages_on_project_id_and_version ON packages_packages USING btree (project_id, version);
@@ -29162,6 +29164,8 @@ CREATE INDEX index_path_locks_on_project_id ON path_locks USING btree (project_i
CREATE INDEX index_path_locks_on_user_id ON path_locks USING btree (user_id);
+CREATE INDEX index_pe_approval_rules_on_required_approvals_and_created_at ON protected_environment_approval_rules USING btree (required_approvals, created_at);
+
CREATE UNIQUE INDEX index_personal_access_tokens_on_token_digest ON personal_access_tokens USING btree (token_digest);
CREATE INDEX index_personal_access_tokens_on_user_id ON personal_access_tokens USING btree (user_id);
@@ -29426,6 +29430,8 @@ CREATE INDEX index_protected_environment_deploy_access_levels_on_group_id ON pro
CREATE INDEX index_protected_environment_deploy_access_levels_on_user_id ON protected_environment_deploy_access_levels USING btree (user_id);
+CREATE INDEX index_protected_environments_on_approval_count_and_created_at ON protected_environments USING btree (required_approval_count, created_at);
+
CREATE UNIQUE INDEX index_protected_environments_on_group_id_and_name ON protected_environments USING btree (group_id, name) WHERE (group_id IS NOT NULL);
CREATE INDEX index_protected_environments_on_project_id ON protected_environments USING btree (project_id);