forked from andika/membership-be
32 lines
811 B
Python
32 lines
811 B
Python
"""
|
|
Migrate user status from awaiting_event to pending_approval
|
|
Run this once to update existing database records
|
|
"""
|
|
|
|
from database import SessionLocal
|
|
from models import User
|
|
|
|
def migrate_status():
|
|
db = SessionLocal()
|
|
try:
|
|
# Find all users with old status
|
|
users = db.query(User).filter(User.status == "awaiting_event").all()
|
|
|
|
count = 0
|
|
for user in users:
|
|
user.status = "pending_approval"
|
|
count += 1
|
|
|
|
db.commit()
|
|
print(f"✅ Successfully migrated {count} users from 'awaiting_event' to 'pending_approval'")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error during migration: {e}")
|
|
db.rollback()
|
|
finally:
|
|
db.close()
|
|
|
|
if __name__ == "__main__":
|
|
print("Starting status migration...")
|
|
migrate_status()
|