forked from VinokurovVE/tests
crud api
This commit is contained in:
21
backend_fastapi/models.py
Normal file
21
backend_fastapi/models.py
Normal file
@ -0,0 +1,21 @@
|
||||
from .database import Model
|
||||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
from sqlalchemy import String, Boolean, ForeignKey
|
||||
|
||||
class Role(Model):
|
||||
__tablename__ = "roles"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(255),nullable=False)
|
||||
|
||||
class User(Model):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[int] = mapped_column( primary_key=True)
|
||||
firstname: Mapped[str] = mapped_column(String(255),nullable=False)
|
||||
lastname: Mapped[str] = mapped_column(String(255),nullable=False)
|
||||
email: Mapped[str] = mapped_column(String(255),nullable=False)
|
||||
hashed_password: Mapped[str] = mapped_column(String(255),nullable=False)
|
||||
is_active: Mapped[bool] = mapped_column(Boolean,default=True)
|
||||
role_id: Mapped[int] = mapped_column(ForeignKey("roles.id"))
|
||||
role: Mapped["Role"] = relationship()
|
Reference in New Issue
Block a user