Add files via upload
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from flask import Flask, send_from_directory
|
from flask import Flask, send_from_directory
|
||||||
|
from sqlalchemy import text
|
||||||
from .extensions import db, migrate, cors
|
from .extensions import db, migrate, cors
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ def create_app(config_name=None):
|
|||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
_run_migrations()
|
||||||
|
|
||||||
@app.route('/', defaults={'path': ''})
|
@app.route('/', defaults={'path': ''})
|
||||||
@app.route('/<path:path>')
|
@app.route('/<path:path>')
|
||||||
@@ -31,3 +33,22 @@ def create_app(config_name=None):
|
|||||||
return send_from_directory(static_folder, 'index.html')
|
return send_from_directory(static_folder, 'index.html')
|
||||||
|
|
||||||
return app
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user