summaryrefslogtreecommitdiff
path: root/config/initializers/fill_shards.rb
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers/fill_shards.rb')
-rw-r--r--config/initializers/fill_shards.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/config/initializers/fill_shards.rb b/config/initializers/fill_shards.rb
index 18e067c8854..cad662e12f3 100644
--- a/config/initializers/fill_shards.rb
+++ b/config/initializers/fill_shards.rb
@@ -1,3 +1,5 @@
-if Shard.connected? && !Gitlab::Database.read_only?
+# The `table_exists?` check is needed because during our migration rollback testing,
+# `Shard.connected?` could be cached and return true even though the table doesn't exist
+if Shard.connected? && Shard.table_exists? && !Gitlab::Database.read_only?
Shard.populate!
end