From 77b57c114be6b1fa02538c35066ccc363bfe68e6 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 28 Mar 2014 13:38:36 +0100 Subject: 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. --- lib/backup/database.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/backup/database.rb') 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 -- cgit v1.2.1