fix(pb): patch the repairs collection when a field is corrected, not only when one is added

This commit is contained in:
Dave 2026-11-06 12:46:16 +02:00
parent f1073280ca
commit 1df399666d

View file

@ -169,10 +169,14 @@ async function main() {
console.log("[repairs-fields] orders.repair already exists — skipping.");
}
if (nextRepairsFields.length !== repairsFields.length) {
// Patch when the array DIFFERS, not only when it grew — a
// corrected field (e.g. clearing a length cap) keeps the same length.
const changed = (a: PbField[], b: PbField[]) =>
JSON.stringify(a) !== JSON.stringify(b);
if (changed(repairsFields, nextRepairsFields)) {
await pb.collections.update(repairs.id, { fields: nextRepairsFields });
}
if (nextOrdersFields.length !== ordersFields.length) {
if (changed(ordersFields, nextOrdersFields)) {
await pb.collections.update(orders.id, { fields: nextOrdersFields });
}