The seed load broke on lin001 the first time it ran after migration 008:
ERROR: invalid input syntax for type integer: "PS_STATUS_BITS"
CONTEXT: COPY hi_stage, line 2, column modbus_address
hi_stage is created LIKE historian_items, so it inherits the LIVE table's
column order. On a database built fresh from 001_schema.sql that matches
the CSV. On a database migrated by 008 it does not: ALTER TABLE ADD COLUMN
appends, so ci_station, ci_point and poll_group sit at the end of the
table while the CSV has them in the middle. \copy matches by position and
ignores the header, so it loaded the poll group into modbus_address.
It failed loudly here because a text value landed in an integer column.
Two columns of the same type would have loaded silently into each other's
places, which is the version of this defect worth designing against.
Both the \copy and the INSERT now name their columns, so the load no
longer depends on the two orders agreeing. The \copy line is long because
psql meta-commands cannot be wrapped across lines.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>