Skip to content

CI integration

Commit your SQL and the generated Go in the same commit. In CI, start a fresh database, apply your migrations, run plainsql check, and then run your tests.

The blog example has Make targets for each step. They need Go 1.27, Docker, and the same PlainSQL version you used to generate the code locally:

Terminal window
# From examples/blog:
set -eu
export DEVDB_CONTAINER_NAME="plainsql-blog-ci-$$"
trap 'make db-down' EXIT
make db-up
make migrate
make check
make test

The example reads the connection string from the Docker container it starts. If your CI runner provides Postgres, put its connection string in DATABASE_URL before you run your migrations and plainsql check.

Change Check
A migration breaks a query Query analysis fails against the migrated schema.
SQL or generator settings changed without regeneration Expected output differs from the committed files.
A removed query left an old generated file The output directory contains an unexpected file.
Application code no longer matches the generated API Go compilation or tests fail.

When check fails, run plainsql generate locally, review the diff, and commit the updated files. Do not regenerate in CI before the check. That would hide the fact that the committed files were out of date.