module PgRls::Schema::DownStatements
Down Schema
Statements
Public Instance Methods
detach_blocking_function(table_name)
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 25 def detach_blocking_function(table_name) ActiveRecord::Migration.execute <<-SQL DROP TRIGGER IF EXISTS id_safe_guard ON #{table_name}; SQL end
detach_trigger_function(table_name)
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 32 def detach_trigger_function(table_name) ActiveRecord::Migration.execute <<-SQL DROP TRIGGER IF EXISTS tenant_id_setter ON #{table_name}; SQL end
drop_rls_blocking_function()
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 17 def drop_rls_blocking_function ActiveRecord::Migration.execute 'DROP FUNCTION IF EXISTS id_safe_guard ();' end
drop_rls_column(table_name)
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 39 def drop_rls_column(table_name) ActiveRecord::Migration.execute <<-SQL ALTER TABLE #{table_name} DROP COLUMN IF EXISTS tenant_id; SQL end
drop_rls_policy(table_name)
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 46 def drop_rls_policy(table_name) ActiveRecord::Migration.execute <<-SQL DROP POLICY #{table_name}_#{PgRls::SECURE_USERNAME} ON #{table_name}; ALTER TABLE #{table_name} DISABLE ROW LEVEL SECURITY; SQL end
drop_rls_setter_function()
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 21 def drop_rls_setter_function ActiveRecord::Migration.execute 'DROP FUNCTION IF EXISTS tenant_id_setter ();' end
drop_rls_user()
click to toggle source
# File lib/pg_rls/schema/down_statements.rb, line 7 def drop_rls_user ActiveRecord::Migration.execute <<~SQL DROP OWNED BY #{PgRls::SECURE_USERNAME}; REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM #{PgRls::SECURE_USERNAME}; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM #{PgRls::SECURE_USERNAME}; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM #{PgRls::SECURE_USERNAME}; DROP USER #{PgRls::SECURE_USERNAME}; SQL end