mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 19:23:37 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
24 lines
625 B
Ruby
24 lines
625 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_dependency 'migration/base_dropper'
|
|
|
|
module Migration
|
|
class Migration::TableDropper
|
|
def self.read_only_table(table_name)
|
|
BaseDropper.create_readonly_function(table_name)
|
|
|
|
DB.exec <<~SQL
|
|
CREATE TRIGGER #{BaseDropper.readonly_trigger_name(table_name)}
|
|
BEFORE INSERT OR UPDATE OR DELETE OR TRUNCATE
|
|
ON #{table_name}
|
|
FOR EACH STATEMENT
|
|
EXECUTE PROCEDURE #{BaseDropper.readonly_function_name(table_name)};
|
|
SQL
|
|
end
|
|
|
|
def self.execute_drop(table_name)
|
|
DB.exec("DROP TABLE IF EXISTS #{table_name}")
|
|
end
|
|
end
|
|
end
|