commit
9c5fef1a4d
412 files changed
+94582
No files matched your search
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, Index, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from sakura_cloud.db.base import Base
|
||||
from sakura_cloud.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
||||
|
||||
|
||||
class Device(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||
__tablename__ = "devices"
|
||||
|
||||
user_id: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
device_name: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
device_type: Mapped[str] = mapped_column(String(20), nullable=False)
|
||||
device_token: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
||||
last_active_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
last_sync_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
user = relationship("User", back_populates="devices")
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_devices_user_id", "user_id"),
|
||||
Index("idx_devices_last_active", "last_active_at"),
|
||||
)
|
||||
Reference in new issue
Block a user