From 58968522a30d60f7944898750d287c2e74d2d5c5 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 27 Feb 2014 15:01:35 +0100 Subject: [PATCH] Apply Postgres force-restore patch --- config/patches/gitlab-rails/pg_force_restore.patch | 13 +++++++++++++ config/software/gitlab-rails.rb | 4 ++++ 2 files changed, 17 insertions(+), 0 deletions(-) create mode 100644 config/patches/gitlab-rails/pg_force_restore.patch diff --git a/config/patches/gitlab-rails/pg_force_restore.patch b/config/patches/gitlab-rails/pg_force_restore.patch new file mode 100644 index 0000000..ffb64dc --- /dev/null +++ b/config/patches/gitlab-rails/pg_force_restore.patch @@ -0,0 +1,13 @@ +diff --git a/lib/backup/database.rb b/lib/backup/database.rb +index ebb4f28..6552f45 100644 +--- a/lib/backup/database.rb ++++ b/lib/backup/database.rb +@@ -29,6 +29,8 @@ 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']} ... " + pg_env + system('psql', config['database'], '-f', db_file_name) diff --git a/config/software/gitlab-rails.rb b/config/software/gitlab-rails.rb index e561023..7a1e9ad 100644 --- a/config/software/gitlab-rails.rb +++ b/config/software/gitlab-rails.rb @@ -54,6 +54,10 @@ build do # Patch the gitlab backup script to correctly restore gitlab-shell hooks patch :source => "backup_restore_hooks.patch" + # The backup script in gitlab-rails 6-6-stable fails to overwrite existing + # Postgres data. This patch, taken from gitlab-rails master, fixes that. + patch :source => "pg_force_restore.patch" + bundle "install --without mysql development test --path=#{install_dir}/embedded/service/gem", :env => env # In order to precompile the assets, we need to get to a state where rake can -- libgit2 0.21.2