47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""add action_logs
|
|
|
|
Revision ID: ea17bfd32885
|
|
Revises: b2e071ae215a
|
|
Create Date: 2026-03-12 14:17:22.483024
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'ea17bfd32885'
|
|
down_revision: Union[str, Sequence[str], None] = 'b2e071ae215a'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('action_logs',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('action', sa.String(), nullable=False),
|
|
sa.Column('ip_address', sa.String(), nullable=True),
|
|
sa.Column('details', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_action_logs_action'), 'action_logs', ['action'], unique=False)
|
|
op.create_index(op.f('ix_action_logs_created_at'), 'action_logs', ['created_at'], unique=False)
|
|
op.create_index(op.f('ix_action_logs_user_id'), 'action_logs', ['user_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_action_logs_user_id'), table_name='action_logs')
|
|
op.drop_index(op.f('ix_action_logs_created_at'), table_name='action_logs')
|
|
op.drop_index(op.f('ix_action_logs_action'), table_name='action_logs')
|
|
op.drop_table('action_logs')
|
|
# ### end Alembic commands ###
|