"""``asset_items.status`` column default ``available`` → ``idle``. The table has carried a DDL-level ``DEFAULT 'available'`` since the original asset migration, while the ORM model, the intake path and every return path use ``idle``. Nothing in the app relies on the column default (every INSERT names the column), but it is the last place that still says "the stock status is called `available`" — and one meaning with two names is what produced the 「可用 / 闲置」 split and, in the same family, the frozen ``in_stock`` row that migration 454 cleaned up. Pure metadata change: existing rows are untouched (`available` stays a readable legacy value; 0 rows carry it in prod as of 2026-08-07). Revision ID: 455 Revises: 454 """ from __future__ import annotations import logging import sqlalchemy as sa from alembic import op revision = "455" down_revision = "454" branch_labels = None depends_on = None logger = logging.getLogger("alembic.runtime.migration") def _current_default(bind) -> str | None: return bind.execute( sa.text( "SELECT column_default FROM information_schema.columns " "WHERE table_schema = DATABASE() AND table_name = 'asset_items' " "AND column_name = 'status'" ) ).scalar() def upgrade() -> None: bind = op.get_bind() before = _current_default(bind) op.execute( sa.text("ALTER TABLE asset_items ALTER COLUMN status SET DEFAULT 'idle'") ) logger.info( "migration 455: asset_items.status default %r -> 'idle'", before, ) def downgrade() -> None: op.execute( sa.text( "ALTER TABLE asset_items ALTER COLUMN status SET DEFAULT 'available'" ) )