| name | database-reset-dev |
| description | Resets local development database by deleting all data and restarting API container to trigger auto-seeding. SINGLE SOURCE OF TRUTH for dev database reset automation. |
Database Reset Dev Skill
Purpose: Full database reset for local development environment - deletes all data and restarts API container to trigger automatic seed data population.
When to Use:
- Need fresh seed data for testing
- Database data is corrupted or inconsistent
- After manual data changes that broke the database state
- Testing with clean slate required
- Seed data accidentally modified or deleted
When NOT to Use:
- Staging database (use
database-reset-stagingskill instead) - Production database (NEVER - this is dev only)
- Just need to restart containers without data reset (use
restart-dev-containersskill)
Background: API container automatically seeds database on startup through DatabaseInitializationService when database is empty.
🚨 CRITICAL WARNINGS
This skill performs DESTRUCTIVE operations:
- ❌ ALL data in development database will be DELETED
- ❌ Both
publicANDcmsschemas will be DROPPED and recreated - ❌ Cannot be undone
- ✅ ONLY affects local dev database (
witchcityrope_dev) - ✅ API container will automatically re-seed on startup
Prerequisites:
- Docker containers should be running (or will be started by this skill)
- PostgreSQL client (psql) must be installed locally
How to Use This Skill
Executable Script: execute.sh
# From project root - with confirmation prompt
bash .claude/skills/database-reset-dev/execute.sh
# Skip confirmation prompt (for automation)
SKIP_CONFIRMATION=true bash .claude/skills/database-reset-dev/execute.sh
What the script does:
- Shows pre-flight information (purpose, when/when NOT to use, destructive operation warnings)
- Requires confirmation before proceeding (skippable with env var)
- Validates prerequisites:
- Docker running
- Project root directory
- PostgreSQL client installed (psql)
- Stops API container
- Drops all database schemas (public + cms)
- Recreates public schema
- Starts API container with dev overlay
- Waits for API initialization (initial 10 second wait)
- Checks API container status
- Verifies no compilation errors in API
- Waits for migrations and seeding (15 seconds)
- Verifies API health endpoint (with retry logic - up to 3 attempts)
- Verifies database health endpoint
- Verifies seed data populated
- Reports summary
Script includes CRITICAL safety warnings - this is a DESTRUCTIVE operation that cannot be undone.
Database Connection Details
Local Development Database:
- Host: localhost
- Port: 5434 (Docker-exposed port - note: NOT standard 5432)
- Database: witchcityrope_dev
- Username: postgres
- Password: devpass123
Note: Port 5434 is used to avoid conflicts with other local PostgreSQL instances.
How Auto-Seeding Works
When API container starts with an empty database:
DatabaseInitializationServiceruns automatically- Applies any pending migrations
- Detects empty database
- Calls
SeedCoordinatorto populate seed data:- 7 test user accounts (admin, teacher, vetted member, general member, guest, 2 safety coordinators)
- Sample events and sessions
- Vetting statuses and workflows
- Email templates
- System settings
- CMS content
Total seed time: ~10-15 seconds after container startup
Manual Override (Emergency Only)
If skill fails, manual steps:
Step 1: Connect to database and drop schemas
PGPASSWORD=devpass123 psql -h localhost -p 5434 -U postgres -d witchcityrope_dev -c "DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public; DROP SCHEMA IF EXISTS cms CASCADE;"
Step 2: Restart containers
bash .claude/skills/restart-dev-containers/execute.sh
Step 3: Verify seed data
PGPASSWORD=devpass123 psql -h localhost -p 5434 -U postgres -d witchcityrope_dev -c "SELECT COUNT(*) FROM \"Users\" WHERE \"Email\" LIKE '%@witchcityrope.com';"
Common Issues & Solutions
Issue: psql command not found
Cause: PostgreSQL client not installed locally
Solution:
# Ubuntu/Debian
sudo apt install postgresql-client
# macOS
brew install postgresql
Issue: Connection refused on port 5434
Cause: Docker containers not running
Solution:
- Check Docker status for witchcity containers
- If no containers: Use restart-dev-containers skill to restart containers
Issue: Database not found
Cause: Database was deleted entirely (not just schemas)
Solution:
- Recreate database manually:
PGPASSWORD=devpass123 psql -h localhost -p 5434 -U postgres -c "CREATE DATABASE witchcityrope_dev;"
- Run this skill again
Issue: Seed data not populating after reset
Cause: API container seeding disabled or failed
Solution:
- Check API logs for seed-related messages
- Verify
DatabaseInitializationServiceran - Check for errors in initialization
- Manual restart: Use restart-dev-containers skill to restart containers
Issue: Health check fails with "API service unhealthy"
Cause: API container needs more time to start, or compilation/migration errors
Solution:
- Skill automatically retries health check 3 times with 5-second delays
- If still failing, check API container logs for recent messages
- Check for compilation errors in logs
- Check migrations in logs
- If API container keeps restarting, fix source code errors first
Issue: Port 5434 already in use
Cause: Another PostgreSQL instance using that port
Solution:
- Find process:
lsof -i :5434 - Stop conflicting service
- Or modify docker-compose.yml to use different port
Integration with Workflow
Typical usage scenarios:
Scenario 1: Clean testing environment
Before E2E tests that require specific seed data state:
1. Run this skill to reset database
2. Run tests immediately
Scenario 2: Database corruption during development
Database in bad state from manual changes:
1. Run this skill to get fresh seed data
2. Continue development
Scenario 3: Testing seed data changes
Modified seed data logic in API:
1. Run this skill
2. Verify new seed data populated correctly
Integration with Other Skills
Related skills:
restart-dev-containers: Use this if you just need container restart WITHOUT database resetdatabase-reset-staging: Staging environment equivalent (different database, different procedure)
When to use which:
- Need fresh seed data? → Use THIS skill (database-reset-dev)
- Just container issues? → Use
restart-dev-containers - Staging database? → Use
database-reset-staging
Output Format
On success:
✅ Database Reset Complete
==========================
📊 Summary:
• Database: witchcityrope_dev
• Schemas: Dropped and recreated
• Seed data: Populated
• Test users: 7 accounts
🎯 Ready for:
• Development
• Testing
• Fresh start
On failure:
❌ Database Reset Failed
Error: [specific error message]
💡 Troubleshooting:
• Check Docker is running
• Verify psql client installed
• Review container logs for errors
• See: .claude/skills/database-reset-dev/SKILL.md (Common Issues)
Version History
- 2025-11-19: Added comprehensive health checks and retry logic
- Implemented API container status verification
- Added compilation error checking
- Added health endpoint verification with 3-attempt retry logic
- Added database health check
- Prevents premature container restart attempts
- Matches health check rigor of
restart-dev-containersskill
- 2025-11-18: Created as single source of truth for dev database reset
- Complements:
restart-dev-containersskill (container management) - Complements:
database-reset-stagingskill (staging equivalent)
Remember: This skill is for development only. Never use on staging or production. Use restart-dev-containers skill if you don't need database reset.