Skip to content

Commit 1409edd

Browse files
committed
cmd/relui: use migrations for sqlc schema
Use migrations instead of maintaining a schema.sql. Having a schema dump can be useful, but we can instead go with our migrations to avoid confusion. For golang/go#47401 Change-Id: I426ffd46e17d3aa381d5bc0d517c8529961702f0 Reviewed-on: https://go-review.googlesource.com/c/build/+/353552 Trust: Alexander Rakoczy <[email protected]> Run-TryBot: Alexander Rakoczy <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 80b982a commit 1409edd

File tree

5 files changed

+2
-183
lines changed

5 files changed

+2
-183
lines changed

cmd/relui/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ migrate: docker
3535
migrate-down-up: docker
3636
docker run --rm --name=relui-dev-migrate -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-dev $(DOCKER_TAG) --migrate-down-up
3737

38-
schema.sql: migrate
39-
docker exec postgres-dev pg_dump --username=$(POSTGRES_USER) --schema-only relui-dev > schema.sql
40-
4138
.PHONY: test
4239
test: postgres-dev docker-test
4340
docker run --rm --name=relui-test -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-test golang/relui-test:$(VERSION)

cmd/relui/README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,10 @@ go run -tags pgx github.com/golang-migrate/migrate/v4/cmd/migrate \
5252

5353
#### Running
5454

55-
Migrations are automatically ran on application launch. Updating
56-
schema.sql, as documented below, will also run migrations. "Down"
55+
Migrations are automatically ran on application launch. "Down"
5756
migrations are not automatically run and must be manually invoked in
5857
`psql`, or by the `--migrate-down-up` flag or `make migrate-down-up`.
5958

60-
#### cmd/relui/schema.sql
61-
62-
`schema.sql` is updated by running the following command in this
63-
directory:
64-
65-
```bash
66-
make schema.sql
67-
```
68-
6959
## Testing
7060

7161
Run go test with the appropriate

cmd/relui/schema.sql

Lines changed: 0 additions & 163 deletions
This file was deleted.

cmd/relui/sqlc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ packages:
33
- name: "db"
44
path: "../../internal/relui/db"
55
queries: "../../internal/relui/queries"
6-
schema: "schema.sql"
6+
schema: "../../internal/relui/migrations/"
77
engine: "postgresql"
88
sql_package: "pgx/v4"
99
overrides:

internal/relui/db/models.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)