https://kotlinlang.org logo
#exposed
Title
# exposed
s

solidogen

03/06/2021, 2:17 PM
So I need something like this to let exposed validate it's own scheme against itself spring.jpa.hibernate.ddl-auto=validate
e

Endre Deak

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
s

solidogen

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
e

Endre Deak

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”
s

solidogen

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
👍 1
4 Views