diff options
author | Robert Speicher <robert@gitlab.com> | 2016-05-09 18:17:57 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-05-09 18:17:57 +0000 |
commit | f27fd2741310152eedf5a0e8df029daee161d8d7 (patch) | |
tree | 6512b75efa9b4f527ba48b36cddd33ae95b33a31 /lib/tasks | |
parent | 0c2bb8d1d701d74ff720f12c3019cf51fbc77913 (diff) | |
parent | 10d4d5842bed749fa3477fb8808ec1c7cc05be75 (diff) | |
download | gitlab-ce-f27fd2741310152eedf5a0e8df029daee161d8d7.tar.gz |
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
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/db.rake | 4 |
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 |