Claude-skill-registry database-reset-production
Resets production database with full schema drop. EXTREME CAUTION - deletes all production data. SINGLE SOURCE OF TRUTH for production database reset automation.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/database-reset-production" ~/.claude/skills/majiayu000-claude-skill-registry-database-reset-production && rm -rf "$T"
skills/data/database-reset-production/SKILL.mdDatabase Reset Production Skill
Purpose: Full database schema reset for PRODUCTION environment - drops all schemas and lets migrations rebuild.
⚠️ EXTREME CAUTION: THIS IS FOR PRODUCTION DATABASE ⚠️
When to Use:
- CRITICAL schema changes that cannot be migrated
- Database corruption beyond repair
- After explicit approval from stakeholders
- During planned maintenance window
When NOT to Use:
- You're not 100% certain this is necessary
- Production has live user data (will be permanently deleted)
- You haven't taken a complete database backup
- This is during business hours
- You haven't notified all stakeholders
Background Documentation: See
/docs/guides-setup/database-setup.md (Production Database Management section) for context and manual procedures.
🚨 CRITICAL WARNINGS
This skill performs DESTRUCTIVE operations:
- ❌ ALL PRODUCTION DATA WILL BE PERMANENTLY DELETED
- ❌ User accounts, events, payments, vetting records - EVERYTHING
- ❌ All
,public
, ANDcms
schemas will be DROPPEDhangfire - ❌ CANNOT BE UNDONE
- ✅ ONLY affects production database (
)witchcityrope_production - ✅ Migrations will rebuild schema automatically
- ✅ All users will need to re-register
Prerequisites:
- COMPLETE DATABASE BACKUP VERIFIED
- Production code already deployed (use
skill first)production-deploy - Stakeholder approval documented
- Maintenance window scheduled
- Rollback plan prepared
How to Use This Skill
Executable Script:
execute.sh
# From project root - with DOUBLE confirmation prompt bash .claude/skills/database-reset-production/execute.sh # Skip confirmation prompt (for automation - USE WITH EXTREME CAUTION) SKIP_CONFIRMATION=true bash .claude/skills/database-reset-production/execute.sh
What the script does:
- Shows pre-flight information with EXTREME warnings
- Requires DOUBLE confirmation before proceeding:
- First: Type "DELETE PRODUCTION DATA" exactly
- Second: Type "yes" to final confirmation
- Validates prerequisites:
- SSH key accessible
- PostgreSQL client installed (psql)
- Server connectivity
- Retrieves database credentials from production server
- Stops production containers
- Drops all database schemas (public + cms + hangfire)
- Recreates public schema
- Starts containers (migrations run automatically)
- Waits for database initialization
- Verifies schema rebuild
- Runs health check
- Reports summary
Script includes MULTIPLE safety warnings - this is a DESTRUCTIVE operation that CANNOT be undone.
Manual Override (Emergency Only)
If skill fails, manual steps:
Prerequisites: Get DB credentials from server first
Manual schema drop: Connect to database and execute:
DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public; DROP SCHEMA IF EXISTS cms CASCADE; DROP SCHEMA IF EXISTS hangfire CASCADE;
Then: Restart production containers manually
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 timeout
Cause: Firewall or network issue
Solution:
- Verify server is accessible:
ssh witchcity@104.131.165.14 - Check production containers status
- Verify database port is open (25060)
Issue: Migrations fail after reset
Cause: Old migration state or code/DB mismatch
Solution:
- Check API logs
- Ensure latest code deployed:
skillproduction-deploy - Verify no lingering tables: Run query to list all tables
Issue: Seed data not populating
Cause: Seed condition not met
Solution:
- API only seeds if
hasappsettings.Production.jsonSeedData: true - Check environment configuration on server
- Manual trigger: Restart API container
Integration with Process
Typical workflow:
- BACKUP PRODUCTION DATABASE (verify backup is restorable)
- Schedule maintenance window
- Notify all stakeholders
- Deploy code: Use
skillproduction-deploy - Place maintenance page
- Reset database: Use THIS skill
- Verify migrations and seed data
- Test critical endpoints
- Remove maintenance page
- Notify stakeholders
Security Considerations
Database User:
witchcity_production
- Environment-specific maintenance user
- Has full permissions on
database ONLYwitchcityrope_production - Cannot affect other databases
- Follows principle of least privilege
Connection String: Uses keyword-value format
- Format:
Host=...;Port=...;Database=...;Username=...;Password=...; - Retrieved from
on server.env.production - Never stored in version control
Version History
- 2025-11-24: Created as automation wrapper for production database reset
- Mirrors:
skill with enhanced safetydatabase-reset-staging - Complements:
docs/guides-setup/database-setup.md
Remember:
- This skill is for PRODUCTION - USE WITH EXTREME CAUTION
- Always take complete database backup first
- Always use
skill first to ensure latest code is deployedproduction-deploy - Always notify stakeholders before and after
- Never use during business hours without explicit approval