summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Torres <torres@balameb.com>2016-09-21 21:54:09 +0000
committerJose Torres <torres@balameb.com>2016-12-27 22:58:02 -0600
commit80772ccaef9c0a883e4686940d7b4e37c5c0609f (patch)
tree66781ff52a2e914c1fdbe1f707ce87f81ef5511e
parentb93c72e33a50aaed845fe333dee0201b0b11934e (diff)
downloadgitlab-ce-mysql_validate_pre_truncate.tar.gz
Adds validation for schema_migration prior to truncate.mysql_validate_pre_truncate
Adds note to table.delete
-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 7c96bc864ce..b2780e0a9ac 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -30,9 +30,10 @@ namespace :gitlab do
connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql?
tables = connection.tables
+ # Removes the entry from the array
tables.delete 'schema_migrations'
- # Truncate schema_migrations to ensure migrations re-run
- connection.execute('TRUNCATE schema_migrations')
+ # Truncate schema_migrations to ensure migrations re-run
+ connection.execute('TRUNCATE schema_migrations') if connection.table_exists? 'schema_migrations'
# Drop tables with cascade to avoid dependent table errors
# PG: http://www.postgresql.org/docs/current/static/ddl-depend.html