Spaces:
Sleeping
Sleeping
File size: 713 Bytes
697c967 | 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 | """
Simple script to recreate database tables
"""
import asyncio
from sqlmodel import SQLModel
from database.session import async_engine
from models.user import User
from models.task import Task
async def reset_database():
print("Dropping and recreating database tables...")
# Drop all tables first
async with async_engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.drop_all)
print("Tables dropped.")
# Create all tables
async with async_engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.create_all)
print("Tables recreated successfully!")
print("Database reset complete.")
if __name__ == "__main__":
asyncio.run(reset_database()) |