Commit 56c267e5 authored by Jose Torres's avatar Jose Torres Committed by Stan Hu

Fix MySQL error when truncating a table that doesn't exist

This adds a conditional statement before truncating the
`schema_migrations` table.

This comit also ports this code to Rails 5.
parent d8e24e9d
......@@ -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
......
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