Last active
October 21, 2025 21:33
-
-
Save tomaspozo/c96017c9d9de4b484cc41f5d021db389 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Create 300 dummy tables with RLS enabled and a default select policy each | |
| DO $$ | |
| DECLARE | |
| i INT; | |
| table_name TEXT; | |
| BEGIN | |
| FOR i IN 1..300 LOOP | |
| table_name := format('dummy_table_%s', i); | |
| EXECUTE format($sql$ | |
| CREATE TABLE IF NOT EXISTS %I ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| description TEXT | |
| ); | |
| $sql$, table_name); | |
| EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY;', table_name); | |
| -- Create policy to allow authenticated users to select | |
| EXECUTE format($sql$ | |
| CREATE POLICY select_authenticated ON %I | |
| FOR SELECT | |
| TO authenticated | |
| USING (true); | |
| $sql$, table_name); | |
| END LOOP; | |
| END | |
| $$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment