diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/README.md b/fastapi_template/template/{{cookiecutter.project_name}}/README.md index 621d8f84b889f25e4cf361204670c5c2b22543ae..a0ea83d721f9597ef6c6480504fbb91446026aee 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/README.md +++ b/fastapi_template/template/{{cookiecutter.project_name}}/README.md @@ -5,3 +5,65 @@ Start a project with: ``` docker-compose -f deploy/docker-compose.yml --project-directory . up ``` + +## Pre-commit + +To install pre-commit simply run inside of the shell: +``` +pre-commit install +``` +{%- if cookiecutter.enable_kube == 'True' %} + +## Kubernetes +To run your app in kubernetes +just run: +``` +kubectl apply -f deploy/kube +``` + +It will create needed components. + +If you hasn't pushed to docker registry yet, you can build image locally. + +``` +docker-compose -f deploy/docker-compose.yml --project-directory . build +docker save --output {{cookiecutter.project_name}}.tar {{cookiecutter.project_name}}:latest +``` + +{%- endif %} +{%- if cookiecutter.enable_alembic == 'True' %} + +# Migrations + +If you want to migrate your database, you should run following commands: +```bash +# To run all migrations untill the migration with revision_id. +alembic upgrade "<revision_id>" + +# To perform all pending migrations. +alembic upgrade "head" +``` + +### Reverting migrations + +If you want to revert migrations, you should run: +```bash +# revert all migrations up to: revision_id. +alembic downgrade <revision_id> + +# Revert everything. + alembic downgrade base +``` + +### Miration generation + +To generate migrations you should run: +```bash +# For automatic change detection. +alembic revision --autogenerate + +# For empty file generation. +alembic revision +``` + +{%- endif %} diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml b/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml index 7df58b4ef5fb07d991025b48804b1f4b0b4097e6..1b7d87d0951531391ee02601ff7b16a9803e27db 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml +++ b/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml @@ -19,7 +19,7 @@ yarl = "^1.6.3" {%- if cookiecutter.db_info.name != "none" %} SQLAlchemy = {version = "^1.4", extras = ["mypy", "asyncio"]} {%- endif %} -{% if cookiecutter.enable_alembic == "True" %} +{%- if cookiecutter.enable_alembic == "True" %} alembic = "^1.6.5" {%- endif %} {%- if cookiecutter.db_info.name == "postgresql" %} diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db/migrations/README.md b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db/migrations/README.md deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/pyproject.toml b/pyproject.toml index 430cd17e881f5a989dd8d7c92e994115b9c63011..e0178acd2979eef1c4e429ab72046b7ab7c2ebc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fastapi_template" -version = "2.2.0" +version = "2.2.1" description = "Feature-rich robust FastAPI template" authors = ["Pavel Kirilin <win10@list.ru>"] packages = [