Menu

My Tests Were Green on the Wrong Database — Moving to Real PostgreSQL with Flyway
📰

My Tests Were Green on the Wrong Database — Moving to Real PostgreSQL with Flyway

DEV Community: java·Rahkel Pekins·1 day ago
#GS3bmR1X
#devtojava#devto#dev#database#real
Reading 0:00
15s threshold

In Part 1 I ended with a question I was genuinely sitting with: REST controllers first, or persistence first?

Persistence won — in the project's own ROADMAP order. And it turned out to be the right call, because it exposed something uncomfortable: my repository tests were green, but they were green on the wrong database.

The problem: H2 was hiding the truth

Up to this point, the app's tests ran against H2, an in-memory stand-in. That's fine for fast unit tests. It's not fine as proof that your schema works, because the database your app will actually run on is PostgreSQL — different engine, different constraint behavior, different failure modes.

A test passing on H2 only proves the code works in a world that doesn't exist.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.