-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
29 lines (21 loc) · 988 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
# --name is the name of container
# can use docker logs to see the postgres conatiner logs
# the db name will same as username if not mentioned explicitly, here it will be root.
postgres:
docker run --name postgresdb -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=mysecretpassword -d postgres:alpine
createdb:
docker exec -it postgresdb createdb --username=root --owner=root chat-db
dropdb:
docker exec -it postgresdb dropdb --username=root --owner=root chat-db
migrate-up:
migrate -path db/migration -database "postgresql://root:mysecretpassword@localhost:5432/chat-db?sslmode=disable" -verbose up
migrate-down:
migrate -path db/migration -database "postgresql://root:mysecretpassword@localhost:5432/chat-db?sslmode=disable" -verbose up
sqlc:
sqlc generate
# -v verbose logs, -cover for code coverage data, ./... to run unit test in all the packages
test:
go test -v -cover ./...
server:
go run main.go
.PHONY: createdb dropdb migrate-down migrate-up sqlc server