diff --git a/services/cookies/models.py b/services/cookies/models.py index 4df0ba3..ab8d408 100644 --- a/services/cookies/models.py +++ b/services/cookies/models.py @@ -29,10 +29,10 @@ class Cookies(SQLModel): BigInteger(), ), ) - data: Optional[Dict[str, str]] = Field(sa_column=Column(JSON)) - status: Optional[CookiesStatusEnum] = Field(sa_column=Column(Enum(CookiesStatusEnum))) + data: Optional[Dict[str, str]] = Field(default=None, sa_column=Column(JSON)) + status: Optional[CookiesStatusEnum] = Field(default=None, sa_column=Column(Enum(CookiesStatusEnum))) region: RegionEnum = Field(sa_column=Column(Enum(RegionEnum))) - is_share: Optional[bool] = Field(sa_column=Column(Boolean)) + is_share: Optional[bool] = Field(default=True, sa_column=Column(Boolean)) class CookiesDataBase(Cookies, table=True): diff --git a/services/gacha_log_rank/models.py b/services/gacha_log_rank/models.py index e81347b..1456dd5 100644 --- a/services/gacha_log_rank/models.py +++ b/services/gacha_log_rank/models.py @@ -40,11 +40,13 @@ class GachaLogRank(SQLModel, table=True): """小保底不歪概率""" score_5: int = Field(sa_column=Column(BigInteger(), default=0)) """保留字段""" - data: Optional[Dict[str, Any]] = Field(sa_column=Column(JSON)) + data: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON)) time_created: Optional[datetime] = Field( - sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 + default=None, sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 ) - time_updated: Optional[datetime] = Field(sa_column=Column(DateTime, onupdate=func.now())) # pylint: disable=E1102 + time_updated: Optional[datetime] = Field( + default=None, sa_column=Column(DateTime, onupdate=func.now()) + ) # pylint: disable=E1102 def update_by_new(self, new_ins: "GachaLogRank"): self.score_1 = new_ins.score_1 diff --git a/services/groups/models.py b/services/groups/models.py index 0050697..4baed3f 100644 --- a/services/groups/models.py +++ b/services/groups/models.py @@ -28,10 +28,10 @@ class Group(SQLModel): chat_id: int = Field(sa_column=Column(BigInteger(), unique=True)) type: ChatTypeEnum = Field(sa_column=Column(Enum(ChatTypeEnum))) title: str = Field() - description: Optional[str] = Field(sa_column=Column(TEXT())) - username: Optional[str] = Field() - big_photo_id: Optional[str] = Field() - small_photo_id: Optional[str] = Field() + description: Optional[str] = Field(default=None, sa_column=Column(TEXT())) + username: Optional[str] = Field(default=None) + big_photo_id: Optional[str] = Field(default=None) + small_photo_id: Optional[str] = Field(default=None) created_at: datetime = Field(sa_column=Column(DateTime(timezone=True))) updated_at: datetime = Field(sa_column=Column(DateTime(timezone=True))) is_left: int = Field(sa_column=Column(Integer(), default=0)) diff --git a/services/history_data/models.py b/services/history_data/models.py index edaa230..6980d33 100644 --- a/services/history_data/models.py +++ b/services/history_data/models.py @@ -14,8 +14,10 @@ class HistoryData(SQLModel, table=True): user_id: int = Field(sa_column=Column(BigInteger(), primary_key=True, index=True)) data_id: Optional[int] = Field(default=None, sa_column=Column(BigInteger())) time_created: Optional[datetime] = Field( - sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 + default=None, sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 ) - time_updated: Optional[datetime] = Field(sa_column=Column(DateTime, onupdate=func.now())) # pylint: disable=E1102 + time_updated: Optional[datetime] = Field( + default=None, sa_column=Column(DateTime, onupdate=func.now()) + ) # pylint: disable=E1102 type: int = Field(sa_column=Column(Integer(), primary_key=True)) - data: Optional[Dict[str, Any]] = Field(sa_column=Column(JSON)) + data: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON)) diff --git a/services/players/models.py b/services/players/models.py index 6d0a1a0..ff389f6 100644 --- a/services/players/models.py +++ b/services/players/models.py @@ -80,16 +80,18 @@ class PlayerInfo(SQLModel): id: Optional[int] = Field(default=None, sa_column=Column(Integer(), primary_key=True, autoincrement=True)) user_id: int = Field(sa_column=Column(BigInteger(), primary_key=True)) player_id: int = Field(sa_column=Column(BigInteger(), primary_key=True)) - nickname: Optional[str] = Field() - signature: Optional[str] = Field() - hand_image: Optional[int] = Field() - name_card: Optional[int] = Field() - extra_data: Optional[ExtraPlayerInfo] = Field(sa_column=Column(ExtraPlayerType)) + nickname: Optional[str] = Field(default=None) + signature: Optional[str] = Field(default=None) + hand_image: Optional[int] = Field(default=None) + name_card: Optional[int] = Field(default=None) + extra_data: Optional[ExtraPlayerInfo] = Field(default=None, sa_column=Column(ExtraPlayerType)) create_time: Optional[datetime] = Field( - sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 + default=None, sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 ) - last_save_time: Optional[datetime] = Field(sa_column=Column(DateTime, onupdate=func.now())) # pylint: disable=E1102 - is_update: Optional[bool] = Field(sa_column=Column(Boolean)) + last_save_time: Optional[datetime] = Field( + default=None, sa_column=Column(DateTime, onupdate=func.now()) + ) # pylint: disable=E1102 + is_update: Optional[bool] = Field(default=None, sa_column=Column(Boolean)) class PlayerInfoSQLModel(PlayerInfo, table=True): diff --git a/services/task/models.py b/services/task/models.py index 06b8cd9..69b5573 100644 --- a/services/task/models.py +++ b/services/task/models.py @@ -36,9 +36,11 @@ class Task(SQLModel, table=True): player_id: int = Field(sa_column=Column(BigInteger(), primary_key=True, index=True)) chat_id: Optional[int] = Field(default=None, sa_column=Column(BigInteger())) time_created: Optional[datetime] = Field( - sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 + default=None, sa_column=Column(DateTime, server_default=func.now()) # pylint: disable=E1102 ) - time_updated: Optional[datetime] = Field(sa_column=Column(DateTime, onupdate=func.now())) # pylint: disable=E1102 + time_updated: Optional[datetime] = Field( + default=None, sa_column=Column(DateTime, onupdate=func.now()) + ) # pylint: disable=E1102 type: TaskTypeEnum = Field(sa_column=Column(Enum(TaskTypeEnum), primary_key=True)) - status: Optional[TaskStatusEnum] = Field(sa_column=Column(Enum(TaskStatusEnum))) - data: Optional[Dict[str, Any]] = Field(sa_column=Column(JSON)) + status: Optional[TaskStatusEnum] = Field(default=None, sa_column=Column(Enum(TaskStatusEnum))) + data: Optional[Dict[str, Any]] = Field(default=None, sa_column=Column(JSON)) diff --git a/services/users/models.py b/services/users/models.py index d627037..df91a40 100644 --- a/services/users/models.py +++ b/services/users/models.py @@ -21,11 +21,11 @@ class User(SQLModel): __table_args__ = dict(mysql_charset="utf8mb4", mysql_collate="utf8mb4_general_ci") id: Optional[int] = Field(default=None, sa_column=Column(Integer(), primary_key=True, autoincrement=True)) user_id: int = Field(sa_column=Column(BigInteger(), unique=True)) - permissions: Optional[PermissionsEnum] = Field(sa_column=Column(Enum(PermissionsEnum))) - locale: Optional[str] = Field() - ban_end_time: Optional[datetime] = Field(sa_column=Column(DateTime(timezone=True))) - ban_start_time: Optional[datetime] = Field(sa_column=Column(DateTime(timezone=True))) - is_banned: Optional[int] = Field() + permissions: Optional[PermissionsEnum] = Field(default=None, sa_column=Column(Enum(PermissionsEnum))) + locale: Optional[str] = Field(default=None) + ban_end_time: Optional[datetime] = Field(default=None, sa_column=Column(DateTime(timezone=True))) + ban_start_time: Optional[datetime] = Field(default=None, sa_column=Column(DateTime(timezone=True))) + is_banned: Optional[int] = Field(default=None) class UserDataBase(User, table=True):