1a980ba9d8
- Migration 0086: Remove FORCE RLS from 5 global tables - Migration 0085: crm_migration keeps BYPASSRLS for data migrations - Migration 0085: Remove audit_log from crm_auth grants - auth_service.py: Audit log via separate API session (crm_api with tenant context) - tests/test_no_legacy_tenant_var.py: CI test for app.tenant_id in policies
39 lines
883 B
Python
39 lines
883 B
Python
"""Fix FORCE RLS on global tables.
|
|
|
|
Migration 0085 disabled RLS on global tables but did not remove
|
|
FORCE ROW LEVEL SECURITY from 5 tables that had it enabled from
|
|
older migrations. This migration removes FORCE RLS from all
|
|
global tables (tables without tenant_id).
|
|
|
|
Revision ID: 0086
|
|
Revises: 0085
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from alembic import op
|
|
|
|
revision = "0086"
|
|
down_revision = "0085"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
GLOBAL_TABLES_WITH_FORCE_RLS = [
|
|
"api_tokens",
|
|
"sequences",
|
|
"sessions",
|
|
"tenant_plugin_activation",
|
|
"user_tenants",
|
|
]
|
|
|
|
|
|
def upgrade() -> None:
|
|
for table in GLOBAL_TABLES_WITH_FORCE_RLS:
|
|
op.execute(f"ALTER TABLE public.{table} NO FORCE ROW LEVEL SECURITY")
|
|
|
|
|
|
def downgrade() -> None:
|
|
for table in GLOBAL_TABLES_WITH_FORCE_RLS:
|
|
op.execute(f"ALTER TABLE public.{table} FORCE ROW LEVEL SECURITY")
|