Add Makefile targets for database management and improve dev/production workflows

- Introduced `drop-db` and `reset-db` targets for streamlined database operations, including database recreation and migration applications.
- Added `help` target to document available Makefile commands for both development and production environments.
- Expanded Makefile with new targets like `push-images` and `deploy` to enhance production deployment workflows.
- Consolidated redundant code and added descriptions for improved maintainability and user experience.
This commit is contained in:
Felipe Cardoso
2025-11-27 10:52:30 +01:00
parent 2bbe925cef
commit 77ed190310
2 changed files with 68 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: help lint lint-fix format format-check type-check test test-cov validate clean install-dev sync check-docker install-e2e test-e2e test-e2e-schema test-all drop-db reset-db
.PHONY: help lint lint-fix format format-check type-check test test-cov validate clean install-dev sync check-docker install-e2e test-e2e test-e2e-schema test-all
# Default target
help:
@@ -25,10 +25,6 @@ help:
@echo " make test-all - Run all tests (unit + E2E)"
@echo " make check-docker - Check if Docker is available"
@echo ""
@echo "Database:"
@echo " make drop-db - Drop local database entirely (requires Docker)"
@echo " make reset-db - Drop and recreate database with migrations"
@echo ""
@echo "Cleanup:"
@echo " make clean - Remove cache and build artifacts"
@@ -123,22 +119,6 @@ test-all:
@$(MAKE) test
@$(MAKE) test-e2e
# ============================================================================
# Database Management
# ============================================================================
drop-db: check-docker
@echo "🗑️ Dropping local database..."
@cd .. && docker compose -f docker-compose.dev.yml exec -T db psql -U postgres -c "DROP DATABASE IF EXISTS app WITH (FORCE);" 2>/dev/null || \
cd .. && docker compose -f docker-compose.dev.yml exec -T db psql -U postgres -c "DROP DATABASE IF EXISTS app;"
@cd .. && docker compose -f docker-compose.dev.yml exec -T db psql -U postgres -c "CREATE DATABASE app;"
@echo "✅ Database dropped and recreated (empty)"
reset-db: drop-db
@echo "🔄 Applying migrations..."
@uv run python migrate.py --local apply
@echo "✅ Database reset complete!"
# ============================================================================
# Cleanup
# ============================================================================