47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Database initialization script.
|
|
Run this script to create all database tables.
|
|
|
|
Usage:
|
|
python init_db.py
|
|
"""
|
|
|
|
import asyncio
|
|
from database.database import init_db, drop_db
|
|
|
|
|
|
async def main():
|
|
"""Initialize database tables"""
|
|
print("=" * 50)
|
|
print("Database Initialization Script")
|
|
print("=" * 50)
|
|
|
|
choice = input("\nWhat would you like to do?\n1. Create tables (init)\n2. Drop and recreate tables (reset)\n3. Exit\n\nChoice: ")
|
|
|
|
if choice == "1":
|
|
print("\nCreating database tables...")
|
|
await init_db()
|
|
print("✅ Database initialized successfully!")
|
|
|
|
elif choice == "2":
|
|
confirm = input("\n⚠️ WARNING: This will DELETE ALL DATA! Are you sure? (yes/no): ")
|
|
if confirm.lower() == "yes":
|
|
print("\nDropping existing tables...")
|
|
await drop_db()
|
|
print("Creating new tables...")
|
|
await init_db()
|
|
print("✅ Database reset successfully!")
|
|
else:
|
|
print("❌ Operation cancelled")
|
|
|
|
elif choice == "3":
|
|
print("Exiting...")
|
|
|
|
else:
|
|
print("❌ Invalid choice")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|