bilhej/backend
Hermes Agent 928a995298
Some checks failed
CI / Lint, type check, unit tests, coverage (pull_request) Successful in 3m9s
CI / E2E browser tests (pull_request) Failing after 2m31s
fix(db): add CHECK constraint for userId XOR guestToken invariant
The Order entity Javadoc states "Either userId or guestToken is set;
never both, never neither" but only the @PrePersist lifecycle callback
enforced this in Java. A stray INSERT (admin tooling, manual SQL) could
violate it silently — creating an order with neither set (invisible to
both JWT and guest lookup paths) or both set (ambiguous ownership).

Changes:
  - V13 Flyway migration adds a CHECK constraint on the orders table:
    CHECK ((user_id IS NULL) <> (guest_token IS NULL))
    This evaluates TRUE when exactly one column is NULL (the other is
    set), and FALSE when both are NULL or both are set.
  - Standard SQL CHECK constraint, supported by both H2 (tests/dev) and
    PostgreSQL (prod).

Verified:
  - Flyway migration check passes (V13 is next available version)
  - ./gradlew :backend:test — BUILD SUCCESSFUL (all tests pass)
  - H2 accepts the constraint at Flyway migration time

Closes #23
2026-07-18 11:35:22 +00:00
..
src fix(db): add CHECK constraint for userId XOR guestToken invariant 2026-07-18 11:35:22 +00:00
.gitattributes feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
.gitignore feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00
build.gradle Add account settings dropdown and verified email change flow. 2026-05-22 14:33:06 +02:00
gradlew.bat feat: scaffold Spring Boot 4 backend with Gradle, Flyway, and H2 2026-05-01 00:28:10 +02:00