Skip to content

Commit

Permalink
Add debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
stevschmid committed Mar 26, 2024
1 parent 7672270 commit 743a955
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/tasks/rls.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,9 @@ namespace :rls do

task create_role: :environment do
RLS.without_rls do
puts "Current database: #{RLS.query_value("SELECT current_database()")}"
RLS.connection.execute <<~SQL
DO $$
BEGIN
CREATE ROLE "#{RLS.role}" WITH NOLOGIN;
EXCEPTION
WHEN DUPLICATE_OBJECT THEN
RAISE NOTICE 'Role "#{RLS.role}" already exists';
END
$$;
CREATE ROLE "#{RLS.role}" WITH NOLOGIN;
GRANT ALL ON ALL TABLES IN SCHEMA public TO "#{RLS.role}";
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO "#{RLS.role}";
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "#{RLS.role}";
Expand Down

0 comments on commit 743a955

Please sign in to comment.