"""Add Asset.gaugelabreference and Asset.maintenancereference

Adds dedicated external-reference columns to assets, distinct from
assetnumber. Equipment commonly carries an authoritative gauge lab reference
and a maintenance system reference; assetnumber stays the generic asset tag
and name the layperson label.

Revision ID: 7b02_gaugelabref
Revises: 7a01_adr001_position
Create Date: 2026-06-25

"""
from alembic import op
import sqlalchemy as sa


revision = '7b02_gaugelabref'
down_revision = '7a01_adr001_position'
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table('assets') as batch_op:
        batch_op.add_column(sa.Column(
            'gaugelabreference', sa.String(length=50), nullable=True,
            comment='Gauge lab asset reference (authoritative tag the gauge '
                    'lab assigns to equipment); distinct from assetnumber'))
        batch_op.add_column(sa.Column(
            'maintenancereference', sa.String(length=50), nullable=True,
            comment='Maintenance system asset reference; distinct from '
                    'assetnumber'))
        batch_op.create_index('ix_assets_gaugelabreference',
                              ['gaugelabreference'])
        batch_op.create_index('ix_assets_maintenancereference',
                              ['maintenancereference'])


def downgrade():
    with op.batch_alter_table('assets') as batch_op:
        batch_op.drop_index('ix_assets_maintenancereference')
        batch_op.drop_index('ix_assets_gaugelabreference')
        batch_op.drop_column('maintenancereference')
        batch_op.drop_column('gaugelabreference')
