
# Alembic migration script template

"""add menu_items table

Revision ID: a9f54e4eaf02
Revises: 6cb124491c9d
Create Date: 2025-12-07 17:38:54.839296

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'a9f54e4eaf02'
down_revision = '6cb124491c9d'
branch_labels = None
depends_on = None

def upgrade() -> None:
    op.create_table('menu_items',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('post_id', sa.Integer(), nullable=False),
        sa.Column('sort_order', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
        sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
        sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_menu_items_post_id'), 'menu_items', ['post_id'], unique=False)
    op.create_index(op.f('ix_menu_items_sort_order'), 'menu_items', ['sort_order'], unique=False)

def downgrade() -> None:
    op.drop_index(op.f('ix_menu_items_sort_order'), table_name='menu_items')
    op.drop_index(op.f('ix_menu_items_post_id'), table_name='menu_items')
    op.drop_table('menu_items')
