forked from hesabix/arc
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, JSON, String, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from adapters.db.session import Base
|
|
|
|
|
|
class ProfileUserDashboardLayout(Base):
|
|
"""چیدمان داشبورد پروفایل کاربر بهازای breakpoint (پایدار برای وب و چند worker)."""
|
|
|
|
__tablename__ = "profile_user_dashboard_layouts"
|
|
__table_args__ = (
|
|
UniqueConstraint("user_id", "breakpoint", name="uq_pudl_user_bp"),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
user_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
|
breakpoint: Mapped[str] = mapped_column(String(8), nullable=False, index=True)
|
|
# items: [{ key, order, colSpan, rowSpan, hidden }, ...]
|
|
items: Mapped[list] = mapped_column(JSON, nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
|
|
)
|