Commit 96461d47 authored by Robert Speicher's avatar Robert Speicher Committed by Yorick Peterse

Merge branch 'cascade_drop' into 'master'

Add if exists to drop command

Add `IF EXISTS` as a precaution. Related to gitlab-org/gitlab-ce!4020

See merge request !4100
parent ca66610e
...@@ -29,10 +29,12 @@ namespace :gitlab do ...@@ -29,10 +29,12 @@ namespace :gitlab do
tables.delete 'schema_migrations' tables.delete 'schema_migrations'
# Truncate schema_migrations to ensure migrations re-run # Truncate schema_migrations to ensure migrations re-run
connection.execute('TRUNCATE schema_migrations') connection.execute('TRUNCATE schema_migrations')
# Drop tables with cascade to avoid dependent table errors # Drop tables with cascade to avoid dependent table errors
# PG: http://www.postgresql.org/docs/current/static/ddl-depend.html # PG: http://www.postgresql.org/docs/current/static/ddl-depend.html
# MySQL: http://dev.mysql.com/doc/refman/5.7/en/drop-table.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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment