3.5 KiB
Revert to motmadminsettings - Summary
What Was Reverted
All changes have been reverted to use the original table and column names that match your production database.
Table Name
- Before (my changes):
admin_settings - After (reverted):
motmadminsettings✅
Column Names (camelCase)
All column names reverted from snake_case to camelCase:
| Old (snake_case) | New (camelCase) |
|---|---|
next_club |
nextclub ✅ |
next_team |
nextteam ✅ |
next_date |
nextdate ✅ |
oppo_logo |
oppologo ✅ |
hkfc_logo |
hkfclogo ✅ |
curr_motm |
currmotm ✅ |
curr_dotd |
currdotd ✅ |
next_fixture |
nextfixture ✅ |
motm_url_suffix |
motmurlsuffix ✅ |
prev_fixture |
prevfixture ✅ |
WHERE Clauses
Removed all WHERE userid = 'admin' clauses from queries since the motmadminsettings table doesn't have a userid column.
Files Modified
-
main.py- All table references:
admin_settings→motmadminsettings - All column names: snake_case → camelCase
- Removed
WHERE userid = 'admin'from all queries
- All table references:
-
readSettings.py- Table reference:
admin_settings→motmadminsettings - Removed
WHERE userid = 'admin'from query - Removed camelCase to snake_case conversion logic
- Table reference:
Key Changes
SQL Queries
SELECT queries:
-- Before (my changes)
SELECT next_club, next_team FROM admin_settings WHERE userid = 'admin'
-- After (reverted)
SELECT nextclub, nextteam FROM motmadminsettings
UPDATE queries:
-- Before (my changes)
UPDATE admin_settings SET motm_url_suffix = :suffix WHERE userid = 'admin'
-- After (reverted)
UPDATE motmadminsettings SET motmurlsuffix = :suffix
INSERT queries:
-- Before (my changes)
INSERT INTO admin_settings (userid, next_club, next_team, ...)
-- After (reverted)
INSERT INTO motmadminsettings (nextclub, nextteam, ...)
What Still Works
✅ All the bug fixes I made still work:
- Debug logging for URL suffix issues
- Fallback logic for UPDATE queries
- Voting deadline feature
- Error handling improvements
What's Different
❌ No longer using:
admin_settingstable (reverted tomotmadminsettings)- snake_case column names (reverted to camelCase)
WHERE userid = 'admin'clauses (removed)
Production Compatibility
✅ Now compatible with production database:
- Uses
motmadminsettingstable - Uses camelCase column names
- No
useridcolumn references
Testing
The code should now work with your production database without any migration needed.
Quick Test
# Test locally (if you have motmadminsettings table)
python -c "
from db_config import sql_read_static
from sqlalchemy import text
result = sql_read_static(text('SELECT * FROM motmadminsettings'))
print('Table exists:', len(result) > 0)
"
# Deploy to production
docker build -t your-registry/motm-app:latest .
docker push your-registry/motm-app:latest
helm upgrade motm-app ./helm-chart/motm-app --namespace motm-app
Next Steps
- ✅ Code is reverted to use
motmadminsettings - 🚀 Deploy to production
- 🧪 Test MOTM admin page
- ✅ URL suffix should now save correctly
Why This Happened
I initially assumed you were using the newer admin_settings table with snake_case columns (which is what the SQLAlchemy ORM model defines). However, your production database still uses the legacy motmadminsettings table with camelCase columns.
The revert ensures the code matches your actual production database schema.