mirror of
https://github.com/StefBuwalda/dashboard_test.git
synced 2025-10-30 03:09:59 +00:00
Creates db and assumes it's up to date. This replaces init()
This commit is contained in:
14
app.py
14
app.py
@@ -1,19 +1,19 @@
|
||||
# import requests as r
|
||||
from flask import jsonify, render_template, send_file
|
||||
from poll_services import start_async_loop
|
||||
from mem import services, app
|
||||
from mem import services, app, db
|
||||
import threading
|
||||
from flask_migrate import init, upgrade
|
||||
from flask_migrate import upgrade, stamp
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Init and upgrade
|
||||
with app.app_context():
|
||||
# Check if DB file or migrations folder is missing
|
||||
if not (
|
||||
Path("./instance/app.db").is_file() and Path("./migrations").is_dir()
|
||||
):
|
||||
init()
|
||||
# Check if DB file is missing
|
||||
if not (Path("./instance/app.db").is_file()):
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
stamp()
|
||||
# Upgrade db if any new migrations exist
|
||||
upgrade()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user