-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (57 loc) · 2.5 KB
/
Copy pathMakefile
File metadata and controls
78 lines (57 loc) · 2.5 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
GOOSE_DRIVER := postgres
GOOSE_DBSTRING := host=localhost port=5432 user=main password=password dbname=event-management sslmode=disable
GOOSE_MIGRATION_DIR := ./event-management/migrations
CONNECT_URL := http://localhost:8083
SCHEMA_VERSION := 20260403185907
export GOOSE_DRIVER GOOSE_DBSTRING GOOSE_MIGRATION_DIR
# ── Docker ──────────────────────────────────
.PHONY: up down reset
up:
docker compose up -d
up-components:
docker compose up -d elasticsearch kibana broker event-management-db redis connect
down:
docker compose down
reset:
docker compose down -v
# ── Wait helpers ────────────────────────────
.PHONY: wait-db wait-connect
wait-db:
@printf "Waiting for PostgreSQL..."
@until docker compose exec -T event-management-db pg_isready -U main > /dev/null 2>&1; do sleep 1; printf "."; done
@echo " ready"
wait-connect:
@printf "Waiting for Kafka Connect..."
@until curl -sf $(CONNECT_URL)/ > /dev/null 2>&1; do sleep 2; printf "."; done
@echo " ready"
# ── Migrations ──────────────────────────────
.PHONY: migrate-schema migrate-seed migrate-down migrate-status
migrate-schema: wait-db
goose up-to $(SCHEMA_VERSION)
migrate-seed: wait-db
goose up
migrate-down: wait-db
goose reset
migrate-status: wait-db
goose status
# ── Connector ───────────────────────────────
.PHONY: connector-create connector-delete connector-status
connector-create: wait-connect
@curl -s -X POST -H "Accept:application/json" -H "Content-Type:application/json" \
$(CONNECT_URL)/connectors/ -d @connector-config.json
@echo ""
@printf "Waiting for snapshot to complete..."
@sleep 3
@until curl -sf $(CONNECT_URL)/connectors/postgres-cdc/status 2>/dev/null | grep -q '"RUNNING"'; do sleep 2; printf "."; done
@echo " done"
connector-delete:
@curl -s -X DELETE $(CONNECT_URL)/connectors/postgres-cdc || true
@echo ""
connector-status:
@curl -s $(CONNECT_URL)/connectors/postgres-cdc/status | python3 -m json.tool 2>/dev/null || echo "Connector not found"
# ── Workflows ───────────────────────────────
.PHONY: setup teardown
setup: migrate-schema connector-create migrate-seed
@echo "✓ CDC setup complete"
teardown: connector-delete migrate-down
@echo "✓ CDC teardown complete"