Skip to content

Add migration preflight checks for invoice schema changes #1214

Description

@mikewheeleer

Summary

Schema changes can start with incompatible data and fail halfway through a deployment.

Why this matters

This closes a correctness, security, or operability gap in the Liquifact backend and makes the behavior explicit, observable, and safe under failure.

Requirements

  • Repository scope: Liquifact/Liquifact-backend only.
  • Inspect counts and invariants before migration; fail without writes when preconditions are not met; emit a redacted report suitable for operators.
  • Preserve tenant isolation, structured errors, and existing API compatibility unless the issue explicitly requires a contract change.
  • Add focused unit and integration coverage for the new behavior.

Technical guidance

  • Follow the repository's existing middleware, service, persistence, logging, and error-envelope conventions.
  • Keep side effects bounded and make retries, authorization, and failure handling explicit.
  • Document non-obvious tradeoffs and include security notes in the PR.

Edge cases — each must have a test

  • empty database
  • invalid legacy row
  • partial prior migration
  • very large table
  • preflight repeated

Acceptance criteria

  • Every requirement and edge case above is implemented and tested
  • Unit and integration tests cover success, failure, retry, and authorization paths
  • Existing tests pass with no regressions
  • Errors are structured and do not leak secrets or internal stack details
  • npm run lint, npm test, and npm run build passes locally
  • Code follows existing conventions with no duplication or dead code
  • Documentation or concise comments explain non-obvious decisions
  • PR description explains the approach, includes test evidence and security notes, and references Closes #

Out of scope

  • automatic destructive cleanup

Activity

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

Metadata

Metadata

Labels

Stellar WaveStellar Wave Program task

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions