Module: PgRls::Schema::DownStatements
- Included in:
- Statements
- Defined in:
- lib/pg_rls/schema/down_statements.rb
Overview
Down Schema Statements
Instance Method Summary collapse
- #detach_blocking_function(table_name) ⇒ Object
- #detach_trigger_function(table_name) ⇒ Object
- #drop_rls_blocking_function ⇒ Object
- #drop_rls_column(table_name) ⇒ Object
- #drop_rls_policy(table_name) ⇒ Object
- #drop_rls_setter_function ⇒ Object
- #drop_rls_user ⇒ Object
Instance Method Details
#detach_blocking_function(table_name) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/pg_rls/schema/down_statements.rb', line 25 def detach_blocking_function(table_name) ActiveRecord::Migration.execute <<-SQL.squish DROP TRIGGER IF EXISTS id_safe_guard ON #{table_name}; SQL end |
#detach_trigger_function(table_name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/pg_rls/schema/down_statements.rb', line 32 def detach_trigger_function(table_name) ActiveRecord::Migration.execute <<-SQL.squish DROP TRIGGER IF EXISTS tenant_id_setter ON #{table_name}; SQL end |
#drop_rls_blocking_function ⇒ Object
17 18 19 |
# 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) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/pg_rls/schema/down_statements.rb', line 39 def drop_rls_column(table_name) ActiveRecord::Migration.execute <<-SQL.squish ALTER TABLE #{table_name} DROP COLUMN IF EXISTS tenant_id; SQL end |
#drop_rls_policy(table_name) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/pg_rls/schema/down_statements.rb', line 46 def drop_rls_policy(table_name) ActiveRecord::Migration.execute <<-SQL.squish DROP POLICY #{table_name}_#{PgRls.username} ON #{table_name}; ALTER TABLE #{table_name} DISABLE ROW LEVEL SECURITY; SQL end |
#drop_rls_setter_function ⇒ Object
21 22 23 |
# 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 ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/pg_rls/schema/down_statements.rb', line 7 def drop_rls_user ActiveRecord::Migration.execute <<~SQL.squish DROP OWNED BY #{PgRls.username}; REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM #{PgRls.username}; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM #{PgRls.username}; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM #{PgRls.username}; DROP USER #{PgRls.username}; SQL end |