# Database Quick Reference ## ✅ Status: FULLY OPERATIONAL **Last Verified:** December 15, 2025 **Database:** PostgreSQL @ 192.168.10.130:5432 **Total Songs:** 41 **Total Profiles:** 5 --- ## Quick Commands ### Check Database ```bash cd /media/pts/Website/Church_HOP_MusicData bash check-database.sh ``` ### Verify Schema & Functionality ```bash cd backend source venv/bin/activate python3 verify_database.py ``` ### Restart Services ```bash sudo systemctl restart church-music-backend sudo systemctl restart church-music-frontend ``` --- ## API Testing ### Create Song ```bash curl -X POST https://houseofprayer.ddns.net/api/songs \ -H "Content-Type: application/json" \ -d '{ "title": "Test Song", "artist": "Artist", "lyrics": "Lyrics here", "chords": "C G Am F" }' -k ``` ### Get Song ```bash curl https://houseofprayer.ddns.net/api/songs/{id} -k ``` ### List All Songs ```bash curl https://houseofprayer.ddns.net/api/songs -k ``` ### Search Songs ```bash curl 'https://houseofprayer.ddns.net/api/songs?q=amazing' -k ``` --- ## Database Connection **File:** `backend/.env` ``` POSTGRESQL_URI=postgresql://songlyric_user:MySecurePass123@192.168.10.130:5432/church_songlyric ``` --- ## Verified Functionality ✅ **Song Creation** - Working perfectly ✅ **Song Retrieval** - All fields returned correctly ✅ **Song Updates** - Updates persist to database ✅ **Song Deletion** - Cascade deletes working ✅ **Search** - Full-text search operational ✅ **Foreign Keys** - All constraints configured ✅ **Data Integrity** - No orphaned records --- ## Performance Notes **Current Performance:** - Song creation: ~50ms - Song retrieval: ~30ms - Search (41 songs): ~40ms **Recommended Optimizations:** - Add indexes for better performance with large datasets - See DATABASE_ANALYSIS_REPORT.md for details --- ## Maintenance Scripts **Location:** `/media/pts/Website/Church_HOP_MusicData/backend/` 1. `verify_database.py` - Comprehensive verification 2. `fix_schema.sql` - Apply recommended indexes 3. `fix_database_schema.py` - Python migration script --- ## Common Issues ### Song not showing in frontend 1. Check if song exists: `curl https://houseofprayer.ddns.net/api/songs/{id}` 2. Clear browser cache: Ctrl+Shift+R 3. Check backend logs: `sudo journalctl -u church-music-backend -n 20` ### Database connection error 1. Check PostgreSQL is running: `sudo systemctl status postgresql` 2. Verify network access: `ping 192.168.10.130` 3. Test connection: `PGPASSWORD='MySecurePass123' psql -h 192.168.10.130 -U songlyric_user -d church_songlyric -c "SELECT 1"` ### Slow queries 1. Run verification: `python3 verify_database.py` 2. Apply indexes: See DATABASE_ANALYSIS_REPORT.md 3. Check connection pool: Restart backend if exhausted --- ## Support Files 📄 **DATABASE_ANALYSIS_REPORT.md** - Full analysis and recommendations 📄 **POSTGRESQL_QUICK_START.md** - Setup guide 🔧 **backend/verify_database.py** - Verification script 🔧 **backend/fix_schema.sql** - Index creation script --- *For detailed information, see DATABASE_ANALYSIS_REPORT.md*