Skip to content

chore(db): CHECK constraint for field_corrections.item_index #47

Description

@Fluory

Ziel

The database itself rejects impossible line-item indexes in field_corrections.item_index (added in migration 0014, PR #42). Today only the review service validates the index before the insert.

Akzeptanzkriterien

  • A new migration adds CHECK (item_index IS NULL OR item_index >= 0) on app.field_corrections.
  • Inserting a negative item_index as app_rw fails with a constraint violation.
  • Existing rows pass the constraint (migration applies on a DB migrated 0000 → latest with the test data).
  • docs/technical/data-model.md lists the constraint.

Nicht Teil dieser Aufgabe

  • An upper bound tied to the number of extracted line items (stays in the app – it depends on the latest run).

Betroffene Bereiche

  • src/db/schema/app.ts, new migration under src/db/migrations/, docs/technical/data-model.md

Testplan

Kriterium Prüfart
Negative index rejected integration test (real Postgres)
Migration applies on existing data pnpm verify on a fresh DB + migration test

Security/Privacy betroffen?

Nein.

Deliberately not done in PR #42 so the stacked migration numbers (0014/0015) stayed stable. Must be created after the stack #21 … #45 is merged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureNew capabilityreadyDefinition of Ready met – may be claimed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions