mirror of
https://github.com/StefBuwalda/dashboard_test.git
synced 2025-10-30 11:19:58 +00:00
MAJOR REFACTOR P1
This commit is contained in:
21
app/__init__.py
Normal file
21
app/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate, upgrade, stamp
|
||||
from .flask_app import app
|
||||
from pathlib import Path
|
||||
|
||||
__all__ = ["app"]
|
||||
|
||||
# Create db
|
||||
db = SQLAlchemy(app=app)
|
||||
|
||||
# Set up migration
|
||||
migration = Migrate(app=app, db=db)
|
||||
|
||||
# Init and upgrade
|
||||
with app.app_context():
|
||||
# Check if DB file is missing
|
||||
if not (Path("./instance/app.db").is_file()):
|
||||
db.create_all()
|
||||
stamp()
|
||||
# Upgrade db if any new migrations exist
|
||||
upgrade()
|
||||
Reference in New Issue
Block a user