forked from andika/membership-be
first commit
This commit is contained in:
31
migrate_status.py
Normal file
31
migrate_status.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
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()
|
||||
Reference in New Issue
Block a user