Commit 9652be8d authored by Jacob Vosmaer's avatar Jacob Vosmaer

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
parent 0fa16b68
v6.7.2 v 6.7.3
- Drop all tables before restoring a Postgres backup
v 6.7.2
- Fix upgrader script - Fix upgrader script
v6.7.1 v6.7.1
......
...@@ -29,9 +29,10 @@ module Backup ...@@ -29,9 +29,10 @@ module Backup
print "Restoring MySQL database #{config['database']} ... " print "Restoring MySQL database #{config['database']} ... "
system('mysql', *mysql_args, config['database'], in: db_file_name) system('mysql', *mysql_args, config['database'], in: db_file_name)
when "postgresql" then 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']} ... " 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 pg_env
system('psql', config['database'], '-f', db_file_name) system('psql', config['database'], '-f', db_file_name)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment