Class: Vert::Generators::RlsMigrationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/vert/generators/rls_migration_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_enable_rls_migrationObject



21
22
23
24
25
26
# File 'lib/vert/generators/rls_migration_generator.rb', line 21

def create_enable_rls_migration
  return if options[:tables].empty?

  migration_template "enable_rls_on_tables.rb.tt",
                     "db/migrate/#{next_timestamp}_enable_rls_on_tables.rb"
end

#create_rls_functions_migrationObject



16
17
18
19
# File 'lib/vert/generators/rls_migration_generator.rb', line 16

def create_rls_functions_migration
  migration_template "create_rls_functions.rb.tt",
                     "db/migrate/#{timestamp}_create_rls_functions.rb"
end

#show_instructionsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vert/generators/rls_migration_generator.rb', line 28

def show_instructions
  say "\n"
  say "RLS migrations generated!", :green
  say "\n"
  say "Next steps:", :yellow
  say "1. Run migrations: rails db:migrate"
  say "2. Set enable_rls = true in config/initializers/vert.rb"
  say "3. Ensure your database user has appropriate privileges"
  say "\n"
  say "To enable RLS on additional tables, run:", :cyan
  say "  rails generate vert:rls_migration --tables orders invoices"
  say "\n"
end