feat(db): 迁移里的数据库角色名改为环境变量注入

This commit is contained in:
2026-10-30 18:49:30 +08:00
parent 7c84ff3b8d
commit 2dbe4cf675
8 changed files with 42 additions and 12 deletions
+3 -1
View File
@@ -11,6 +11,8 @@ from sqlalchemy.dialects.postgresql import UUID as PgUUID
from alembic import op
from app.roles import APP_ROLE
revision = "0005"
down_revision = "0004"
branch_labels = None
@@ -55,7 +57,7 @@ def upgrade() -> None:
"ALTER TABLE attachment ENABLE ROW LEVEL SECURITY",
"CREATE POLICY attachment_isolation ON attachment "
"USING (workspace_id = app_ws_id()) WITH CHECK (workspace_id = app_ws_id())",
"GRANT SELECT, INSERT, UPDATE, DELETE ON attachment TO dadao_app",
f"GRANT SELECT, INSERT, UPDATE, DELETE ON attachment TO {APP_ROLE}",
):
op.execute(statement)