Add files via upload

This commit is contained in:
jasonMPM
2026-03-05 14:05:41 -06:00
committed by GitHub
parent aa6f1b9bb2
commit 9ec74eaeca

View File

@@ -1,5 +1,6 @@
import os
from flask import Flask, send_from_directory
from sqlalchemy import text
from .extensions import db, migrate, cors
from config import config
@@ -21,6 +22,7 @@ def create_app(config_name=None):
with app.app_context():
db.create_all()
_run_migrations()
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
@@ -31,3 +33,22 @@ def create_app(config_name=None):
return send_from_directory(static_folder, 'index.html')
return app
def _run_migrations():
"""
Safe idempotent migrations for existing databases.
ALTER TABLE is a no-op if the column already exists (exception silently caught).
Add new columns here as the schema evolves.
"""
migrations = [
'ALTER TABLE projects ADD COLUMN drive_url VARCHAR(500)',
]
with db.engine.connect() as conn:
for stmt in migrations:
try:
conn.execute(text(stmt))
conn.commit()
except Exception:
# Column already exists — safe to ignore
pass