11# Tux Database Operations Makefile
2- # Use this to test database operations without the CLI
2+ # Unified database management using scripts/db.py
33
44.PHONY : help help-db db-connect db-current db-upgrade db-downgrade db-revision db-reset db-init test-unit test-integration test-e2e test-db test-alembic test-migrations test-models test-controllers test-service test-db-all test-coverage test-smoke test-clean
55
@@ -32,50 +32,53 @@ help:
3232 @echo " MODE=dev|prod - Environment mode (default: dev)"
3333 @echo " "
3434 @echo " Examples:"
35- @echo " make db-connect"
36- @echo " make MODE=prod db-current"
37- @echo " make db-upgrade"
35+ @echo " make db-connect # Test database connection"
36+ @echo " make MODE=prod db-current # Check current migration in prod"
37+ @echo " make db-upgrade # Upgrade database to latest"
38+ @echo " make db-init # Initialize fresh database"
39+ @echo " make db-reset # Reset database (with confirmation)"
3840
3941# Environment setup
4042MODE ?= dev
4143PYTHON := uv run python
4244
43- # Database connection test
45+ # Database operations using unified db.py script
46+ # All commands delegate to scripts/db.py with appropriate arguments
4447db-connect :
4548 @echo " 🔍 Testing database connection..."
46- @MODE=$(MODE ) $(PYTHON ) scripts/db_connect_test .py
49+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py test
4750
4851# Show current migration
4952db-current :
5053 @echo " 📊 Getting current migration version..."
51- @MODE=$(MODE ) $(PYTHON ) scripts/db_current .py
54+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py current
5255
5356# Upgrade database
5457db-upgrade :
5558 @echo " ⬆️ Upgrading database to latest migration..."
56- @MODE=$(MODE ) $(PYTHON ) scripts/db_upgrade .py
59+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py upgrade
5760
5861# Downgrade database
5962db-downgrade :
6063 @echo " ⬇️ Downgrading database by one migration..."
61- @MODE=$(MODE ) $(PYTHON ) scripts/db_downgrade .py
64+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py downgrade
6265
6366# Create new migration
6467db-revision :
6568 @echo " 📝 Creating new migration revision..."
66- @MODE=$(MODE ) $(PYTHON ) scripts/db_revision .py
69+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py revision
6770
6871# Initialize database schema
6972db-init :
7073 @echo " 🏗️ Initializing database schema..."
71- @MODE=$(MODE ) $(PYTHON ) scripts/db_init .py
74+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py init
7275
7376# Reset database (DANGER!)
7477db-reset :
7578 @echo " ⚠️ WARNING: This will reset the database and destroy all data!"
7679 @read -p " Are you sure? (type 'yes' to continue): " confirm && [ " $$ confirm" = " yes" ] || (echo " Operation cancelled" && exit 1)
7780 @echo " 🔄 Resetting database..."
78- @MODE=$(MODE ) $(PYTHON ) scripts/db_reset .py
81+ @MODE=$(MODE ) $(PYTHON ) scripts/db .py reset
7982
8083# ============================================================================
8184# TESTING TARGETS
@@ -86,15 +89,13 @@ test-unit:
8689 @echo " 🧪 Running database unit tests..."
8790 $(PYTHON ) -m pytest tests/unit/ -v --tb=short
8891
89- # Run database integration tests
92+ # Run database integration tests (currently empty)
9093test-integration :
91- @echo " 🔗 Running database integration tests..."
92- $(PYTHON ) -m pytest --run-integration tests/integration/ -v --tb=short
94+ @echo " 🔗 Database integration tests directory is empty - skipping..."
9395
94- # Run database end-to-end tests
96+ # Run database end-to-end tests (currently empty)
9597test-e2e :
96- @echo " 🌍 Running database E2E tests..."
97- $(PYTHON ) -m pytest --run-e2e tests/e2e/ -v --tb=short
98+ @echo " 🌍 Database E2E tests directory is empty - skipping..."
9899
99100# Run all database tests
100101test-db : test-unit test-integration test-e2e
@@ -108,27 +109,48 @@ test-alembic:
108109# Run migration-specific tests
109110test-migrations :
110111 @echo " 🔄 Running migration tests..."
111- $(PYTHON ) -m pytest tests/unit/test_database_migrations.py -v --tb=short
112+ $(PYTHON ) -m pytest tests/unit/test_database_migrations.py -m " not integration " - v --tb=short
112113
113114# Run model-specific tests
114115test-models :
115116 @echo " 📊 Running model tests..."
116117 $(PYTHON ) -m pytest tests/unit/test_database_models.py -v --tb=short
117118
118- # Run controller-specific tests
119+ # Run controller-specific tests (unit tests only by default)
119120test-controllers :
120121 @echo " 🎛️ Running controller tests..."
121- $(PYTHON ) -m pytest tests/unit/test_database_controllers.py -v --tb=short
122+ $(PYTHON ) -m pytest tests/unit/test_database_controllers.py -m " not integration " - v --tb=short
122123
123- # Run database service tests
124+ # Run database service tests (unit tests only by default)
124125test-service :
125126 @echo " 🔧 Running database service tests..."
126- $(PYTHON ) -m pytest tests/unit/test_database_service.py -v --tb=short
127+ $(PYTHON ) -m pytest tests/unit/test_database_service.py -m " not integration " - v --tb=short
127128
128- # Comprehensive database test suite
129- test-db-all : test-alembic test-migrations test-models test-controllers test-service test-integration test-e2e
129+ # Integration test targets (require real database)
130+ test-controllers-integration :
131+ @echo " 🎛️ Running controller integration tests..."
132+ $(PYTHON ) -m pytest tests/unit/test_database_controllers.py -m " integration" --integration -v --tb=short
133+
134+ test-service-integration :
135+ @echo " 🔧 Running service integration tests..."
136+ $(PYTHON ) -m pytest tests/unit/test_database_service.py -m " integration" --integration -v --tb=short
137+
138+ test-migrations-integration :
139+ @echo " 🔄 Running migration integration tests..."
140+ $(PYTHON ) -m pytest tests/unit/test_database_migrations.py -m " integration" --integration -v --tb=short
141+
142+ # Run all integration tests
143+ test-integration-all : test-controllers-integration test-service-integration test-migrations-integration
144+ @echo " 🎉 All integration tests passed!"
145+
146+ # Comprehensive database test suite (unit tests only - fast & reliable)
147+ test-db-all : test-alembic test-migrations test-models test-controllers test-service
130148 @echo " 🎉 Complete database test suite passed!"
131149
150+ # Full test suite including integration tests (requires test database)
151+ test-db-full : test-alembic test-migrations test-models test-controllers test-service test-integration-all test-e2e
152+ @echo " 🎉 Complete database test suite with integration tests passed!"
153+
132154# Run database tests with coverage
133155test-coverage :
134156 @echo " 📊 Running database tests with coverage..."
@@ -180,9 +202,10 @@ help-db:
180202 @echo " test-clean - Clean test artifacts"
181203 @echo " "
182204 @echo " Usage examples:"
183- @echo " make db-connect"
184- @echo " make MODE=prod db-current"
185- @echo " make test-unit"
186- @echo " make test-db"
187- @echo " make test-alembic"
188- @echo " make test-db-all"
205+ @echo " make db-connect # Test database connection"
206+ @echo " make MODE=prod db-current # Check current migration in prod"
207+ @echo " make db-upgrade # Upgrade database to latest"
208+ @echo " make test-unit # Run unit tests"
209+ @echo " make test-db # Run database test suite"
210+ @echo " make test-alembic # Run alembic-specific tests"
211+ @echo " make test-db-all # Run comprehensive test suite"
0 commit comments