summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-03-28 13:38:36 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-03-28 13:44:46 +0100
commit77b57c114be6b1fa02538c35066ccc363bfe68e6 (patch)
treefd94d74ab02dc8c0274fce1f8c6de7e4bf4de358
parentf48fc3c6cbcc0cbcb34cefa2025434c09cf57e04 (diff)
downloadgitlab-ce-77b57c114be6b1fa02538c35066ccc363bfe68e6.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.
-rw-r--r--CHANGELOG1
-rw-r--r--lib/backup/database.rb5
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 06d19df7a32..dc8031c75ac 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ v 6.8.0
- Ability to at mention users that are participating in issue and merge req. discussion
- Enabled GZip Compression for assets in example Nginx, make sure that Nginx is compiled with --with-http_gzip_static_module flag (this is default in Ubuntu)
- Make user search case-insensitive (Christopher Arnold)
+ - Drop all tables before restoring a Postgres backup
v 6.7.2
- Fix upgrader script
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