Commit Graph
1 Commits
  • 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.