WFDASH-WEBAPP/scripts/migrations
Dave e0d1356da5 feat(orders): add delivery-note repeat-order match fields
Five new fields on the `orders` collection:

- potential_delivery_note (relation → delivery_notes, single) — the
  DN whose items exactly matched this order's items
- potential_delivery_note_number (text) — denormalized copy of the
  matched DN's delivery_note_number, written alongside the relation
  so the orders list can render the number without a second `expand`
  (PB issues a separate IN query per expanded relation —
  orders-service.ts:253 documents why this is avoided here)
- delivery_note_match_confidence (number) — always 1 when set, kept
  for shape parity with quote_match_confidence
- delivery_note_match_method (text) — 'exact_items' or 'no_match',
  text not select for the same forward-compatibility reason
  quote_match_method is text
- delivery_note_matching_attempted (bool) — audit flag

Idempotent — each step detects its own 'already done' state.
Verified by re-running after the first apply.

Plan-staleness fix: PB stores relation options FLAT at the top
level of the field object (collectionId / cascadeDelete /
minSelect / maxSelect), not nested under an `options` key. The
plan's snippet had the nested form and PB rejected it with
'fields.N.collectionId Cannot be blank.' Verified the correct
shape against the live orders.potential_quote field before fixing.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-30 12:57:16 +02:00
..
2026-06-23-add-quote-attachments-direction.ts
2026-06-23-add-quote-email-composition-fields.ts
2026-06-23-add-quote-outbound-email-fields.ts
2026-06-23-add-quote-template-fields.ts
2026-06-26-add-orders-rep.ts
2026-06-27-add-order-quote-match-fields.ts
2026-06-27-drop-orders-status-and-wipe.ts
2026-06-28-add-companies-coordinates.ts
2026-06-28-add-purchase-order-pdfs.ts
2026-06-28-convert-customer-fields.ts
2026-06-30-add-price-list-search-text.ts
2026-06-30-add-price-list-sku-normalised.ts
2026-06-30-add-price-list-source-file.ts
2026-06-30-add-pricelist-notes.ts
2026-06-30-add-quote-items-sku-and-pricing.ts
2026-06-30-add-raw-price-list.ts
2026-06-30-backfill-price-list-search-text.ts
2026-06-30-create-rfq-outbound.ts
2026-07-02-add-sprint-categories-and-claims.ts
2026-07-06-order-items-assigned-at.ts
2026-07-06-order-items-collection-pool-rename.ts
2026-07-06-order-items-nullable-numbers.ts
2026-07-06-order-items-pricing-fields.ts
2026-07-06-purchase-orders-documents-field.ts
2026-07-06-purchase-orders-send-fields.ts
2026-07-06-quote-attachments-quote-item-and-kind.ts
2026-07-07-backfill-assigned-rfc.ts
2026-07-07-order-items-collection-photo.ts
2026-07-07-order-items-ready-for-collection.ts
2026-07-09-po-additional-attachments.ts
2026-07-09-po-pdf-tokens.ts
2026-07-10-restore-counters.ts
2026-07-14-create-stock-purchases.ts feat(stock): implement stock management workflow 2026-07-15 21:53:20 +02:00
2026-07-14-create-stock.ts feat(stock): implement stock management workflow 2026-07-15 21:53:20 +02:00
2026-07-15-add-stock-items-target-qty.ts feat(stock): implement stock management workflow 2026-07-15 21:53:20 +02:00
2026-07-15-add-stock-line-drv-id.ts feat: add stock line support to collection pool 2026-07-16 20:41:42 +02:00
2026-07-15-stock-purchase-line-state.ts feat: add stock line support to collection pool 2026-07-16 20:41:42 +02:00
2026-07-16-add-stock-purchase-documents-history.ts feat(stock-purchases,driver-app): add stock purchase workflow and driver pickup support 2026-07-18 22:43:50 +02:00
2026-07-16-add-stock-purchase-send-statuses.ts feat(stock-purchases,driver-app): add stock purchase workflow and driver pickup support 2026-07-18 22:43:50 +02:00
2026-07-17-add-stock-purchase-problem-fields.ts feat(stock-purchases,driver-app): add stock purchase workflow and driver pickup support 2026-07-18 22:43:50 +02:00
2026-07-19-create-delivery-notes.ts chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
2026-07-19-delivery-notes-signed-copy.ts chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
2026-07-19-delivery-notes-v3.ts chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
2026-07-20-delivery-tracking.ts chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
2026-07-24-partial-approval.ts chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
2026-07-25-add-ai-insights-fields.ts chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
2026-07-26-fix-quote-counter-and-reassign-numbers.ts fix(api,layout): sprint 500 chunk + add 9 missing top-level agent routes + metadataBase; drop unused collection_pool feature; quote counter fix migration 2026-07-26 22:18:49 +02:00
2026-08-03-add-stock-pricing-and-cost-history.ts feat: unify buyer task flows by supporting both customer orders and stock purchases in mark-ready API and UI, and fix PDF table layout responsiveness. 2026-08-03 18:52:30 +02:00
2026-08-04-add-order-items-item-status-index.ts perf(orders): server-side tab filter, slim expand payload, single combined count query 2026-08-04 18:17:59 +02:00
2026-08-04-add-quotes-status-index.ts perf(quotes): server-side tab filter, slim expand, combined counts + bonus bugfix 2026-08-04 19:01:31 +02:00
2026-08-06-add-stock-purchase-booked-fields.ts feat(stock-purchase): split warehouse confirm from accountant booking 2026-08-06 23:01:15 +02:00
2026-08-06-stock-purchases-additional-attachments.ts feat(pb): add stock_purchases.additional_attachments file field (migration) 2026-08-06 23:32:12 +02:00
2026-08-07-flip-stale-unprocessed-items.js fix(sprint): filter stale quote items, add cleanup migrations 2026-08-07 20:15:46 +02:00
2026-08-07-renumber-duplicate-quotes.js fix(sprint): filter stale quote items, add cleanup migrations 2026-08-07 20:15:46 +02:00
2026-08-07-stock-purchase-items-catalogue-fields.ts feat: add split-invoice stock PO workflow and supporting tooling 2026-08-07 00:53:29 +02:00
2026-08-08-add-quotes-ai-status.ts feat: add AI quote processing pipeline and admin settings UI 2026-08-09 16:17:29 +02:00
2026-08-09-add-ai-settings.ts feat: add AI quote processing pipeline and admin settings UI 2026-08-09 16:17:29 +02:00
2026-08-09-add-ai-system-prompt.ts feat: add AI quote processing pipeline and admin settings UI 2026-08-09 16:17:29 +02:00
2026-08-09-backfill-quote-validity-days.ts fix: correct quote expiry handling for PocketBase's 0 default 2026-08-11 08:32:17 +02:00
2026-08-09-repair-stock-double-booking.ts feat: add split views, stock picking slips, and invoice viewer 2026-08-09 23:16:55 +02:00
2026-08-13-fix-delivery-notes-relations.ts feat(delivery-notes, migrations): add tabs, grouping, markup, and fix DN relations 2026-08-14 09:41:14 +02:00
2026-08-17-add-order-items-in-stock.ts feat(collection-confirm): implement confirmation dialog for stock collection 2026-08-17 11:41:55 +02:00
2026-08-29-add-order-delivery-note-match-fields.ts feat(orders): add delivery-note repeat-order match fields 2026-08-30 12:57:16 +02:00
_env-loader.ts feat(delivery-notes, migrations): add tabs, grouping, markup, and fix DN relations 2026-08-14 09:41:14 +02:00
add-quote-items-user-edited.ts
broaden-quote-attachments-mime-types.ts
create-order-items-v2-and-collection-pool.ts
create-quote-attachments-and-replies.ts