Spaces:
Sleeping
Sleeping
File size: 796 Bytes
fd50325 2278049 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from pymongo import MongoClient
import os
from dotenv import load_dotenv
load_dotenv()
MONGO_URI = os.getenv("MONGO_URI")
def reset_users_collection():
try:
client = MongoClient(MONGO_URI)
db = client.get_default_database()
# Drop the existing users collection
print("Dropping existing users collection...")
db.users.drop()
# Run database_setup.py to recreate with new schema
print("Creating users collection with new schema...")
import database_setup
print("✅ Users collection reset successfully!")
except Exception as e:
print(f"❌ Error: {e}")
finally:
client.close()
if __name__ == "__main__":
reset_users_collection() |