Fix database mismatches

This commit is contained in:
Koncept Kit
2026-01-04 22:01:26 +07:00
parent 6ec0745966
commit efc2002a67
6 changed files with 215 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
#!/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 ""