-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (34 loc) · 1.28 KB
/
Copy pathMakefile
File metadata and controls
44 lines (34 loc) · 1.28 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
ifneq (,$(wildcard .env))
include .env
export
endif
DATABASE_URL=postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=disable
migrate:
docker compose run --rm migrate -path=/migrations -database="$(DATABASE_URL)" up
migrate-rollback:
docker compose run --rm migrate -path=/migrations -database="$(DATABASE_URL)" down
migrate-force:
docker compose run --rm migrate -path=/migrations -database="$(DATABASE_URL)" force $(version)
migrate-status:
docker compose run --rm migrate -path=/migrations -database="$(DATABASE_URL)" version
migrations:
@read -p "Migration name: " name; \
docker run --rm -v $$PWD/migrations:/migrations migrate/migrate create -ext sql -dir /migrations -seq $$name
run-functional-tests:
@echo "🧹 Cleaning up..."
docker compose down -v
@echo "🚀 Starting test_db..."
docker compose up -d test_db
@sleep 3
@echo "🧨 Dropping existing schema..."
docker compose run --rm migrate \
-path=/migrations \
-database "postgres://postgres:postgres@test_db:5432/testdb?sslmode=disable" \
drop -f
@echo "🛠 Running migrations..."
docker compose run --rm migrate \
-path=/migrations \
-database "postgres://postgres:postgres@test_db:5432/testdb?sslmode=disable" \
up
@echo "✅ Running tests..."
go test ./tests -v