summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorDrew Blessing <drew@gitlab.com>2016-05-09 12:20:18 -0500
committerDrew Blessing <drew@gitlab.com>2016-05-09 12:20:18 -0500
commit10d4d5842bed749fa3477fb8808ec1c7cc05be75 (patch)
tree82ddec1d4027aef3a9e1147628a943753b488f0a /lib/tasks
parent50d18a1e1d945297de4162b2712fa6bbcee0e42e (diff)
downloadgitlab-ce-10d4d5842bed749fa3477fb8808ec1c7cc05be75.tar.gz
Add if exists to drop command
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/db.rake4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 1c706dc11b3..e473b756023 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -29,10 +29,12 @@ namespace :gitlab do
tables.delete 'schema_migrations'
# Truncate schema_migrations to ensure migrations re-run
connection.execute('TRUNCATE schema_migrations')
+
# Drop tables with cascade to avoid dependent table errors
# PG: http://www.postgresql.org/docs/current/static/ddl-depend.html
# MySQL: http://dev.mysql.com/doc/refman/5.7/en/drop-table.html
- tables.each { |t| connection.execute("DROP TABLE #{t} CASCADE") }
+ # Add `IF EXISTS` because cascade could have already deleted a table.
+ tables.each { |t| connection.execute("DROP TABLE IF EXISTS #{t} CASCADE") }
end
end
end