Remove data field

This commit is contained in:
2022-12-30 23:46:51 +01:00
parent 339ae64363
commit 8ce7cce01a
5 changed files with 61 additions and 38 deletions

View File

@@ -11,13 +11,20 @@ class BaseMeta(ormar.ModelMeta):
class CachedFile(ormar.Model):
class Meta(BaseMeta):
tablename = "cached_files"
constraints = [ormar.UniqueColumns("object_id", "object_type")]
constraints = [
ormar.UniqueColumns("object_id", "object_type"),
ormar.UniqueColumns("message_id", "chat_id"),
]
id: int = ormar.Integer(primary_key=True) # type: ignore
object_id: int = ormar.Integer(index=True) # type: ignore
object_type: str = ormar.String(max_length=8, index=True) # type: ignore
object_type: str = ormar.String(
max_length=8, index=True, unique=True
) # type: ignore
message_id: int = ormar.BigInteger() # type: ignore
message_id: int = ormar.BigInteger(index=True) # type: ignore
chat_id: int = ormar.BigInteger() # type: ignore
data: dict = ormar.JSON() # type: ignore
@property
def data(self) -> dict:
return {"message_id": self.message_id, "chat_id": self.chat_id}