Skip to content

feat(payments): add payments schema and persistence - #220

Merged
tiana-code merged 1 commit into
mainfrom
feat/E-02-payments-schema
Jun 18, 2026
Merged

feat(payments): add payments schema and persistence#220
tiana-code merged 1 commit into
mainfrom
feat/E-02-payments-schema

Conversation

@tiana-code

Copy link
Copy Markdown
Owner

What

Second slice of E-02 Payments. Adds the payments persistence baseline in a dedicated payments schema.

  • Migrations (Liquibase formatted SQL, idempotent): payments (aggregate: amount NUMERIC(38,18) + CHAR(3) currency, status CHECK over the 6 PaymentStatus, version), payment_events (append-only log), processed_webhooks (inbound dedup by delivery_id), outbox_events (the service's own outbox, mirroring the ledger platform.outbox_events incl. leased_at + pending/claimable partial indexes).
  • Entities/repos: PaymentEntity (@Version, write-once columns updatable=false), PaymentEventEntity/ProcessedWebhookEntity (@Immutable), PaymentOutboxEventEntity (mirrors the ledger outbox entity), four Spring Data repositories. App-assigned UUIDs (no @GeneratedValue); gen_random_uuid() kept as a non-JPA-insert defence per the ledger precedent.
  • IT: @DataJpaTest + Testcontainers Postgres runs the changelog and round-trips each entity (amount precision via compareTo, enum, version, JSON payload, webhook dedup).

Payments owns its own outbox, separate from the ledger's platform.outbox_events; the shared dispatcher (#210) will read it through a store port.

Gates

Local (-x integrationTest): :services:payments:{test,detekt,detektTest,spotlessCheck,assemble,compileIntegrationTestKotlin} green. critic GO, security-auditor PASS, evaluator 0.86. The migration + round-trip IT runs on CI. One follow-up tracked for #214: tighten the webhook-dedup test to a real INSERT conflict (DB PK already enforces dedup).

Closes #209

Add the payments service database baseline in its own `payments` schema:
the payments aggregate table plus the payment-events log, the inbound
processed-webhooks dedup table, and the service's own outbox_events (same
shape as the ledger outbox, including the lease column and the claimable
indexes). All changesets are idempotent formatted SQL. Add the JPA entities
(optimistic-locked aggregate, immutable insert-only logs) reusing Money and
PaymentStatus, their Spring Data repositories, and a Testcontainers round-trip
integration test that runs the migrations and verifies field fidelity.

Closes #209
@tiana-code tiana-code added this to the v0.2.0 milestone Jun 18, 2026
@tiana-code
tiana-code merged commit d142963 into main Jun 18, 2026
8 checks passed
@tiana-code
tiana-code deleted the feat/E-02-payments-schema branch June 18, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F-02.2 Payments DB schema and persistence

1 participant