30 lines
825 B
Python
30 lines
825 B
Python
"""add ref_type and ref_id to audit_log
|
|
|
|
Revision ID: 0002
|
|
Revises: 0001
|
|
Create Date: 2025-12-14
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "0002"
|
|
down_revision = "0001"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
with op.batch_alter_table('audit_log') as batch_op:
|
|
batch_op.add_column(sa.Column('ref_type', sa.String(length=50), nullable=True))
|
|
batch_op.add_column(sa.Column('ref_id', sa.BigInteger(), nullable=True))
|
|
op.create_index('idx_audit_log_ref_type_id', 'audit_log', ['ref_type', 'ref_id'])
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index('idx_audit_log_ref_type_id', table_name='audit_log')
|
|
with op.batch_alter_table('audit_log') as batch_op:
|
|
batch_op.drop_column('ref_id')
|
|
batch_op.drop_column('ref_type')
|