goware/pgkit

Pgkit is not backward-compatible when a new column is added to a DB table schema

VojtechVitek opened this issue · 0 comments

When I add a new column to the DB schema (e.g. v2 of my application)

+ new_field BOOLEAN NOT NULL DEFAULT TRUE

and apply the migration, the old v1 application will start failing on all SELECT * FROM pgkit queries with the following error:

get collection by contract address:
  get one:
    pgkit: scanning: doing scan: scanFn:
      scany: column: 'new_field': no corresponding field found, or it's unexported in data.Collection

This effectively prevent us from writing backward-compatible schema upgrades, since we can't add new columns without breaking the already running applications with slightly older Go data models.

Expected behavior: The old v1 application should ignore any new columns, which don't have corresponding fields found in the struct.