app/migrations/versions/2022_031015_b500363567e3_create_admin_audit_log.py
2022-03-10 16:37:21 +01:00

35 lines
1.1 KiB
Python

"""Create admin audit log
Revision ID: b500363567e3
Revises: 9282e982bc05
Create Date: 2022-03-10 15:26:54.538717
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "b500363567e3"
down_revision = "9282e982bc05"
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
"admin_audit_log",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("created_at", sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column("admin_user_id", sa.Integer, nullable=False),
sa.Column("action", sa.Integer, nullable=False),
sa.Column("model", sa.String(length=256), nullable=False),
sa.Column("model_id", sa.Integer, nullable=False),
sa.Column("data", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.ForeignKeyConstraint(['admin_user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint("id"),
)
def downgrade():
op.drop_table("admin_audit_log")