d5279b124f
Storage Persistence Guard / storage-persistence-audit (push) Has been cancelled
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled
Client Quality Gates / Shared client and Web (pull_request) Has been cancelled
Client Quality Gates / macOS Desktop (pull_request) Has been cancelled
Storage Persistence Guard / storage-persistence-audit (pull_request) Has been cancelled
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
"""add access context to audit logs
|
|
|
|
Revision ID: 20260709_01
|
|
Revises: 20260630_02
|
|
Create Date: 2026-07-09 10:00:00.000000
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
|
|
revision: str = "20260709_01"
|
|
down_revision: Union[str, None] = "20260630_02"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("audit_logs", sa.Column("client_ip", sa.String(45), nullable=True))
|
|
op.add_column("audit_logs", sa.Column("user_agent", sa.String(500), nullable=True))
|
|
op.add_column("audit_logs", sa.Column("client_type", sa.String(16), nullable=True))
|
|
op.add_column("audit_logs", sa.Column("client_version", sa.String(32), nullable=True))
|
|
op.add_column("audit_logs", sa.Column("client_platform", sa.String(16), nullable=True))
|
|
op.add_column("audit_logs", sa.Column("build_channel", sa.String(16), nullable=True))
|
|
op.add_column("audit_logs", sa.Column("build_commit", sa.String(64), nullable=True))
|
|
op.create_index("ix_audit_logs_operator_created", "audit_logs", ["operator_id", "created_at"])
|
|
op.create_index("ix_audit_logs_client_ip_created", "audit_logs", ["client_ip", "created_at"])
|
|
op.create_index("ix_audit_logs_client_source_created", "audit_logs", ["client_type", "created_at"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_audit_logs_client_source_created", table_name="audit_logs")
|
|
op.drop_index("ix_audit_logs_client_ip_created", table_name="audit_logs")
|
|
op.drop_index("ix_audit_logs_operator_created", table_name="audit_logs")
|
|
for column in (
|
|
"build_commit",
|
|
"build_channel",
|
|
"client_platform",
|
|
"client_version",
|
|
"client_type",
|
|
"user_agent",
|
|
"client_ip",
|
|
):
|
|
op.drop_column("audit_logs", column)
|