59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
"""Add moderation system
|
|
|
|
Revision ID: 83e6fd46fa2b
|
|
Revises: bc32a0b7efbb
|
|
Create Date: 2025-12-02 03:28:35.663970
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '83e6fd46fa2b'
|
|
down_revision: Union[str, Sequence[str], None] = 'bc32a0b7efbb'
|
|
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('report',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('target_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('target_id', sa.Integer(), nullable=False),
|
|
sa.Column('reason', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('report', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_report_status'), ['status'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_report_target_id'), ['target_id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_report_target_type'), ['target_type'], unique=False)
|
|
|
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('role', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
|
batch_op.drop_column('role')
|
|
|
|
with op.batch_alter_table('report', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_report_target_type'))
|
|
batch_op.drop_index(batch_op.f('ix_report_target_id'))
|
|
batch_op.drop_index(batch_op.f('ix_report_status'))
|
|
|
|
op.drop_table('report')
|
|
# ### end Alembic commands ###
|