Commit 77b57c114be6b1fa02538c35066ccc363bfe68e6

Authored by Jacob Vosmaer
1 parent f48fc3c6

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.
Showing 2 changed files with 4 additions and 2 deletions   Show diff stats
CHANGELOG
... ... @@ -2,6 +2,7 @@ v 6.8.0
2 2 - Ability to at mention users that are participating in issue and merge req. discussion
3 3 - 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)
4 4 - Make user search case-insensitive (Christopher Arnold)
  5 + - Drop all tables before restoring a Postgres backup
5 6  
6 7 v 6.7.2
7 8 - Fix upgrader script
... ...
lib/backup/database.rb
... ... @@ -29,9 +29,10 @@ module Backup
29 29 print "Restoring MySQL database #{config['database']} ... "
30 30 system('mysql', *mysql_args, config['database'], in: db_file_name)
31 31 when "postgresql" then
32   - puts "Destructively rebuilding database schema for RAILS_ENV #{Rails.env}"
33   - Rake::Task["db:schema:load"].invoke
34 32 print "Restoring PostgreSQL database #{config['database']} ... "
  33 + # Drop all tables because PostgreSQL DB dumps do not contain DROP TABLE
  34 + # statements like MySQL.
  35 + Rake::Task["gitlab:db:drop_all_tables"].invoke
35 36 pg_env
36 37 system('psql', config['database'], '-f', db_file_name)
37 38 end
... ...