Skip to content

scripts/seed.ts generates a random bond_id on every run, breaking the script's documented idempotency #1139

Description

@vjuliaife

Description:
scripts/seed.ts's header comment states "The script is safe to run multiple times (uses ON CONFLICT DO NOTHING)", and upsertImporter does use ON CONFLICT (user_id) DO UPDATE. But bond_id is computed fresh via Math.floor(Math.random() * ...) on every invocation and is part of the UPDATE-less INSERT columns, meaning any downstream test or fixture that hardcodes a demo bond_id will silently diverge across seed runs, contradicting the "idempotent" claim for anything beyond legal_name.

Acceptance Criteria:

  • Make bond_id deterministic per demo importer (e.g. derived from a fixed seed constant per SEED_IMPORTERS entry) so ON CONFLICT re-runs produce identical bond_id values
  • Update the upsert's DO UPDATE SET clause to also refresh bond_id consistently if intentionally re-seeded
  • Add a one-line note to the header comment clarifying exactly which fields are stable across re-runs
  • Re-run npm run seed twice locally and diff the importers table to confirm stability

Relevant Files:

  • scripts/seed.ts — upsertImporter computes bondId via Math.random() on every call despite the header's idempotency claim

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxDeveloper experience / docs / namingtoolingAuto-created by repotool publish-folder

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions