-
Notifications
You must be signed in to change notification settings - Fork 124
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
tapdb+sqlc: sqlc: add script to merge SQL migrations into consolidated schemas #1387
Conversation
Pull Request Test Coverage Report for Build 13404212592Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Very useful 🎉
07b47bc
to
cc06e9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🤖
cc06e9c
to
0141cb4
Compare
This commit introduces a new Go script located in `cmd/merge-sql-schemas/main.go` that consolidates SQL migration files into a single schema file. The script reads all `.up.sql` migration files from the `tapdb/sqlc/migrations` directory, executes them in order on an in-memory SQLite database, and retrieves the final schema definitions for tables and views. Additionally, the Makefile is updated to include a call to this new script during the SQL code generation process. The `.gitignore` file is that temporary or unwanted files do not clutter the repository. also modified to exclude files matching the pattern `.aider*`, ensuring
This commit checks in the unified schema using the script added in the prior commit.
0141cb4
to
7fa601d
Compare
@@ -252,9 +252,17 @@ sqlc: | |||
@$(call print, "Merging SQL migrations into consolidated schemas") | |||
go run ./cmd/merge-sql-schemas/main.go | |||
|
|||
sqlc-check: sqlc | |||
sqlc-check: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the dependency on the sqlc
target? Now it won't actually generate the schema anymore to see if there's a diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, missed this. I removed it to verify that the bash fragment I had worked (so I could remove the file, then run the check w/o it adding the file again).
Fixes incorrect removal of the sqlc target in #1387. Without this dependency, the check doesn't actually check anything.
In this PR, we introduce a new Go script located in
cmd/merge-sql-schemas/main.go
that consolidates SQL migration filesinto a single schema file. The script reads all
.up.sql
migrationfiles from the
tapdb/sqlc/migrations
directory, executes them in orderon an in-memory SQLite database, and retrieves the final schema
definitions for tables and views.
Additionally, the Makefile is updated to include a call to this new
script during the SQL code generation process. The
.gitignore
file isthat temporary or unwanted files do not clutter the repository.
also modified to exclude files matching the pattern
.aider*
, ensuringWhen I was making #1386, I made a few mistakes along the way as I was looking at the initial migration file, but later migration files ended up modifying a schema I was trying to migrate. With this, devs can look in a single place for the latest set of schemas.
Fixes #1062