diff options
author | Jose Torres <torres@balameb.com> | 2016-09-21 21:54:09 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-05 17:30:22 -0800 |
commit | 56c267e52cd84c82eec1319a5847016ed9dc37cc (patch) | |
tree | f435bfb828e72bc7bfc12aa03d3f705a131b472f | |
parent | d8e24e9d3896443e4b46c99a9b61a59d2a1acb2e (diff) | |
download | gitlab-ce-56c267e52cd84c82eec1319a5847016ed9dc37cc.tar.gz |
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.
-rw-r--r-- | lib/tasks/gitlab/db.rake | 5 |
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 |