chore: add one-click setup/start/stop scripts, migration CLI, and seed tool

- Add idempotent seed tool with duplicate detection for agents/issues/comments
- Add migration CLI supporting up/down with schema_migrations tracking
- Add Makefile targets: make setup (first-time), make start, make stop
- Update .gitignore for test artifacts and compiled binaries

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang 2026-03-22 11:50:33 +08:00
parent 6dfc61fa86
commit b5b0605e9a
5 changed files with 350 additions and 4 deletions

View file

@ -1,4 +1,45 @@
.PHONY: dev daemon build test migrate-up migrate-down sqlc seed clean
.PHONY: dev daemon build test migrate-up migrate-down sqlc seed clean setup start stop
# ---------- One-click commands ----------
# First-time setup: install deps, start DB, run migrations, seed data
setup:
@echo "==> Installing dependencies..."
pnpm install
@echo "==> Starting PostgreSQL..."
docker compose up -d
@echo "==> Waiting for PostgreSQL to be ready..."
@until docker compose exec -T postgres pg_isready -U multica > /dev/null 2>&1; do \
sleep 1; \
done
@echo "==> Running migrations..."
cd server && go run ./cmd/migrate up
@echo "==> Seeding data..."
cd server && go run ./cmd/seed
@echo ""
@echo "✓ Setup complete! Run 'make start' to launch the app."
# Start all services (backend + frontend)
start:
@docker compose up -d
@until docker compose exec -T postgres pg_isready -U multica > /dev/null 2>&1; do \
sleep 1; \
done
@echo "Starting backend and frontend..."
@trap 'kill 0' EXIT; \
(cd server && go run ./cmd/server) & \
pnpm dev:web & \
wait
# Stop all services
stop:
@echo "Stopping services..."
@-lsof -ti:8080 | xargs kill -9 2>/dev/null
@-lsof -ti:3000 | xargs kill -9 2>/dev/null
docker compose down
@echo "✓ All services stopped."
# ---------- Individual commands ----------
# Go server
dev: