softdelete users and migration script
This commit is contained in:
+12
-1
@@ -84,13 +84,24 @@ class RadadminClient(Base):
|
||||
__tablename__ = "radadmin_clients"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
mac_address: Mapped[str] = mapped_column(String(17), nullable=False, unique=True)
|
||||
# Not DB-unique on its own — uniqueness is enforced only among live rows by the
|
||||
# generated `active_mac` column (see radadmin_schema.sql). Soft-deleted rows
|
||||
# (deleted_at set) may share a mac_address with the live row and each other.
|
||||
mac_address: Mapped[str] = mapped_column(String(17), nullable=False)
|
||||
name: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
phone: Mapped[str | None] = mapped_column(String(32), nullable=True)
|
||||
alias: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
# Mirror of the client's group (radusergroup) and billing status (customers):
|
||||
# set on add, synced on edit, and kept frozen on the row after soft-delete so
|
||||
# the deleted client's group/status survive their hard-deleted source rows.
|
||||
groupname: Mapped[str | None] = mapped_column(String(64), nullable=True, default=None)
|
||||
status: Mapped[str | None] = mapped_column(String(10), nullable=True, default=None)
|
||||
created_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime, nullable=True, server_default=func.current_timestamp()
|
||||
)
|
||||
# Soft delete: NULL = live, a timestamp = deleted. Deleted rows are never
|
||||
# returned by the API and are kept only for restore/reference.
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, default=None)
|
||||
|
||||
|
||||
class RadadminDevice(Base):
|
||||
|
||||
Reference in New Issue
Block a user