# SIMPLE STEPS TO FIX YOUR DATABASE # 1. First, remove the corrupted file: rm fix.py # 2. Create a clean fix file (COPY AND PASTE THIS ENTIRE BLOCK): cat > fix.py << 'ENDOFFILE' import psycopg2 import os DATABASE_URL = os.environ.get('DATABASE_URL') if DATABASE_URL and DATABASE_URL.startswith('postgres://'): DATABASE_URL = DATABASE_URL.replace('postgres://', 'postgresql://', 1) conn = psycopg2.connect(DATABASE_URL) cur = conn.cursor() cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS public_liability_amount DECIMAL(12,2)") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS workers_comp_insurance BOOLEAN DEFAULT false") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS insurance_expiry_date DATE") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS worker_control_level VARCHAR(50)") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS white_card_number VARCHAR(100)") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS white_card_expiry DATE") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS terms_accepted_date TIMESTAMP") cur.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP") ENDOFFILE # 3. Run the fix: python3 fix.py # YOU SHOULD SEE: # Added all columns # Created user_sessions table # Users table now has 51 columns # FIX COMPLETE! # 4. Exit SSH: exit # 5. Test your registration/login - it will work!