
database-reset-production
by DarkMonkDev
The live Witch City Rope repository
SKILL.md
name: database-reset-production description: Resets production database with full schema drop. EXTREME CAUTION - deletes all production data. SINGLE SOURCE OF TRUTH for production database reset automation.
Database 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,cms, ANDhangfireschemas will be DROPPED - ❌ 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
production-deployskill first) - 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:
production-deployskill - 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
appsettings.Production.jsonhasSeedData: 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
production-deployskill - 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
witchcityrope_productiondatabase ONLY - Cannot affect other databases
- Follows principle of least privilege
Connection String: Uses keyword-value format
- Format:
Host=...;Port=...;Database=...;Username=...;Password=...; - Retrieved from
.env.productionon server - Never stored in version control
Version History
- 2025-11-24: Created as automation wrapper for production database reset
- Mirrors:
database-reset-stagingskill with enhanced safety - 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
production-deployskill first to ensure latest code is deployed - Always notify stakeholders before and after
- Never use during business hours without explicit approval
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon