mirror of
https://github.com/kevin-DL/full-stack-fastapi-postgresql.git
synced 2026-01-14 02:54:44 +00:00
* Update CRUD utils to use types better. * Simplify Pydantic model names, from `UserInCreate` to `UserCreate`, etc. * Upgrade packages. * Add new generic "Items" models, crud utils, endpoints, and tests. To facilitate re-using them to create new functionality. As they are simple and generic (not like Users), it's easier to copy-paste and adapt them to each use case. * Update endpoints/*path operations* to simplify code and use new utilities, prefix and tags in `include_router`. * Update testing utils. * Update linting rules, relax vulture to reduce false positives. * Update migrations to include new Items. * Update project README.md with tips about how to start with backend.
20 lines
635 B
Python
20 lines
635 B
Python
from app import crud
|
|
from app.core import config
|
|
from app.models.user import UserCreate
|
|
|
|
|
|
def init_db(db_session):
|
|
# Tables should be created with Alembic migrations
|
|
# But if you don't want to use migrations, create
|
|
# the tables un-commenting the next line
|
|
# Base.metadata.create_all(bind=engine)
|
|
|
|
user = crud.user.get_by_email(db_session, email=config.FIRST_SUPERUSER)
|
|
if not user:
|
|
user_in = UserCreate(
|
|
email=config.FIRST_SUPERUSER,
|
|
password=config.FIRST_SUPERUSER_PASSWORD,
|
|
is_superuser=True,
|
|
)
|
|
user = crud.user.create(db_session, user_in=user_in)
|