Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: resolve circular dependency in make db-schema target #3273

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

mastercactapus
Copy link
Member

@mastercactapus mastercactapus commented Sep 11, 2023

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 own sqlc.yaml file and can be built independently
  • The make db-schema target now uses go run directly to further distance itself from build deps
  • The SplitQuery helper was moved to util/sqlutil instead of requiring the entire harness
  • psql-lite will now output the results of a select query, eliminating the dependency on psql itself
  • A goalert-migrate command was added to allow applying migrations without building the full app

Going forward, if a merge conflict breaks migrate/schema.sql, devs can simply run make db-schema to regenerate it, similar to other generated files.

Additional Context
To validate:

  • try deleting migrate/schema.sql and see that make db-schema still works
  • try adding invalid syntax into migrate/schema.sql (e.g., merge conflict) and see that make db-schema still works

@mastercactapus mastercactapus merged commit 7212d6a into master Sep 12, 2023
@mastercactapus mastercactapus deleted the db-schema-circ-dep branch September 12, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants