File size: 1,229 Bytes
f742815 | 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 30 31 32 33 34 35 36 37 38 39 40 | """
Clear all database data and reinitialize with fresh tables
"""
from app import app, db
from models import User, Student, Classroom, AttendanceSession, AttendanceRecord
def clear_database():
"""Drop all tables and recreate them"""
with app.app_context():
print("Clearing database...")
print("="*70)
# Drop all tables
db.drop_all()
print("[OK] Dropped all tables")
# Recreate all tables
db.create_all()
print("[OK] Created fresh tables")
print("="*70)
print("Database cleared successfully!")
print("\nAll data has been removed:")
print(" - Users: 0")
print(" - Students: 0")
print(" - Classrooms: 0")
print(" - Attendance Sessions: 0")
print(" - Attendance Records: 0")
print("="*70)
print("\nNext steps:")
print("1. Run: python add_utm_venues.py (to add classrooms)")
print("2. Run: python add_home_venue.py (to add Puteri Court)")
print("3. Register new accounts at: http://localhost:5000/register")
print("="*70)
if __name__ == '__main__':
clear_database()
|