合入家庭共享与设备消息能力
This commit is contained in:
@@ -169,7 +169,7 @@ class Card(Base):
|
||||
class Parent(Base):
|
||||
__tablename__ = "parents"
|
||||
|
||||
user_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
openid: Mapped[str] = mapped_column(String(64), unique=True, nullable=False)
|
||||
unionid: Mapped[Optional[str]] = mapped_column(String(64))
|
||||
nickname: Mapped[Optional[str]] = mapped_column(String(64))
|
||||
@@ -184,7 +184,7 @@ class Parent(Base):
|
||||
class Child(Base):
|
||||
__tablename__ = "children"
|
||||
|
||||
child_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
child_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
child_name: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
child_gender: Mapped[int] = mapped_column(Integer, server_default="2")
|
||||
child_birthday: Mapped[Optional[date]] = mapped_column(Date)
|
||||
@@ -201,9 +201,9 @@ class ParentChildRelation(Base):
|
||||
Index("idx_pcr_child_id", "child_id"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
child_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True)
|
||||
child_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True)
|
||||
relation_type: Mapped[int] = mapped_column(Integer, server_default="9")
|
||||
is_primary: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
status: Mapped[int] = mapped_column(Integer, server_default="1")
|
||||
@@ -219,10 +219,10 @@ class DeviceBinding(Base):
|
||||
Index("idx_device_bindings_owner_user_id", "owner_user_id"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
device_id: Mapped[str] = mapped_column(String(64), nullable=False, unique=True)
|
||||
owner_user_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
child_id: Mapped[Optional[int]] = mapped_column(Integer)
|
||||
owner_user_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
||||
child_id: Mapped[Optional[int]] = mapped_column(BigInteger)
|
||||
status: Mapped[int] = mapped_column(Integer, server_default="1")
|
||||
bound_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
||||
unbound_at: Mapped[Optional[datetime]] = mapped_column(DateTime)
|
||||
@@ -230,14 +230,55 @@ class DeviceBinding(Base):
|
||||
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
|
||||
|
||||
|
||||
class DeviceFamilyMember(Base):
|
||||
__tablename__ = "device_family_members"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("device_id", "user_id", name="uq_device_family_member"),
|
||||
Index("idx_device_family_members_device_status", "device_id", "status"),
|
||||
Index("idx_device_family_members_user_status", "user_id", "status"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
device_id: Mapped[str] = mapped_column(String(64), ForeignKey("device_auth.device_id"), nullable=False)
|
||||
user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("parents.user_id"), nullable=False)
|
||||
role: Mapped[int] = mapped_column(Integer, server_default="2")
|
||||
status: Mapped[int] = mapped_column(Integer, server_default="1")
|
||||
invited_by_user_id: Mapped[Optional[int]] = mapped_column(BigInteger, ForeignKey("parents.user_id", ondelete="SET NULL"))
|
||||
joined_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
|
||||
removed_at: Mapped[Optional[datetime]] = mapped_column(DateTime)
|
||||
created_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
|
||||
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"), onupdate=datetime.utcnow)
|
||||
|
||||
|
||||
class DeviceFamilyInvitation(Base):
|
||||
__tablename__ = "device_family_invitations"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("invite_token", name="uq_device_family_invite_token"),
|
||||
Index("idx_device_family_invites_device_status", "device_id", "status"),
|
||||
Index("idx_device_family_invites_owner_status", "owner_user_id", "status"),
|
||||
Index("idx_device_family_invites_expires_at", "expires_at"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
invite_token: Mapped[str] = mapped_column(String(36), nullable=False)
|
||||
device_id: Mapped[str] = mapped_column(String(64), ForeignKey("device_auth.device_id"), nullable=False)
|
||||
owner_user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("parents.user_id"), nullable=False)
|
||||
status: Mapped[int] = mapped_column(Integer, server_default="1")
|
||||
expires_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
||||
accepted_by_user_id: Mapped[Optional[int]] = mapped_column(BigInteger, ForeignKey("parents.user_id", ondelete="SET NULL"))
|
||||
accepted_at: Mapped[Optional[datetime]] = mapped_column(DateTime)
|
||||
created_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
|
||||
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"), onupdate=datetime.utcnow)
|
||||
|
||||
|
||||
class DeviceBindSession(Base):
|
||||
__tablename__ = "device_bind_sessions"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
bind_token: Mapped[str] = mapped_column(String(36), unique=True, nullable=False)
|
||||
device_id: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
initiator_user_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
target_child_id: Mapped[Optional[int]] = mapped_column(Integer)
|
||||
initiator_user_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
||||
target_child_id: Mapped[Optional[int]] = mapped_column(BigInteger)
|
||||
challenge_code_hash: Mapped[Optional[str]] = mapped_column(String(64))
|
||||
challenge_set_at: Mapped[Optional[datetime]] = mapped_column(DateTime)
|
||||
expires_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
||||
@@ -253,11 +294,11 @@ class DeviceBindSession(Base):
|
||||
class DeviceBindHistory(Base):
|
||||
__tablename__ = "device_bind_history"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
device_id: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
child_id: Mapped[Optional[int]] = mapped_column(Integer)
|
||||
bound_by_user_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
unbound_by_user_id: Mapped[Optional[int]] = mapped_column(Integer)
|
||||
child_id: Mapped[Optional[int]] = mapped_column(BigInteger)
|
||||
bound_by_user_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
||||
unbound_by_user_id: Mapped[Optional[int]] = mapped_column(BigInteger)
|
||||
bind_source: Mapped[int] = mapped_column(Integer, server_default="1")
|
||||
bound_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
||||
unbound_at: Mapped[Optional[datetime]] = mapped_column(DateTime)
|
||||
@@ -271,6 +312,8 @@ class DeviceSetting(Base):
|
||||
setting_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
device_id: Mapped[str] = mapped_column(String(64), unique=True, nullable=False)
|
||||
sleep_mode: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
manual_sleep_mode: Mapped[int] = mapped_column(Integer, nullable=False, server_default="0")
|
||||
schedule_suppressed_until: Mapped[Optional[datetime]] = mapped_column(DateTime)
|
||||
disable_time_start: Mapped[Optional[time]] = mapped_column(Time)
|
||||
disable_time_end: Mapped[Optional[time]] = mapped_column(Time)
|
||||
timezone: Mapped[str] = mapped_column(String(32), server_default=text("'Asia/Shanghai'"))
|
||||
|
||||
Reference in New Issue
Block a user