From 6740631fdb379f764e8d3007447341f4496dc350 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 27 Jul 2018 12:48:16 +0800 Subject: [PATCH] TEMPFIX: Fix broken restores. --- lib/backup_restore/restorer.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/backup_restore/restorer.rb b/lib/backup_restore/restorer.rb index fefe6c45774..f3b7ffbe5a0 100644 --- a/lib/backup_restore/restorer.rb +++ b/lib/backup_restore/restorer.rb @@ -64,6 +64,21 @@ module BackupRestore wait_for_sidekiq BackupRestore.move_tables_between_schemas("public", "backup") + + # This is a temp fix to allow restores to work again. @tgxworld is + # current working on a fix that namespaces functions created by Discourse + # so that we can alter the schema of those functions before restoring. + %w{ + raise_email_logs_reply_key_readonly + raise_email_logs_skipped_reason_readonly + }.each do |function| + DB.exec(<<~SQL) + DROP FUNCTION IF EXISTS backup.#{function}; + ALTER FUNCTION public.#{function} + SET SCHEMA "backup"; + SQL + end + @db_was_changed = true restore_dump migrate_database