Skip to content

Commit

Permalink
Add to User model table name, which produce before that errors, which…
Browse files Browse the repository at this point in the history
… cannot find table 'users', replace inheritance in api models instead creating new base, takes from database.py
  • Loading branch information
Maksymilian-Plywaczyk committed Nov 18, 2023
1 parent 7391942 commit 1f61bd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 4 additions & 7 deletions api/src/api/models.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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"""

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions api/src/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 1f61bd3

Please sign in to comment.