Spaces:
Running
Running
| import os | |
| from flask import Flask | |
| from models import db | |
| app = Flask(__name__) | |
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| DB_PATH = os.path.join(BASE_DIR, 'alisto.db') | |
| app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_PATH}' | |
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | |
| db.init_app(app) | |
| def reset_database(): | |
| print("--- RESETTING DATABASE ---") | |
| # 1. Delete the old file if it exists | |
| if os.path.exists(DB_PATH): | |
| os.remove(DB_PATH) | |
| print(f"Deleted old database: {DB_PATH}") | |
| else: | |
| print("No old database found.") | |
| # 2. Create fresh tables | |
| with app.app_context(): | |
| db.create_all() | |
| print("✅ Success: Created new empty 'alisto.db' with correct columns.") | |
| if __name__ == "__main__": | |
| reset_database() |