work still in progress
This commit is contained in:
@@ -130,12 +130,13 @@ def init_db(app: Flask) -> None:
|
|||||||
- Prints status messages to console during initialization
|
- Prints status messages to console during initialization
|
||||||
"""
|
"""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
if not db.engine.dialect.has_table(db.engine.connect(), "image"):
|
if getenv("CLEAR_AT_RESTART", "0") == "1": # Force clear if CLEAR_AT_RESTART
|
||||||
print(f"CLEAR_AT_RESTART={getenv('CLEAR_AT_RESTART', '0')}")
|
print("Clearing database and file system at restart...")
|
||||||
if getenv("CLEAR_AT_RESTART", "0") == "1":
|
db.drop_all() # Clear existing tables if configured
|
||||||
print("Clearing database and file system at restart...")
|
db.session.commit() # pylint: disable=no-member
|
||||||
db.drop_all() # Clear existing tables if configured
|
rmtree(Path("./results"), ignore_errors=True) # Clear results folder
|
||||||
rmtree(Path("./results"), ignore_errors=True) # Clear results folder
|
|
||||||
|
if not db.engine.dialect.has_table(db.engine.connect(), "image"): # If not configured
|
||||||
db.create_all()
|
db.create_all()
|
||||||
print("Database structure created successfully.")
|
print("Database structure created successfully.")
|
||||||
if getenv("SKIP_IHDR_FILL", "0") == "1":
|
if getenv("SKIP_IHDR_FILL", "0") == "1":
|
||||||
|
|||||||
Reference in New Issue
Block a user