# 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 1. **`main.py`** - All table references: `admin_settings` → `motmadminsettings` - All column names: snake_case → camelCase - Removed `WHERE userid = 'admin'` from all queries 2. **`readSettings.py`** - Table reference: `admin_settings` → `motmadminsettings` - Removed `WHERE userid = 'admin'` from query - Removed camelCase to snake_case conversion logic ## Key Changes ### SQL Queries **SELECT queries:** ```sql -- Before (my changes) SELECT next_club, next_team FROM admin_settings WHERE userid = 'admin' -- After (reverted) SELECT nextclub, nextteam FROM motmadminsettings ``` **UPDATE queries:** ```sql -- Before (my changes) UPDATE admin_settings SET motm_url_suffix = :suffix WHERE userid = 'admin' -- After (reverted) UPDATE motmadminsettings SET motmurlsuffix = :suffix ``` **INSERT queries:** ```sql -- 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_settings` table (reverted to `motmadminsettings`) - snake_case column names (reverted to camelCase) - `WHERE userid = 'admin'` clauses (removed) ## Production Compatibility ✅ **Now compatible with production database:** - Uses `motmadminsettings` table - Uses camelCase column names - No `userid` column references ## Testing The code should now work with your production database without any migration needed. ### Quick Test ```bash # 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 1. ✅ Code is reverted to use `motmadminsettings` 2. 🚀 Deploy to production 3. 🧪 Test MOTM admin page 4. ✅ 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.