| """
|
| 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)
|
|
|
|
|
| db.drop_all()
|
| print("[OK] Dropped 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()
|
|
|