Module: PgRls::Schema::Statements

Includes:
DownStatements, UpStatements
Included in:
PgRls::Schema::Solo::Statements
Defined in:
lib/pg_rls/schema/statements.rb

Overview

Schema Statements

Instance Method Summary collapse

Methods included from DownStatements

#detach_blocking_function, #detach_trigger_function, #drop_rls_blocking_function, #drop_rls_column, #drop_rls_policy, #drop_rls_setter_function, #drop_rls_user

Methods included from UpStatements

#add_rls_column, #add_rls_column_to_tenant_table, #append_blocking_function, #append_trigger_function, #create_rls_blocking_function, #create_rls_policy, #create_rls_setter_function, #create_rls_user

Instance Method Details

#convert_to_rls_table(table_name) ⇒ Object



59
60
61
62
63
# File 'lib/pg_rls/schema/statements.rb', line 59

def convert_to_rls_table(table_name)
  add_rls_column(table_name)
  create_rls_policy(table_name)
  append_trigger_function(table_name)
end

#convert_to_rls_tenant_table(table_name, **_options) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/pg_rls/schema/statements.rb', line 43

def convert_to_rls_tenant_table(table_name, **_options)
  create_rls_user
  create_rls_setter_function
  create_rls_blocking_function
  add_rls_column_to_tenant_table(table_name)
  append_blocking_function(table_name)
end

#create_rls_table(table_name, **options) ⇒ Object



22
23
24
25
26
27
# File 'lib/pg_rls/schema/statements.rb', line 22

def create_rls_table(table_name, **options, &)
  create_table(table_name, **options, &)
  add_rls_column(table_name)
  create_rls_policy(table_name)
  append_trigger_function(table_name)
end

#create_rls_tenant_table(table_name, **options) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/pg_rls/schema/statements.rb', line 13

def create_rls_tenant_table(table_name, **options, &)
  create_rls_user
  create_rls_setter_function
  create_rls_blocking_function
  create_table(table_name, **options, &)
  add_rls_column_to_tenant_table(table_name)
  append_blocking_function(table_name)
end

#drop_rls_table(table_name) ⇒ Object



37
38
39
40
41
# File 'lib/pg_rls/schema/statements.rb', line 37

def drop_rls_table(table_name)
  detach_trigger_function(table_name)
  drop_rls_policy(table_name)
  drop_table(table_name)
end

#drop_rls_tenant_table(table_name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/pg_rls/schema/statements.rb', line 29

def drop_rls_tenant_table(table_name)
  drop_rls_setter_function
  detach_blocking_function(table_name)
  drop_table(table_name)
  drop_rls_blocking_function
  drop_rls_user
end

#revert_rls_table(table_name) ⇒ Object



65
66
67
68
69
# File 'lib/pg_rls/schema/statements.rb', line 65

def revert_rls_table(table_name)
  detach_trigger_function(table_name)
  drop_rls_policy(table_name)
  drop_rls_column(table_name)
end

#revert_rls_tenant_table(table_name) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/pg_rls/schema/statements.rb', line 51

def revert_rls_tenant_table(table_name)
  drop_rls_setter_function
  detach_blocking_function(table_name)
  drop_rls_blocking_function
  drop_rls_user
  drop_rls_column(table_name)
end