dev: resolve circular dependency in make db-schema target #3273
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR aims to fix the pain with the
make db-schema
target.Currently, it depends on building several dev tools, which also have dependencies on other parts of the app, that in turn depend on sqlc-generated code. Since all the application-related code in turn depends on the output of
make db-schema
this created a circular dependency that was hard to resolve.This is made better by this PR by doing the following:
psql-lite
a dev-only tool, now has it's ownsqlc.yaml
file and can be built independentlymake db-schema
target now usesgo run
directly to further distance itself from build depsSplitQuery
helper was moved toutil/sqlutil
instead of requiring the entire harnesspsql-lite
will now output the results of a select query, eliminating the dependency onpsql
itselfgoalert-migrate
command was added to allow applying migrations without building the full appGoing forward, if a merge conflict breaks
migrate/schema.sql
, devs can simply runmake db-schema
to regenerate it, similar to other generated files.Additional Context
To validate:
migrate/schema.sql
and see thatmake db-schema
still worksmigrate/schema.sql
(e.g., merge conflict) and see thatmake db-schema
still works