diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-03-28 13:38:36 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-04-01 17:50:37 +0200 |
commit | 9652be8d0741d24a6925c697126150c76f44dabb (patch) | |
tree | 6b90f6fad443f935bc323d15fc0cbef5eb79348e | |
parent | 0fa16b6886c4bf2fa7ee22c1af1a977d337db684 (diff) | |
download | gitlab-ce-9652be8d0741d24a6925c697126150c76f44dabb.tar.gz |
Drop all tables before restoring a PostgreSQL DB
Invoking 'db:schema:load' turned out to be a bad idea: when downgrading
an existing GitLab installation, the schema of the newer version would
be preserved when trying to import the old version.
Conflicts:
CHANGELOG
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | lib/backup/database.rb | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index 75d88e2ce3f..70bc88e790e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ -v6.7.2 +v 6.7.3 + - Drop all tables before restoring a Postgres backup + +v 6.7.2 - Fix upgrader script v6.7.1 diff --git a/lib/backup/database.rb b/lib/backup/database.rb index 6552f45ff0b..7b6908ccad8 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -29,9 +29,10 @@ module Backup print "Restoring MySQL database #{config['database']} ... " system('mysql', *mysql_args, config['database'], in: db_file_name) when "postgresql" then - puts "Destructively rebuilding database schema for RAILS_ENV #{Rails.env}" - Rake::Task["db:schema:load"].invoke print "Restoring PostgreSQL database #{config['database']} ... " + # Drop all tables because PostgreSQL DB dumps do not contain DROP TABLE + # statements like MySQL. + Rake::Task["gitlab:db:drop_all_tables"].invoke pg_env system('psql', config['database'], '-f', db_file_name) end |