From 0f7afd6cd055eccc5d0b7cd771930c8cc328e87f Mon Sep 17 00:00:00 2001 From: Thibault Date: Tue, 28 May 2024 15:30:48 +0200 Subject: [PATCH] fix: missing db --- .dockerignore | 4 ++++ app.py | 3 +++ calendar_connector/database/create_tables.py | 9 +++++++-- docker-compose.yml | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 90d7459..e93d4fe 100644 --- a/.dockerignore +++ b/.dockerignore @@ -162,6 +162,10 @@ cython_debug/ data_*.txt +.idea/* test/ docs/ database.db +web-app/node_modules/* +web-app/.svelte-kit/* +web-app/build/* diff --git a/app.py b/app.py index fb19c38..7838187 100644 --- a/app.py +++ b/app.py @@ -14,6 +14,7 @@ from calendar_connector.database.user import generate_links_data from calendar_connector.custom_exceptions import BadTokenException from calendar_connector.presence_updater import set_presence_to_event +from calendar_connector.database.create_tables import create_db logging.basicConfig( format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", @@ -21,6 +22,8 @@ level=logging.INFO, ) +create_db() + app = flask.Flask(__name__) CORS_HEADERS = {"Access-Control-Allow-Origin": "*"} diff --git a/calendar_connector/database/create_tables.py b/calendar_connector/database/create_tables.py index d471f1d..0978b56 100644 --- a/calendar_connector/database/create_tables.py +++ b/calendar_connector/database/create_tables.py @@ -1,12 +1,17 @@ +from typing import Optional + from peewee import SqliteDatabase from calendar_connector.database.db_connector import get_db from calendar_connector.database.all_models import ALL_MODELS -def create_db(db: SqliteDatabase) -> None: +def create_db(db: Optional[SqliteDatabase] = None) -> None: + if db is None: + db = get_db() db.create_tables(ALL_MODELS) if __name__ == "__main__": - create_db(get_db()) + create_db() + print("Created tables") diff --git a/docker-compose.yml b/docker-compose.yml index 61794f0..e27aaa9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,4 +8,5 @@ services: - "5000:5000" volumes: - ./sporteasy-calendar-connector-logs:/logs - restart: unless-stopped \ No newline at end of file + - ./database.db:/app/database.db + restart: unless-stopped