-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
30 lines (20 loc) · 984 Bytes
/
Makefile
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
include app.env
postgres:
docker run --name postgres --hostname postgres --publish ${POSTGRES_PORT}:${POSTGRES_PORT} --user ${shell id -u} --volume ${shell pwd}/db/data:/var/lib/postgresql/data --env POSTGRES_USER=${POSTGRES_USER} --env POSTGRES_PASSWORD=${POSTGRES_PASSWORD} --restart always --detach postgres:alpine
createdb:
docker exec --interactive --tty postgres createdb --username=${POSTGRES_USER} --owner=${POSTGRES_USER} ${POSTGRES_DB}
dropdb:
docker exec --interactive --tty postgres dropdb ${POSTGRES_DB}
initschema:
migrate create -ext sql -dir db/migration -seq init_schema
migrateup:
migrate -path db/migration -database "${DB_SOURCE}" -verbose up
migratedown:
migrate -path db/migration -database "${DB_SOURCE}" -verbose down
sqlc:
docker run --rm --volume ${shell pwd}:/src --workdir /src kjconroy/sqlc generate
test:
go test -v -cover ./...
server:
go run main.go
.PHONY: postgres createdb dropdb initschema migrateup migratedown sqlc test server