summaryrefslogtreecommitdiff
path: root/db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-02 15:40:18 -0700
committerStan Hu <stanhu@gmail.com>2018-07-02 15:40:18 -0700
commitbc0794f6800c80536e31b21453043f2bbbc6e7f7 (patch)
tree3fb969bd34569b69eb15ed29e2a865345b352a43 /db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb
parent275fbf24b1810e2fbef92b6599d5372855b97b46 (diff)
downloadgitlab-ce-bc0794f6800c80536e31b21453043f2bbbc6e7f7.tar.gz
Backport partial index to find repositories that have not been checked
This was introduced in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5984.
Diffstat (limited to 'db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb')
-rw-r--r--db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb b/db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb
new file mode 100644
index 00000000000..a701d3678db
--- /dev/null
+++ b/db/post_migrate/20180629191052_add_partial_index_to_projects_for_last_repository_check_at.rb
@@ -0,0 +1,18 @@
+class AddPartialIndexToProjectsForLastRepositoryCheckAt < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = "index_projects_on_last_repository_check_at"
+
+ def up
+ add_concurrent_index(:projects, :last_repository_check_at, where: "last_repository_check_at IS NOT NULL", name: INDEX_NAME)
+ end
+
+ def down
+ remove_concurrent_index(:projects, :last_repository_check_at, where: "last_repository_check_at IS NOT NULL", name: INDEX_NAME)
+ end
+end