mirror of
https://github.com/discourse/discourse.git
synced 2025-06-11 11:43:43 +08:00
FIX: don't break restore if function does not exist
This commit is contained in:
@ -65,18 +65,22 @@ module BackupRestore
|
|||||||
|
|
||||||
BackupRestore.move_tables_between_schemas("public", "backup")
|
BackupRestore.move_tables_between_schemas("public", "backup")
|
||||||
|
|
||||||
# This is a temp fix to allow restores to work again. @tgxworld is
|
# This is a temp fix to allow restores to work again.
|
||||||
# current working on a fix that namespaces functions created by Discourse
|
# @tgxworld is currently working on a fix that namespaces functions
|
||||||
# so that we can alter the schema of those functions before restoring.
|
# created by Discourse so that we can alter the schema of those
|
||||||
|
# functions before restoring.
|
||||||
%w{
|
%w{
|
||||||
raise_email_logs_reply_key_readonly
|
raise_email_logs_reply_key_readonly
|
||||||
raise_email_logs_skipped_reason_readonly
|
raise_email_logs_skipped_reason_readonly
|
||||||
}.each do |function|
|
}.each do |function|
|
||||||
DB.exec(<<~SQL)
|
begin
|
||||||
DROP FUNCTION IF EXISTS backup.#{function};
|
DB.exec(<<~SQL)
|
||||||
ALTER FUNCTION public.#{function}
|
DROP FUNCTION IF EXISTS backup.#{function};
|
||||||
SET SCHEMA "backup";
|
ALTER FUNCTION public.#{function} SET SCHEMA "backup";
|
||||||
SQL
|
SQL
|
||||||
|
rescue PG::UndefinedFunction
|
||||||
|
# the function does not exist, no need to worry about this
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@db_was_changed = true
|
@db_was_changed = true
|
||||||
|
Reference in New Issue
Block a user