aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a7b8c9d0e1f2_add_group_last_activity.py28
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/models.py4
2 files changed, 31 insertions, 1 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a7b8c9d0e1f2_add_group_last_activity.py b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a7b8c9d0e1f2_add_group_last_activity.py
new file mode 100644
index 0000000..8a4e2ee
--- /dev/null
+++ b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a7b8c9d0e1f2_add_group_last_activity.py
@@ -0,0 +1,28 @@
+"""add_group_last_activity_at
+
+Revision ID: a7b8c9d0e1f2
+Revises: f1a2b3c4d5e6
+Create Date: 2026-08-20 20:50:00.000000
+
+"""
+from typing import Sequence, Union
+
+from alembic import op
+import sqlalchemy as sa
+
+
+revision: str = 'a7b8c9d0e1f2'
+down_revision: Union[str, Sequence[str], None] = 'f1a2b3c4d5e6'
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+
+def upgrade() -> None:
+ op.add_column('groups',
+ sa.Column('last_activity_at', sa.DateTime(timezone=True),
+ server_default=sa.func.now(), nullable=False))
+ op.execute("UPDATE groups SET last_activity_at = created_at")
+
+
+def downgrade() -> None:
+ op.drop_column('groups', 'last_activity_at')
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/models.py b/packages/meshbay-hub/src/meshbay_hub/db/models.py
index f1f11e2..3966bdc 100644
--- a/packages/meshbay-hub/src/meshbay_hub/db/models.py
+++ b/packages/meshbay-hub/src/meshbay_hub/db/models.py
@@ -103,7 +103,9 @@ class Group(Base):
# group. Until then the group has no files, no key and nobody to serve it, so
# it is shown to its owner only and is what `prune-groups` collects. Set once
# and never cleared: a node going offline does not un-host a group.
- hosted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
+ hosted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
+ last_activity_at: Mapped[datetime] = mapped_column(
+ DateTime(timezone=True), default=_now, nullable=False)
members: Mapped[list["GroupMember"]] = relationship(back_populates="group")