Spaces:
Sleeping
Sleeping
File size: 1,255 Bytes
7644eac |
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 |
"""
Migration script to add ResourceProgress table for persistent resource tracking.
Run this after updating models.py
"""
import sys
import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from web_app import create_app, db
from web_app.models import ResourceProgress
def migrate():
"""Create the resource_progress table"""
app = create_app()
with app.app_context():
print("Creating resource_progress table...")
# Create the table
db.create_all()
print("✅ ResourceProgress table created successfully!")
print("\nTable structure:")
print("- id (Primary Key)")
print("- user_id (Foreign Key -> users.id)")
print("- learning_path_id (Foreign Key -> user_learning_paths.id)")
print("- milestone_index (Integer)")
print("- resource_index (Integer)")
print("- resource_url (String)")
print("- completed (Boolean)")
print("- completed_at (DateTime)")
print("- created_at (DateTime)")
print("- updated_at (DateTime)")
print("\n✨ Users can now track resource completion persistently!")
if __name__ == "__main__":
migrate()
|