1818 enable_rls_on_table ( :support_faqs )
1919 enable_rls_on_table ( :organizations )
2020
21- # Enable RLS on Rails internal tables (block all API access)
22- enable_rls_on_table ( :ar_internal_metadata )
23- enable_rls_on_table ( :schema_migrations )
21+ # NOTE: schema_migrations and ar_internal_metadata intentionally excluded.
22+ # Adding FORCE RLS with deny-all to Rails internal tables breaks db:migrate
23+ # on every deploy. These tables are not exposed via any API and need no RLS.
2424
2525 # ===========================================================================
2626 # SUPPORT TICKETS - Organization scoped
@@ -297,24 +297,6 @@ def up
297297 USING (false);
298298 SQL
299299
300- # ===========================================================================
301- # RAILS INTERNAL TABLES - Block all API access
302- # These should never be accessible via PostgREST/API
303- # ===========================================================================
304-
305- # ar_internal_metadata - Rails internal
306- execute <<-SQL
307- CREATE POLICY ar_internal_metadata_deny_all ON ar_internal_metadata
308- FOR ALL
309- USING (false);
310- SQL
311-
312- # schema_migrations - Rails internal
313- execute <<-SQL
314- CREATE POLICY schema_migrations_deny_all ON schema_migrations
315- FOR ALL
316- USING (false);
317- SQL
318300 end
319301
320302 def down
@@ -372,10 +354,6 @@ def down
372354 drop_policy ( :organizations , 'organizations_update_policy' )
373355 drop_policy ( :organizations , 'organizations_delete_policy' )
374356
375- # Drop policies for Rails internal tables
376- drop_policy ( :ar_internal_metadata , 'ar_internal_metadata_deny_all' )
377- drop_policy ( :schema_migrations , 'schema_migrations_deny_all' )
378-
379357 # Disable RLS
380358 disable_rls_on_table ( :support_tickets )
381359 disable_rls_on_table ( :support_ticket_messages )
@@ -386,8 +364,6 @@ def down
386364 disable_rls_on_table ( :opponent_teams )
387365 disable_rls_on_table ( :support_faqs )
388366 disable_rls_on_table ( :organizations )
389- disable_rls_on_table ( :ar_internal_metadata )
390- disable_rls_on_table ( :schema_migrations )
391367 end
392368
393369 private
0 commit comments