summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-02-06 05:07:48 +0000
committerStan Hu <stanhu@gmail.com>2019-02-06 05:07:48 +0000
commitd0187de202d94fa445a28c347b7a54dbf09a22a8 (patch)
tree7f78c390bd80720dd7b5a36d3b43a588921c8483
parentae55a99f85339943489f6a5cc7976b9867751bc6 (diff)
parent56c267e52cd84c82eec1319a5847016ed9dc37cc (diff)
downloadgitlab-ce-d0187de202d94fa445a28c347b7a54dbf09a22a8.tar.gz
Merge branch 'mysql_validate_pre_truncate' into 'master'
Adds validation for schema_migration prior to truncate. See merge request gitlab-org/gitlab-ce!6459
-rw-r--r--lib/tasks/gitlab/db.rake5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 74cd70c6e9f..b94b21775ee 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -29,10 +29,11 @@ namespace :gitlab do
# If MySQL, turn off foreign key checks
connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql?
- tables = connection.tables
+ tables = connection.data_sources
+ # Removes the entry from the array
tables.delete 'schema_migrations'
# Truncate schema_migrations to ensure migrations re-run
- connection.execute('TRUNCATE schema_migrations')
+ connection.execute('TRUNCATE schema_migrations') if connection.data_source_exists? 'schema_migrations'
# Drop tables with cascade to avoid dependent table errors
# PG: http://www.postgresql.org/docs/current/static/ddl-depend.html