From 1f61bd346e782a1b751ca533aa952843a3fd90b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maksymilian=20P=C5=82ywaczyk?= Date: Sat, 18 Nov 2023 19:18:44 +0100 Subject: [PATCH] Add to User model table name, which produce before that errors, which cannot find table 'users', replace inheritance in api models instead creating new base, takes from database.py --- api/src/api/models.py | 11 ++++------- api/src/auth/models.py | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/api/src/api/models.py b/api/src/api/models.py index 60c19b7..39a1edb 100644 --- a/api/src/api/models.py +++ b/api/src/api/models.py @@ -1,6 +1,7 @@ """Describes models used in the project""" -from typing import List +from typing import List, Union +from api.databases import Base from geoalchemy2 import Geography from sqlalchemy import ( Boolean, @@ -14,14 +15,10 @@ Text, Time, ) -from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship +from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.types import LargeBinary -class Base(DeclarativeBase): - pass - - class City(Base): """City model""" @@ -52,7 +49,7 @@ class RoutePoint(Base): id = Column(Integer, primary_key=True) route: Mapped[int] = mapped_column(ForeignKey("routes.id")) city: Mapped[int] = mapped_column(ForeignKey("cities.id")) - restriction: Mapped[int | None] = mapped_column( + restriction: Mapped[Union[int, None]] = mapped_column( ForeignKey("route_point_restrictions.id") ) name = Column(String) diff --git a/api/src/auth/models.py b/api/src/auth/models.py index ba839eb..6342086 100644 --- a/api/src/auth/models.py +++ b/api/src/auth/models.py @@ -9,6 +9,10 @@ class User(SQLAlchemyBaseUserTable[int], Base): + """User model""" + + __tablename__ = "users" + id = Column(Integer, primary_key=True) nickname = Column(String, unique=True, nullable=False) created_at = Column(