-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (33 loc) · 1.69 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
migratefilesup: # nc-0
migrate create -ext sql -dir db/migration -seq init_schema
postgres: # nc_1
docker run --name postgresElyasamRestaurant -p 5432:5432 -e POSTGRES_USER=mosleh -e POSTGRES_PASSWORD=1234 -d postgres:16.1-alpine3.19
postgresstop:
docker stop postgresElyasamRestaurant
postgresstart:
docker start postgresElyasamRestaurant
postgresdown:
docker rm postgresElyasamRestaurant
createdb: # nc_2
docker exec -it postgresElyasamRestaurant createdb --username=mosleh --owner mosleh Elyasam_Restaurant
dropdb:
docker exec -it postgresElyasamRestaurant dropdb --username=mosleh Elyasam_Restaurant
execdb: # access to database psql command line
docker exec -it postgresElyasamRestaurant psql -U mosleh -n Elyasam_Restaurant
migrateup: # nc_3
migrate -path db/migration -database "postgres://mosleh:1234@localhost:5432/Elyasam_Restaurant?sslmode=disable" -verbose up
migratedown:
migrate -path db/migration -database "postgres://mosleh:1234@localhost:5432/Elyasam_Restaurant?sslmode=disable" -verbose down
sqlc: # nc_4
sqlc generate
run: # Run program
go run main.go
test: # Test CRUD in database
go test -v -cover ./...
mock:
mockgen -package mockdb -destination db/mock/store.go github.com/moslehazizi/Elyasam_Restaurant/db/sqlc Store
backup:
docker exec -t postgresElyasamRestaurant pg_dumpall -c -U mosleh > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
restore: # every time to restore a specific backup file must replace with your_dump.sql
cat dump_18-12-2023_09_05_39.sql | docker exec -i postgresElyasamRestaurant psql -U mosleh -d Elyasam_Restaurant
.PHONY: migratefilesup postgres postgresstop postgresstart postgresdown createdb dropdb execdb migrateup migratedown sqlc run mock backup restore