-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (41 loc) · 1.57 KB
/
Makefile
File metadata and controls
50 lines (41 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
POSTGRES_URI=postgresql://yaroslav:AnySecretPassword!!@localhost:5432/yaaws?sslmode=disable
env-up:
docker-compose up -d
env-down:
docker-compose down --remove-orphans -v
go-test:
docker exec research-sqlc-go-app go test ./... -v -count=1
docker-go-version:
docker exec research-sqlc-go-app go version
docker-pg-version:
docker exec research-sqlc-postgres psql -U yaroslav -d yaaws -c "SELECT VERSION();"
test:
make env-up
make docker-go-version
make docker-pg-version
make migrate-up
make go-test
make env-down
# go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
# sqlc generate
#
# alternative
# docker run --rm -v $(shell pwd):/src -w /src kjconroy/sqlc generate
generate-sqlc:
sqlc generate
# Creates new migration file with the current timestamp
# Example: make create-new-migration-file NAME=<name>
create-new-migration-file:
$(eval NAME ?= noname)
mkdir -p ./internal/storage/postgres/migrations/
goose -dir ./internal/storage/postgres/migrations/ create $(NAME) sql
migrate-up:
goose -dir ./internal/storage/postgres/migrations/ -table schema_migrations postgres $(POSTGRES_URI) up
migrate-redo:
goose -dir ./internal/storage/postgres/migrations/ -table schema_migrations postgres $(POSTGRES_URI) redo
migrate-down:
goose -dir ./internal/storage/postgres/migrations/ -table schema_migrations postgres $(POSTGRES_URI) down
migrate-reset:
goose -dir ./internal/storage/postgres/migrations/ -table schema_migrations postgres $(POSTGRES_URI) reset
migrate-status:
goose -dir ./internal/storage/postgres/migrations/ -table schema_migrations postgres $(POSTGRES_URI) status