Commit Graph
2 Commits
  • fix(migrate-db): preserve false-valued columns in SQLite to Postgres copy
    GORM struct INSERT substitutes a column default tag for Go zero-values, so disabled rows (enable=false) silently re-enabled on the destination. Copy each batch through explicit per-column maps so every value is written verbatim. Adds a regression test.
  • fix(migrate): copy composite-key tables without FindInBatches (#4787)
    SQLite to Postgres migration aborted with "copy *model.ClientInbound:
    primary key required" on installs whose client_inbounds table exceeds
    one read batch (500 rows). gorm's FindInBatches pages between batches
    using a single PrioritizedPrimaryField, which composite-key tables
    (client_id + inbound_id, no surrogate id) do not have, so it returns
    ErrPrimaryKeyRequired once a table holds more than one batch.
    
    Replace FindInBatches in copyTable with explicit LIMIT/OFFSET paging
    ordered by the model's primary-key columns. This works for every table
    including composite-key ones, keeps memory bounded, and changes no
    schema.
    
    Add a Postgres-gated regression test covering a >500-row composite-key
    table.