"""Add dashboarddefaults (visitor-IP -> business-unit mapping)

A shopfloor / lobby kiosk resolves which business unit to display from the
display PC's IP. Powers the visitor-location lookup.

Revision ID: 7d01_dashboarddefaults
Revises: 7c04_fold_plugin_schema
Create Date: 2026-06-27

"""
from alembic import op
import sqlalchemy as sa


revision = '7d01_dashboarddefaults'
down_revision = '7c04_fold_plugin_schema'
branch_labels = None
depends_on = None


def upgrade():
    op.create_table(
        'dashboarddefaults',
        sa.Column('dashboarddefaultid', sa.Integer(), primary_key=True),
        sa.Column('ipaddress', sa.String(length=50), nullable=False, unique=True),
        sa.Column('businessunitid', sa.Integer(), nullable=False),
        sa.Column('description', sa.String(length=255), nullable=True),
        sa.Column('createddate', sa.DateTime(), nullable=True),
        sa.Column('modifieddate', sa.DateTime(), nullable=True),
        sa.Column('isactive', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(['businessunitid'], ['businessunits.businessunitid'],
                                name='fk_dashboarddefaults_businessunit'),
    )


def downgrade():
    op.drop_table('dashboarddefaults')
