- Docker and Docker Compose installed
- Go 1.21+ (for running the application)
-
Start the database:
cd collector-agent docker-compose up -d -
Wait for PostgreSQL to be ready:
# Check logs docker-compose logs -f postgres # Or wait for healthy status docker-compose ps
-
Run migrations:
# Option A: Using psql from host (if installed) psql -h localhost -U postgres -d feedback -f migrations/202501150001_create_feedback.up.sql psql -h localhost -U postgres -d feedback -f migrations/202501150002_create_votes.up.sql # Option B: Using psql from Docker container docker-compose exec postgres psql -U postgres -d feedback -f /migrations/202501150001_create_feedback.up.sql docker-compose exec postgres psql -U postgres -d feedback -f /migrations/202501150002_create_votes.up.sql # Option C: Interactive shell docker-compose exec postgres psql -U postgres -d feedback # Then run: \i /migrations/202501150001_create_feedback.up.sql
-
Verify setup:
docker-compose exec postgres psql -U postgres -d feedback -c "\dt"
- Host: localhost
- Port: 5432
- Database: feedback
- User: postgres
- Password: password
- Connection String:
postgres://postgres:password@localhost:5432/feedback?sslmode=disable
Start pgAdmin for a web-based database management interface:
docker-compose --profile tools up -dAccess at: http://localhost:5050
- Email: admin@feedback.local
- Password: admin
Add server connection:
- Host: postgres (use container name, not localhost)
- Port: 5432
- Database: feedback
- User: postgres
- Password: password
# Start services
docker-compose up -d
# Stop services (keeps data)
docker-compose down
# Stop and remove data
docker-compose down -v
# View logs
docker-compose logs -f postgres
# Access PostgreSQL shell
docker-compose exec postgres psql -U postgres -d feedback
# Restart database
docker-compose restart postgres
# Check service status
docker-compose psRun manual tests:
docker-compose exec postgres psql -U postgres -d feedback
# Inside psql:
-- Insert test feedback
INSERT INTO feedback (title, type, sentiment)
VALUES ('Test Feature', 1, 1);
-- Insert test vote
INSERT INTO votes (feedback_id, user_id)
VALUES (1, 100);
-- Query data
SELECT * FROM feedback;
SELECT * FROM votes;Port 5432 already in use:
# Check what's using the port
lsof -i :5432
# Either stop that service or change the port in docker-compose.yml:
# ports:
# - "5433:5432" # Use 5433 on host insteadDatabase not ready:
# Check health status
docker-compose ps
# Check logs for errors
docker-compose logs postgresReset everything:
docker-compose down -v
docker-compose up -d
# Re-run migrations