summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-02-13 12:31:30 -0800
committerRémy Coutable <remy@rymai.me>2018-02-14 12:31:16 +0100
commit080dba4a7e036e4bcb9cae69c5de6bfa33ff8b2e (patch)
tree9a7b3906b01dc2b99c7cfa10ecd20a024e8aaa1e /lib
parent1c91c4e3f7009d6e50ba046aff7b672a0f761d41 (diff)
downloadgitlab-ce-080dba4a7e036e4bcb9cae69c5de6bfa33ff8b2e.tar.gz
Avoid dropping tables in test
And use :migration tag to use deletion strategy, and to avoid caching tables, and to lock into a particular schema. Attempting to fix intermittent spec errors `PG::UndefinedTable: ERROR: relation "public.untracked_files_for_uploads" does not exist`.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/populate_untracked_uploads.rb2
-rw-r--r--lib/gitlab/background_migration/prepare_untracked_uploads.rb6
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/gitlab/background_migration/populate_untracked_uploads.rb b/lib/gitlab/background_migration/populate_untracked_uploads.rb
index 8a8e770940e..ee55fabd6f0 100644
--- a/lib/gitlab/background_migration/populate_untracked_uploads.rb
+++ b/lib/gitlab/background_migration/populate_untracked_uploads.rb
@@ -249,7 +249,7 @@ module Gitlab
end
def drop_temp_table_if_finished
- if UntrackedFile.all.empty?
+ if UntrackedFile.all.empty? && !Rails.env.test? # Dropping a table intermittently breaks test cleanup
UntrackedFile.connection.drop_table(:untracked_files_for_uploads,
if_exists: true)
end
diff --git a/lib/gitlab/background_migration/prepare_untracked_uploads.rb b/lib/gitlab/background_migration/prepare_untracked_uploads.rb
index 298de005b9b..914a9e48a2f 100644
--- a/lib/gitlab/background_migration/prepare_untracked_uploads.rb
+++ b/lib/gitlab/background_migration/prepare_untracked_uploads.rb
@@ -171,8 +171,10 @@ module Gitlab
end
def drop_temp_table
- UntrackedFile.connection.drop_table(:untracked_files_for_uploads,
- if_exists: true)
+ unless Rails.env.test? # Dropping a table intermittently breaks test cleanup
+ UntrackedFile.connection.drop_table(:untracked_files_for_uploads,
+ if_exists: true)
+ end
end
end
end