From 339ae64363bdb8d9822bc59adebb452e4f04c2d4 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Fri, 30 Dec 2022 23:01:21 +0100 Subject: [PATCH] Add message_id and chat_id to CachedFile --- src/app/alembic/versions/f77b0b14f9eb_.py | 28 +++++++++++++++++++++++ src/app/models.py | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 src/app/alembic/versions/f77b0b14f9eb_.py diff --git a/src/app/alembic/versions/f77b0b14f9eb_.py b/src/app/alembic/versions/f77b0b14f9eb_.py new file mode 100644 index 0000000..a6c6c51 --- /dev/null +++ b/src/app/alembic/versions/f77b0b14f9eb_.py @@ -0,0 +1,28 @@ +"""empty message + +Revision ID: f77b0b14f9eb +Revises: 9b7cfb422191 +Create Date: 2022-12-30 22:53:41.951490 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "f77b0b14f9eb" +down_revision = "9b7cfb422191" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + "cached_files", sa.Column("message_id", sa.BigInteger(), nullable=True) + ) + op.add_column("cached_files", sa.Column("chat_id", sa.BigInteger(), nullable=True)) + + +def downgrade(): + op.drop_column("cached_files", "message_id") + op.drop_column("cached_files", "chat_id") diff --git a/src/app/models.py b/src/app/models.py index d357454..db0e2e3 100644 --- a/src/app/models.py +++ b/src/app/models.py @@ -16,4 +16,8 @@ class CachedFile(ormar.Model): 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 + + message_id: int = ormar.BigInteger() # type: ignore + chat_id: int = ormar.BigInteger() # type: ignore + data: dict = ormar.JSON() # type: ignore