diff --git a/README.md b/README.md index f9af7b5..bab9c66 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,9 @@ vi config.json Rebuild containers: ``` docker compose up --build -d -``` \ No newline at end of file +``` + +Change the ownership of the db, such that the host user 1000 can write it: +``` +sudo chown -R 1000 data/ +``` diff --git a/create_task.py b/create_task.py index f52f006..788ef0d 100644 --- a/create_task.py +++ b/create_task.py @@ -5,6 +5,7 @@ from result import Err, Ok, Result from models import Task import argparse from sqlmodel import Session, SQLModel, create_engine +from main import * import sys import dateparser @@ -55,9 +56,6 @@ if __name__ == "__main__": print("Invalid due date.", file=sys.stderr) exit(1) - engine = create_engine("sqlite:///data.db") - SQLModel.metadata.create_all(engine) - with Session(engine) as session: task = Task( name=args.name, diff --git a/data/.keep b/data/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml index 788d312..b58d417 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,4 +12,4 @@ services: build: . volumes: - "./config.json:/app/config.json" - - "./data.db:/app/data.db" + - "./data:/app/data" diff --git a/main.py b/main.py index c665fec..fbcf728 100644 --- a/main.py +++ b/main.py @@ -546,7 +546,7 @@ async def main(config: Config, session: Session): with open("config.json", "r") as f: config = Config.model_validate(json.load(f)) -engine = create_engine("sqlite:///data.db") +engine = create_engine("sqlite:///data/data.db") SQLModel.metadata.create_all(engine) if __name__ == "__main__":