implement lazy database initialization and ensure database setup in routes
All checks were successful
Build and Push Image / build-and-push (push) Successful in 15s

This commit is contained in:
Michael Trip 2026-01-09 22:29:28 +01:00
parent 995cadeb27
commit ae0556468f
2 changed files with 22 additions and 4 deletions

View file

@ -6,6 +6,13 @@ from config import Config
db = SQLAlchemy()
login_manager = LoginManager()
def ensure_database():
"""Initialize database tables if they don't exist"""
try:
db.create_all()
except Exception as e:
print(f"Database initialization error: {e}")
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
@ -24,8 +31,4 @@ def create_app():
from app.routes import bp as main_bp
app.register_blueprint(main_bp)
# Initialize database tables
with app.app_context():
db.create_all()
return app