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>