mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
Backward compatibility for dropping functions in ColumnDropper
.
https://meta.discourse.org/t/launcher-rebuild-error-pg-error-schema-discourse-functions-does-not-exist/96209
This commit is contained in:
parent
6659417807
commit
b71af05d62
@ -82,7 +82,22 @@ module Migration
|
||||
"readonly()"
|
||||
].compact.join("_")
|
||||
|
||||
"#{FUNCTION_SCHEMA_NAME}.#{function_name}"
|
||||
if DB.exec(<<~SQL).to_s == '1'
|
||||
SELECT schema_name
|
||||
FROM information_schema.schemata
|
||||
WHERE schema_name = '#{FUNCTION_SCHEMA_NAME}'
|
||||
SQL
|
||||
|
||||
"#{FUNCTION_SCHEMA_NAME}.#{function_name}"
|
||||
else
|
||||
function_name
|
||||
end
|
||||
end
|
||||
|
||||
def self.old_readonly_function_name(table_name, column_name = nil)
|
||||
readonly_function_name(table_name, column_name).sub(
|
||||
"#{FUNCTION_SCHEMA_NAME}.", ''
|
||||
)
|
||||
end
|
||||
|
||||
def self.readonly_trigger_name(table_name, column_name = nil)
|
||||
|
@ -57,6 +57,9 @@ module Migration
|
||||
DB.exec <<~SQL
|
||||
DROP TRIGGER IF EXISTS #{BaseDropper.readonly_trigger_name(@table, column)} ON #{@table};
|
||||
DROP FUNCTION IF EXISTS #{BaseDropper.readonly_function_name(@table, column)} CASCADE;
|
||||
-- Backward compatibility for old functions created in the public
|
||||
-- schema
|
||||
DROP FUNCTION IF EXISTS #{BaseDropper.old_readonly_function_name(@table, column)} CASCADE;
|
||||
SQL
|
||||
|
||||
# safe cause it is protected on method entry, can not be passed in params
|
||||
|
@ -75,6 +75,9 @@ module Migration
|
||||
|
||||
DB.exec <<~SQL
|
||||
DROP FUNCTION IF EXISTS #{BaseDropper.readonly_function_name(@old_name)} CASCADE;
|
||||
-- Backward compatibility for old functions created in the public
|
||||
-- schema
|
||||
DROP FUNCTION IF EXISTS #{BaseDropper.old_readonly_function_name(@old_name)} CASCADE;
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user