From fee79f76b94fae69f7635fa3181c36ebf0fe11a6 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 12 Oct 2024 19:40:03 -0700 Subject: [PATCH] Small bug fixes and updates (#52) * chore: clean up * chore: bump version --- pyproject.toml | 2 +- .../.github/workflows/main.yml | 3 +-- .../.github/workflows/unit-tests.yml | 2 +- {{ cookiecutter.project_slug }}/README.md | 20 +++++++++++++++++++ .../pyproject.toml | 2 +- .../src/db/init_db.py | 1 + 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9659e9c..dfd1829 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cookiecutter-fastapi-backend" -version = "0.4.0" +version = "0.4.1" description = "Cookiecutter template to build and deploy fastapi backends..batteries included" authors = ["nickatnight "] readme = "README.md" diff --git a/{{ cookiecutter.project_slug }}/.github/workflows/main.yml b/{{ cookiecutter.project_slug }}/.github/workflows/main.yml index d26ed9f..ce58b2f 100644 --- a/{{ cookiecutter.project_slug }}/.github/workflows/main.yml +++ b/{{ cookiecutter.project_slug }}/.github/workflows/main.yml @@ -5,8 +5,7 @@ on: tags: - '*' branches: - - master - - develop + - main {%- if cookiecutter.deployments == 'yes' %} env: diff --git a/{{ cookiecutter.project_slug }}/.github/workflows/unit-tests.yml b/{{ cookiecutter.project_slug }}/.github/workflows/unit-tests.yml index 252f0e9..02c6119 100644 --- a/{{ cookiecutter.project_slug }}/.github/workflows/unit-tests.yml +++ b/{{ cookiecutter.project_slug }}/.github/workflows/unit-tests.yml @@ -24,4 +24,4 @@ jobs: - name: Clean-up if: always() run: | - docker-compose -f ops/docker-compose.test.yml down -v + docker compose -f ops/docker-compose.test.yml down -v diff --git a/{{ cookiecutter.project_slug }}/README.md b/{{ cookiecutter.project_slug }}/README.md index 3972103..84eaa2b 100644 --- a/{{ cookiecutter.project_slug }}/README.md +++ b/{{ cookiecutter.project_slug }}/README.md @@ -23,7 +23,27 @@ ## Backend local development, additional details +Initialize first migration (project must be up with docker compose up and contain no 'version' files) +```shell +$ make alembic-init +``` + +Create new migration file +```shell +$ docker compose exec {{ cookiecutter.backend_container_name }} alembic revision --autogenerate -m "some cool comment" +``` + +Apply migrations +```shell +$ make alembic-migrate +``` + ### Migrations +Every migration after that, you can create new migrations and apply them with +```console +$ make alembic-make-migrations "cool comment dude" +$ make alembic-migrate +``` ### General workflow See the [Makefile](/Makefile) to view available commands. diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/pyproject.toml b/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/pyproject.toml index a2b6fd0..07755a4 100644 --- a/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/pyproject.toml +++ b/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/pyproject.toml @@ -82,7 +82,7 @@ lint.ignore = [ ignore-words-list = 'selectin,' [tool.coverage.report] -fail_under = 55 +fail_under = 20 [tool.coverage.run] omit = ['*tests/*'] diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/src/db/init_db.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/src/db/init_db.py index 6a1f98f..765c3b0 100644 --- a/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/src/db/init_db.py +++ b/{{ cookiecutter.project_slug }}/{{ cookiecutter.backend_container_name }}/src/db/init_db.py @@ -11,6 +11,7 @@ def create_init_data() -> None: with SessionLocal() as session: + # Add initial data here eg session.add(Model(field=value)) session.add() session.add()