Warn and protect against dangerous database operations on production database in the readathon project
TRIGGER: Before any database modification operation (INSERT, UPDATE, DELETE, DROP, TRUNCATE, or running clear_all_data.py)
Check which database is currently active:
# Check config file
grep -E "(active_db|database)" .readathon_config 2>/dev/null
# Or query registry
sqlite3 db/readathon_registry.db "SELECT filename, display_name FROM Database_Registry WHERE is_active = 1;"
If operating on production database (readathon_2025.db):
⚠️ WARNING: Operating on PRODUCTION database!
Database: readathon_2025.db (2025 Read-a-Thon)
Operation: [describe what's about to happen]
Impact: [estimated number of records affected]
Data: Real student data (411 students)
This operation will modify ACTUAL read-a-thon data.
Confirm operation on PRODUCTION database? (yes/no)
User must explicitly type "yes" to proceed.
BLOCK these operations without explicit confirmation:
python3 clear_all_data.py (wipes all contest data)DELETE FROM queries (removes records)DROP TABLE (destroys table structure)TRUNCATE (empties tables)UPDATE without WHERE clause (affects all records)Require user to:
For development and testing, always suggest:
python3 app.py --db sample
Benefits:
Extra caution for registry database (readathon_registry.db):
⚠️ REGISTRY DATABASE: This tracks ALL contest databases!
Modifying registry affects:
- Database catalog
- Active database selection
- Summary statistics
- Database availability
Proceed with registry modification? (yes/no)
From CLAUDE.md:
db/readathon_registry.db (central catalog)db/readathon_2025.db (real contest data)db/readathon_sample.db (safe for testing)Skip warnings only if:
Otherwise, ALWAYS warn before production modifications.