So I need something like this to let exposed validate it's own scheme against itself
03/07/2021, 7:07 PM
you could write a test to verify or a build task manually - I don’t think it’s Exposed target to have schema validation built in
03/07/2021, 10:08 PM
Yeah I thought about a unit test which inserts 1 item per table and then select first item per table - this should invoke any error if it exists I guess
Not sure what a gradle task could contain though
03/08/2021, 3:58 AM
the same - afaik (correct me if I’m wrong) you can literally run anything with Gradle, so just running the same test within a build task could better serve as a “build-time test”
03/08/2021, 9:14 AM
I ended up passing an enum to application module to distinguish between normal run and unit test run. When I’m in unit test mode app drops/creates a test database instead of a normal one. I make those inserts/fetches then to validate database schema.
This is fine when working locally though, I didn’t bother starting postgres in CI environment, so I just pass the test instead if I detect a CI run.
So the safest thing is to run this test as a pre-commit hook so I can’t commit a failing schema. This test takes just 1.5 sec so I guess this is fine