summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 19:02:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 19:02:34 +0000
commit9b60052467242bbc071bcb0f74b7437fb3dfc870 (patch)
treef6426a3d6b62ad0e33be45bcdef6ae6bae4d34b4 /db/post_migrate
parent1ff28a8d8d370efef8bbac2da1edb85b758d4643 (diff)
downloadgitlab-ce-9b60052467242bbc071bcb0f74b7437fb3dfc870.tar.gz
Add latest changes from gitlab-org/security/gitlab@15-2-stable-ee
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb18
-rw-r--r--db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb23
2 files changed, 41 insertions, 0 deletions
diff --git a/db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb b/db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb
new file mode 100644
index 00000000000..077e8ed4bbe
--- /dev/null
+++ b/db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexWithTargetTypeToTodos < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_FOR_PROJECTS_NAME = 'index_requirements_project_id_user_id_id_and_target_type'
+ INDEX_FOR_TARGET_TYPE_NAME = 'index_requirements_user_id_and_target_type'
+
+ def up
+ add_concurrent_index :todos, [:project_id, :user_id, :id, :target_type], name: INDEX_FOR_PROJECTS_NAME
+ add_concurrent_index :todos, [:user_id, :target_type], name: INDEX_FOR_TARGET_TYPE_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :todos, INDEX_FOR_PROJECTS_NAME
+ remove_concurrent_index_by_name :todos, INDEX_FOR_TARGET_TYPE_NAME
+ end
+end
diff --git a/db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb b/db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb
new file mode 100644
index 00000000000..4f99caa10a4
--- /dev/null
+++ b/db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class RemoveDeprecatedIndexesFromTodos < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ PROJECTS_INDEX = 'index_todos_on_project_id_and_user_id_and_id'
+ USERS_INDEX = 'index_todos_on_user_id'
+
+ # These indexes are deprecated in favor of two new ones
+ # added in a previous migration:
+ #
+ # * index_requirements_project_id_user_id_target_type_and_id
+ # * index_requirements_user_id_and_target_type
+ def up
+ remove_concurrent_index_by_name :todos, PROJECTS_INDEX
+ remove_concurrent_index_by_name :todos, USERS_INDEX
+ end
+
+ def down
+ add_concurrent_index :todos, [:project_id, :user_id, :id], name: PROJECTS_INDEX
+ add_concurrent_index :todos, :user_id, name: USERS_INDEX
+ end
+end