Skip to content

plainsql check

Terminal window
plainsql check

plainsql check runs the same analysis and generation as plainsql generate, but it does not write any files. Instead, it compares the result with the files already in the output directory. Use it in CI to catch a SQL change that was committed without regenerating.

The command fails when a generated file is missing, different, or unexpected, or when the output directory contains an extra directory. A symbolic link in place of a generated file also fails. It also fails when a query no longer works against the database schema.

Query errors show the file, line, and column in the SQL, plus any hint from Postgres. The quickstart has an example.

Terminal window
plainsql check --config config/plainsql.yaml
plainsql check --project blog --project reporting

The database must be running with migrations applied. With no flags, PlainSQL reads plainsql.yaml and checks every project. Use --project to check only some of them.

When the check fails because you changed a query or the schema, run plainsql generate locally, review the diff, and run your Go tests. In CI, run the check before any step that regenerates files. Otherwise, it compares against fresh output instead of what you committed.