Skip to content

Commit

Permalink
Merge pull request #2 from vector-im/tadzik/fix-rmau-column-sizes
Browse files Browse the repository at this point in the history
Increase UserActivity DB column sizes
  • Loading branch information
tadzik authored Oct 8, 2021
2 parents 251cf46 + a66b700 commit 430c3cf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""increase account activity column sizes
Revision ID: 143181919790
Revises: 97404229e75e
Create Date: 2021-10-08 11:21:27.519129
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '143181919790'
down_revision = '97404229e75e'
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table('user_activity', schema=None) as batch_op:
batch_op.alter_column('first_activity_ts',
existing_type=sa.INTEGER(),
type_=sa.BigInteger(),
existing_nullable=True)
batch_op.alter_column('last_activity_ts',
existing_type=sa.INTEGER(),
type_=sa.BigInteger(),
existing_nullable=True)


def downgrade():
with op.batch_alter_table('user_activity', schema=None) as batch_op:
batch_op.alter_column('last_activity_ts',
existing_type=sa.BigInteger(),
type_=sa.INTEGER(),
existing_nullable=True)
batch_op.alter_column('first_activity_ts',
existing_type=sa.BigInteger(),
type_=sa.INTEGER(),
existing_nullable=True)
4 changes: 2 additions & 2 deletions mautrix_telegram/db/user_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class UserActivity(Base):
log: TraceLogger = logging.getLogger("mau.user_activity")

puppet_id: TelegramID = Column(BigInteger, primary_key=True)
first_activity_ts: Optional[int] = Column(Integer)
last_activity_ts: Optional[int] = Column(Integer)
first_activity_ts: Optional[int] = Column(BigInteger)
last_activity_ts: Optional[int] = Column(BigInteger)

def update(self, activity_ts: int) -> None:
if self.last_activity_ts > activity_ts:
Expand Down

0 comments on commit 430c3cf

Please sign in to comment.