#!/bin/bash # Fix all schema mismatches between models.py and database # Run this on your server set -e # Exit on error echo "============================================================" echo "Schema Mismatch Fix Script" echo "============================================================" echo "" # Navigate to backend directory cd "$(dirname "$0")" echo "Step 1: Check current Alembic status..." python3 -m alembic current echo "" echo "Step 2: Apply migration 003 (user_invitations fields)..." python3 -m alembic upgrade head echo "" echo "Step 3: Verify migration was applied..." python3 -m alembic current echo "" echo "Step 4: Restart PM2 backend..." pm2 restart membership-backend echo "" echo "============================================================" echo "✅ Schema fixes applied!" echo "============================================================" echo "" echo "Migrations applied:" echo " - 001_initial_baseline" echo " - 002_add_missing_user_fields (users table)" echo " - 003_add_user_invitation_fields (user_invitations table)" echo "" echo "Please test:" echo " 1. Login to admin dashboard" echo " 2. Navigate to user invitations page" echo " 3. Verify no more schema errors" echo ""