Skip to content

Commit

Permalink
fix: missing db
Browse files Browse the repository at this point in the history
  • Loading branch information
tbmc committed May 28, 2024
1 parent 65033b6 commit 0f7afd6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ cython_debug/

data_*.txt

.idea/*
test/
docs/
database.db
web-app/node_modules/*
web-app/.svelte-kit/*
web-app/build/*
3 changes: 3 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
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",
datefmt="%Y-%m-%d %H:%M:%S",
level=logging.INFO,
)

create_db()

app = flask.Flask(__name__)

CORS_HEADERS = {"Access-Control-Allow-Origin": "*"}
Expand Down
9 changes: 7 additions & 2 deletions calendar_connector/database/create_tables.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ services:
- "5000:5000"
volumes:
- ./sporteasy-calendar-connector-logs:/logs
restart: unless-stopped
- ./database.db:/app/database.db
restart: unless-stopped

0 comments on commit 0f7afd6

Please sign in to comment.