Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-07-08 02:02:48 +0300
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-07-08 02:02:48 +0300
commitb9452d7bcd76f519f391595559531cf893960ab6 (patch)
tree05a4c2b0895b05705991c8c46030856aa284d8f3 /lib/backup
parent8b1065019ad9ac0fd41f5c32d47a049b77f00eb2 (diff)
parent90ab5a59bb28053c9da768679b8036caa7885e95 (diff)
Merge branch 'improve-postgres-restore-cleaning' into 'master'
Use native Postgres database cleaning during backup restore We were using hacks to drop tables etc during a Postgres backup restore. With this change, we let pg_dump insert the DROP TABLE statements it needs at the start of the SQL dump. See merge request !1891
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/database.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index f677f8def2b..b8aa6b9ff2f 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -18,7 +18,8 @@ module Backup
when "postgresql" then
$progress.print "Dumping PostgreSQL database #{config['database']} ... "
pg_env
- system('pg_dump', config['database'], out: db_file_name)
+ # Pass '--clean' to include 'DROP TABLE' statements in the DB dump.
+ system('pg_dump', '--clean', config['database'], out: db_file_name)
end
report_success(success)
abort 'Backup failed' unless success
@@ -41,10 +42,6 @@ module Backup
system('mysql', *mysql_args, config['database'], in: db_file_name)
when "postgresql" then
$progress.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
- Rake::Task["gitlab:db:drop_all_postgres_sequences"].invoke
pg_env
system('psql', config['database'], '-f', db_file_name)
end