Refactor client view
This commit is contained in:
@ -51,13 +51,22 @@ class Client(Base):
|
||||
"""Clients."""
|
||||
|
||||
__tablename__: str = "client"
|
||||
__table_args__: tuple[sa.UniqueConstraint, ...] = (
|
||||
sa.UniqueConstraint("name", "version", name="uq_client_name_version"),
|
||||
)
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(
|
||||
sa.Uuid(as_uuid=True), primary_key=True, default=uuid.uuid4
|
||||
)
|
||||
name: Mapped[str] = mapped_column(sa.String, unique=True)
|
||||
version: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=1)
|
||||
|
||||
name: Mapped[str] = mapped_column(sa.String, nullable=False)
|
||||
|
||||
description: Mapped[str | None] = mapped_column(sa.String, nullable=True)
|
||||
public_key: Mapped[str] = mapped_column(sa.Text)
|
||||
public_key: Mapped[str] = mapped_column(sa.Text, nullable=False)
|
||||
|
||||
is_active: Mapped[bool] = mapped_column(sa.Boolean, default=True)
|
||||
is_deleted: Mapped[bool] = mapped_column(sa.Boolean, default=False)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False
|
||||
@ -69,10 +78,26 @@ class Client(Base):
|
||||
onupdate=sa.func.now(),
|
||||
)
|
||||
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(
|
||||
sa.DateTime(timezone=True),
|
||||
nullable=True
|
||||
)
|
||||
|
||||
secrets: Mapped[list["ClientSecret"]] = relationship(
|
||||
back_populates="client", passive_deletes=True
|
||||
)
|
||||
|
||||
previous_version_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
sa.Uuid(as_uuid=True),
|
||||
sa.ForeignKey("client.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
)
|
||||
previous_version: Mapped["Client | None"] = relationship(
|
||||
"Client",
|
||||
remote_side=[id],
|
||||
backref="versions"
|
||||
)
|
||||
|
||||
policies: Mapped[list["ClientAccessPolicy"]] = relationship(back_populates="client")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user