From d36517a36cdb44d2bdd3717ace25f737a5d06511 Mon Sep 17 00:00:00 2001 From: Igor Benav Date: Tue, 28 May 2024 21:47:22 -0300 Subject: [PATCH] warning plus import for db migrations --- README.md | 6 ++++++ src/app/core/setup.py | 5 ++--- src/app/models/__init__.py | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3115bb7..4fea298 100644 --- a/README.md +++ b/README.md @@ -493,6 +493,9 @@ To create the first tier it's similar, you just replace `create_superuser` for ` ### 4.4 Database Migrations +> \[!WARNING\] +> To create the tables if you did not create the endpoints, ensure that you import the models in src/app/models/__init__.py. This step is crucial to create the new tables. + If you are using the db in docker, you need to change this in `docker-compose.yml` to run migrations: ```sh @@ -737,6 +740,9 @@ class EntityDelete(BaseModel): ### 5.5 Alembic Migrations +> \[!WARNING\] +> To create the tables if you did not create the endpoints, ensure that you import the models in src/app/models/__init__.py. This step is crucial to create the new models. + Then, while in the `src` folder, run Alembic migrations: ```sh diff --git a/src/app/core/setup.py b/src/app/core/setup.py index 40701f1..a9c3662 100644 --- a/src/app/core/setup.py +++ b/src/app/core/setup.py @@ -24,10 +24,9 @@ RedisRateLimiterSettings, settings, ) -from .db.database import Base -from .db.database import async_engine as engine +from .db.database import Base, async_engine as engine from .utils import cache, queue, rate_limit - +from ..models import * # -------------- database -------------- async def create_tables() -> None: diff --git a/src/app/models/__init__.py b/src/app/models/__init__.py index e69de29..c44c105 100644 --- a/src/app/models/__init__.py +++ b/src/app/models/__init__.py @@ -0,0 +1,4 @@ +from .post import Post +from .rate_limit import RateLimit +from .tier import Tier +from .user import User