Skip to content

feat(thirdparty): Flyway owns the Third Party schema in every profile (#267) - #272

Merged
dfcoffin merged 4 commits into
mainfrom
feature/267-thirdparty-flyway
Nov 17, 2026
Merged

dfcoffin merged 4 commits into
mainfrom
feature/267-thirdparty-flyway

Conversation

@dfcoffin

@dfcoffin dfcoffin commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #267.

Summary

Every Third Party profile now creates its schema with Flyway from the openespi-common scripts (classpath:db/migration plus db/vendor/{h2,mysql,postgres}), the same layout as the Data Custodian. Hibernate only validates it (ddl-auto: validate); the old update and create-drop are gone.

  • V4 gap: V4 is the Data Custodian's handoff_nonces table (openespi-handoff), which the TP doesn't use. Flyway applies V1, V2, V3 and V5.
  • Profiles: kept local (now the default), dev-mysql and dev-postgresql. Removed dev (HSQLDB, plus the hsqldb dependency), h2 (duplicate of local) and postgresql (duplicate of dev-postgresql).
  • local: Flyway on with the H2 scripts; the Hibernate naming-strategy overrides are removed, so it matches the tests and openespi-common.
  • POM: removed the Maven <profiles>. They set properties nothing read, so -Plocal silently ran dev-mysql. The profile is chosen with -Dspring-boot.run.profiles=….
  • local listens on loopback only (server.address: 127.0.0.1). Because local is now the default and seeds the published DEV ONLY accounts (admin/admin with ROLE_CUSTODIAN, customer/customer) and the H2 console, a deployment that forgets SPRING_PROFILES_ACTIVE must not serve them to the network. Before this PR the default dev-mysql failed safe (no database, no start). To reach the TP from another machine or a container, use dev-mysql or dev-postgresql.
  • Legacy dump: deleted etc/ThirdPartyMySQL.sql.
  • Docs: docs/LOCAL_TESTING.md lists the TP admin and customer logins; the TP README shows how to build and run each profile.

Change outside the Third Party: openespi-common application.properties

openespi-common shipped spring.profiles.active=${SPRING_PROFILES_ACTIVE:dev-mysql} in its jar's application.properties. For files at the same location Spring Boot gives .properties precedence over .yml, so it overrode the TP's own default: with no profile the TP still started on dev-mysql. The line is removed, with a comment matching the existing one about spring.application.name. The Data Custodian is unaffected: its own application.yml already defaults to dev-mysql. The Authorization Server doesn't depend on openespi-common.

Tests

  • The test profile now uses Flyway and validate, so every TP Spring test checks the entities against the scripts. Each test context gets its own in-memory database (resolves the shared-testdb note from fix(thirdparty): address the #268 review of Third Party form login (#249) #270).
  • New schema tests, one per database. Each checks Flyway applied exactly V1, V2, V3, V5, that ddl-auto is validate, and that a TP account round-trips:
    • LocalProfileSchemaTest: starts with no profile, so it also checks the default is local the development accounts are seeded and server.address is 127.0.0.1. It fails against openespi-common's old application.properties.
    • DevMysqlProfileSchemaTest (MySQL 9.5.0) and DevPostgresqlProfileSchemaTest (PostgreSQL 18): Testcontainers, skipped without Docker.

Test plan

  • TP mvn verify: 106 tests, 0 failures, 6 skipped (2 pre-existing + the 4 Docker tests on Windows without Docker)
  • Docker schema tests (WSL): MySQL and PostgreSQL, 4 tests pass
  • openespi-common: 284 non-Docker tests pass; Data Custodian: 117 non-Docker tests pass
  • Real start with no profile: runs on local, Flyway applies 4 migrations (now at v5), customer signs in
  • Real start on local: listens on 127.0.0.1:8082 only; the login page answers on loopback (200) and the LAN address refuses connections
  • CI

🤖 Generated with Claude Code

dfcoffin and others added 2 commits November 16, 2026 22:54
…#267)

Every Third Party profile now creates its schema with Flyway from the
openespi-common scripts (db/migration plus db/vendor/{h2,mysql,postgres})
and Hibernate only validates it (ddl-auto: validate). V4 is the Data
Custodian's handoff table and is intentionally absent; Flyway applies
V1, V2, V3 and V5.

- Profiles: keep local (default), dev-mysql and dev-postgresql; delete
  dev (HSQLDB), h2 and postgresql, and the hsqldb dependency.
- Remove the POM's Maven profiles, which set properties nothing read.
- Delete the legacy etc/ThirdPartyMySQL.sql dump.
- openespi-common: drop spring.profiles.active from application.properties.
  Being .properties in the jar, it overrode each application's own
  application.yml default (the TP's local still started as dev-mysql).
  The DC's application.yml already defaults to dev-mysql.
- test profile: Flyway + validate, one in-memory H2 database per context.
- New schema tests for local (no profile chosen), dev-mysql and
  dev-postgresql (Testcontainers, skipped without Docker).
- Docs: TP logins in LOCAL_TESTING.md; README run instructions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
local is now the default profile and seeds published DEV ONLY accounts
(admin/admin with ROLE_CUSTODIAN, customer/customer) plus the H2 console.
Bind it to 127.0.0.1 so a deployment that forgets SPRING_PROFILES_ACTIVE
does not serve them to the network. dev-mysql and dev-postgresql are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dfcoffin and others added 2 commits November 16, 2026 23:34
- Flyway: baseline-on-migrate false. No Third Party database was ever
  built by Flyway (Hibernate built them before #267), so baselining an
  existing one at V1 is never right; Flyway now stops with a clear error.
  README: drop and recreate an existing thirdparty database once.
- Correct the naming-strategy comment in application-local.yml (it comes
  from openespi-common) and the H2 settings comment in application-test.yml.
- Schema tests: the base class's fields are protected; LocalProfileSchemaTest
  no longer injects its own copies.

The underlying openespi-common application.properties precedence problem
is tracked in #273.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Correct stale comments: the H2 console runs on the local profile only
  (pom.xml), and dev-mysql/dev-postgresql no longer wait on #267
  (LocalDevAccountSeedRunner Javadoc).
- README: the recreate-the-database commands use IF EXISTS / --if-exists
  and no longer re-grant (grants on thirdparty.* survive the drop).
- Schema tests: delete the round-trip row in finally; method references;
  drop the spring.flyway.enabled assertion, which defaulted to true.

openespi-common's broken docker/prod/aws-sandbox profile files are
tracked in #273.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dfcoffin
dfcoffin merged commit bd3e2e2 into main Nov 17, 2026
11 checks passed
@dfcoffin
dfcoffin deleted the feature/267-thirdparty-flyway branch November 17, 2026 05:06
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.

Third Party: make Flyway own the schema in every profile using the openespi-common scripts (split from #241)

1 participant