items-models-import-error
This commit is contained in:
parent
938f950646
commit
7c35097c88
5 changed files with 94 additions and 32 deletions
|
|
@ -8,10 +8,11 @@ from fastapi import Depends, HTTPException
|
|||
from typing import Annotated
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from pydantic.networks import EmailStr
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import Integer, DateTime
|
||||
from sqlalchemy.orm import Session, relationship, mapped_column, Mapped
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
from email.message import EmailMessage
|
||||
|
||||
import jwt
|
||||
|
||||
class Token(BaseModel):
|
||||
|
|
@ -59,16 +60,20 @@ class UserCreate(BaseModel):
|
|||
class DBUser(Base):
|
||||
__tablename__ = "users_table"
|
||||
|
||||
user_id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String, unique=True, index=True, nullable=False)
|
||||
email = Column(String, unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String, nullable=False)
|
||||
role = Column(String, default="user")
|
||||
status = Column(String, default="active")
|
||||
created_date = Column(String, default=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S"))
|
||||
bio = Column(String, default="No bio")
|
||||
collections = Column(ARRAY(String), default=['likes'])
|
||||
follower_user = Column(ARRAY(Integer), default=[])
|
||||
user_id: Mapped[int] = mapped_column(primary_key=True, index=True, autoincrement=True)
|
||||
username : Mapped[str] = mapped_column(unique=True, index=True, nullable=False)
|
||||
email : Mapped[str] = mapped_column(unique=True, index=True, nullable=False)
|
||||
hashed_password : Mapped[str] = mapped_column(nullable=False)
|
||||
role : Mapped[Role] = mapped_column(default=Role.user)
|
||||
status : Mapped[Status] = mapped_column(default=Status.active)
|
||||
created_date : Mapped[datetime] = mapped_column(DateTime, default=datetime.now()) #datetime.datetime -> python, DateTime -> sqlalchemy
|
||||
bio : Mapped[str] = mapped_column(default="No bio")
|
||||
follow_users : Mapped[list[int]] = mapped_column(ARRAY(Integer), default=[]) # takip edilen kullanıcılar
|
||||
|
||||
# -> buralar diğer tablolar ile olan ilişkiler
|
||||
from ..items.models import Items
|
||||
items : Mapped[list['Items']] = relationship("Items", back_populates="user", cascade="all, delete-orphan", lazy='select')
|
||||
|
||||
|
||||
|
||||
### AUTH ###
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue