#!/usr/bin/env python3 """ Fix the URL suffix UPDATE query to work regardless of userid value. This script updates the query to not use WHERE userid = 'admin' if that's causing issues. """ # The issue is that the WHERE clause might not be matching # Let's update the query to update ALL rows or use a different approach # Option 1: Update all rows (if there's only one row) # UPDATE admin_settings SET motm_url_suffix = :url_suffix # Option 2: Update by id (if id is always 1) # UPDATE admin_settings SET motm_url_suffix = :url_suffix WHERE id = 1 # Option 3: Use INSERT ... ON CONFLICT (PostgreSQL specific) # INSERT INTO admin_settings (userid, motm_url_suffix) # VALUES ('admin', :url_suffix) # ON CONFLICT (userid) DO UPDATE SET motm_url_suffix = :url_suffix print("This script documents the possible fixes for the URL suffix UPDATE issue.") print() print("The problem: UPDATE query returns True but doesn't actually update any rows") print("Likely cause: WHERE userid = 'admin' is not matching any rows") print() print("Possible solutions:") print("1. Update all rows: UPDATE admin_settings SET motm_url_suffix = :url_suffix") print("2. Update by id: UPDATE admin_settings SET motm_url_suffix = :url_suffix WHERE id = 1") print("3. Use UPSERT: INSERT ... ON CONFLICT (PostgreSQL)") print() print("Run the diagnostic script to see what's in the database first.")