- floor_plans / floor_items (0035), tables' plan_id + width/height/rotation/shape; /api/floor-plans (set-up, catalog.tables.manage, floor_plans.changed) and /api/floor-plans/live (each table's state, guests, waiters, time; zone rule) - @xenia/floorplan: the drawing (Floor, Item, TableShape, FloorView) and its geometry (grid snap in whole cells, outlines, chairs), tested - manager: Management -> Tables -> Floor plans (editor: drag, grid, irregular floor, walls/bar/labels/areas, background picture), Tables page List / Map - counter POS: Tables List / Map; waiter: Map mode, the list stays the default - tests: test_floor_plans.py, floor + geometry unit tests, manager/waiter/terminal e2e Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
4.1 KiB
Python
86 lines
4.1 KiB
Python
"""Floor plans, their walls / bar / labels / areas, and the tables' place on a plan
|
|
(plan step 6.8, D-31, models/floor_plan.py). Existing tables stay off any plan.
|
|
|
|
Revision ID: 0035_floor_plans
|
|
Revises: 0034_tablet_orders
|
|
Create Date: 2026-11-18 16:05:26
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from core.timeutil import UTCDateTime
|
|
|
|
revision = '0035_floor_plans'
|
|
down_revision = '0034_tablet_orders'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
'floor_plans',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
sa.Column('group_id', sa.Integer(), nullable=True),
|
|
sa.Column('sort_order', sa.Integer(), nullable=False),
|
|
sa.Column('width', sa.Integer(), nullable=False),
|
|
sa.Column('height', sa.Integer(), nullable=False),
|
|
sa.Column('outline', sa.JSON(), nullable=True),
|
|
sa.Column('grid_on', sa.Boolean(), nullable=False),
|
|
sa.Column('grid_size', sa.Integer(), nullable=False),
|
|
sa.Column('media_id', sa.Integer(), nullable=True),
|
|
sa.Column('background_opacity', sa.Float(), nullable=False),
|
|
sa.Column('created_at', UTCDateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['group_id'], ['table_groups.id'], ondelete='SET NULL'),
|
|
sa.ForeignKeyConstraint(['media_id'], ['media.id'], ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
)
|
|
with op.batch_alter_table('floor_plans', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_floor_plans_group_id'), ['group_id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_floor_plans_id'), ['id'], unique=False)
|
|
|
|
op.create_table(
|
|
'floor_items',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('plan_id', sa.Integer(), nullable=False),
|
|
sa.Column('kind', sa.String(), nullable=False),
|
|
sa.Column('x', sa.Float(), nullable=False),
|
|
sa.Column('y', sa.Float(), nullable=False),
|
|
sa.Column('width', sa.Float(), nullable=False),
|
|
sa.Column('height', sa.Float(), nullable=False),
|
|
sa.Column('rotation', sa.Float(), nullable=False),
|
|
sa.Column('text', sa.String(), nullable=True),
|
|
sa.ForeignKeyConstraint(['plan_id'], ['floor_plans.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
)
|
|
with op.batch_alter_table('floor_items', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_floor_items_id'), ['id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_floor_items_plan_id'), ['plan_id'], unique=False)
|
|
|
|
with op.batch_alter_table('tables', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('plan_id', sa.Integer(), nullable=True))
|
|
batch_op.add_column(sa.Column('width', sa.Float(), nullable=True))
|
|
batch_op.add_column(sa.Column('height', sa.Float(), nullable=True))
|
|
batch_op.add_column(sa.Column('rotation', sa.Float(), nullable=True))
|
|
batch_op.add_column(sa.Column('shape', sa.String(), nullable=True))
|
|
batch_op.create_index(batch_op.f('ix_tables_plan_id'), ['plan_id'], unique=False)
|
|
batch_op.create_foreign_key('fk_tables_plan_id_floor_plans', 'floor_plans', ['plan_id'], ['id'], ondelete='SET NULL')
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table('tables', schema=None) as batch_op:
|
|
batch_op.drop_constraint('fk_tables_plan_id_floor_plans', type_='foreignkey')
|
|
batch_op.drop_index(batch_op.f('ix_tables_plan_id'))
|
|
batch_op.drop_column('shape')
|
|
batch_op.drop_column('rotation')
|
|
batch_op.drop_column('height')
|
|
batch_op.drop_column('width')
|
|
batch_op.drop_column('plan_id')
|
|
with op.batch_alter_table('floor_items', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_floor_items_plan_id'))
|
|
batch_op.drop_index(batch_op.f('ix_floor_items_id'))
|
|
op.drop_table('floor_items')
|
|
with op.batch_alter_table('floor_plans', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_floor_plans_id'))
|
|
batch_op.drop_index(batch_op.f('ix_floor_plans_group_id'))
|
|
op.drop_table('floor_plans')
|