"""Orders from a menu tablet at a table (plan step 6.6, D-30, models/tablet_order.py). Revision ID: 0034_tablet_orders Revises: 0033_menu_translations Create Date: 2026-11-18 16:00:00 """ from alembic import op import sqlalchemy as sa from core.timeutil import UTCDateTime revision = '0034_tablet_orders' down_revision = '0033_menu_translations' branch_labels = None depends_on = None def upgrade() -> None: op.create_table( 'tablet_orders', sa.Column('id', sa.Integer(), nullable=False), sa.Column('device_id', sa.Integer(), nullable=True), sa.Column('table_id', sa.Integer(), nullable=True), sa.Column('lines', sa.JSON(), nullable=False), sa.Column('note', sa.Text(), nullable=True), sa.Column('total', sa.Float(), nullable=False), sa.Column('status', sa.String(), nullable=False), sa.Column('order_id', sa.Integer(), nullable=True), sa.Column('reason', sa.String(), nullable=True), sa.Column('decided_by_id', sa.Integer(), nullable=True), sa.Column('decided_at', UTCDateTime(), nullable=True), sa.Column('created_at', UTCDateTime(), nullable=False), sa.ForeignKeyConstraint(['decided_by_id'], ['users.id'], ondelete='SET NULL'), sa.ForeignKeyConstraint(['device_id'], ['devices.id'], ondelete='SET NULL'), sa.ForeignKeyConstraint(['order_id'], ['orders.id'], ondelete='SET NULL'), sa.ForeignKeyConstraint(['table_id'], ['tables.id'], ondelete='SET NULL'), sa.PrimaryKeyConstraint('id'), ) with op.batch_alter_table('tablet_orders', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_tablet_orders_created_at'), ['created_at'], unique=False) batch_op.create_index(batch_op.f('ix_tablet_orders_device_id'), ['device_id'], unique=False) batch_op.create_index(batch_op.f('ix_tablet_orders_id'), ['id'], unique=False) batch_op.create_index(batch_op.f('ix_tablet_orders_status'), ['status'], unique=False) batch_op.create_index(batch_op.f('ix_tablet_orders_table_id'), ['table_id'], unique=False) def downgrade() -> None: op.drop_table('tablet_orders')