Settings, posts, milestone marks and pending-checks tables (phase 3, step 2)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 58s
CI / test (push) Successful in 2m19s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 58s
CI / test (push) Successful in 2m19s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
federation_settings gains timezone (IANA name, default UTC), post_weekly_summary and post_milestones (both on by default), with a server_default backfilling any existing rows. New tables on the federation branch: - federation_posts: one row per (user, key) — e.g. weekly:2026-W39 or milestone:scrobbles:10000 — which is what makes posting idempotent; wraps the Create activity, keeps its own content and visibility, and a deleted_at tombstone - federation_milestone_marks: thresholds a user has passed, with posted=false for ones passed silently (enabling sharing, or an import finishing) so they're never reconsidered - federation_pending_checks: a one-row-per-user queue filled by the scrobbles_stored receiver and drained by the worker, so a scrobble request never does milestone-checking work itself Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
ea6b10637e
commit
ed74a78625
2 files changed
+159
No files matched your search
@@ -0,0 +1,99 @@
|
||||
"""federation posts and milestones
|
||||
|
||||
Revision ID: 0b81b61c932a
|
||||
Revises: a481855fcb93
|
||||
Create Date: 2026-09-26 11:34:52.240684
|
||||
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0b81b61c932a"
|
||||
down_revision = "a481855fcb93"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"federation_milestone_marks",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("key", sa.String(length=64), nullable=False),
|
||||
sa.Column("posted", sa.Boolean(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("user_id", "key", name="uq_federation_milestone_mark"),
|
||||
)
|
||||
with op.batch_alter_table("federation_milestone_marks", schema=None) as batch_op:
|
||||
batch_op.create_index(
|
||||
batch_op.f("ix_federation_milestone_marks_user_id"), ["user_id"], unique=False
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"federation_pending_checks",
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("since", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("reason", sa.String(length=32), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("user_id"),
|
||||
)
|
||||
op.create_table(
|
||||
"federation_posts",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("kind", sa.String(length=16), nullable=False),
|
||||
sa.Column("key", sa.String(length=64), nullable=False),
|
||||
sa.Column("activity_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("visibility", sa.String(length=16), nullable=False),
|
||||
sa.Column("content_text", sa.Text(), nullable=False),
|
||||
sa.Column("content_html", sa.Text(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(["activity_id"], ["federation_activities.id"], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("activity_id"),
|
||||
sa.UniqueConstraint("user_id", "key", name="uq_federation_post_key"),
|
||||
)
|
||||
with op.batch_alter_table("federation_posts", schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f("ix_federation_posts_user_id"), ["user_id"], unique=False)
|
||||
|
||||
# server_default backfills existing rows (any user who's already touched their
|
||||
# sharing settings); the model's Python-side default covers new ones.
|
||||
with op.batch_alter_table("federation_settings", schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column("timezone", sa.String(length=64), nullable=False, server_default="UTC")
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column("post_weekly_summary", sa.Boolean(), nullable=False, server_default=sa.true())
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column("post_milestones", sa.Boolean(), nullable=False, server_default=sa.true())
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("federation_settings", schema=None) as batch_op:
|
||||
batch_op.drop_column("post_milestones")
|
||||
batch_op.drop_column("post_weekly_summary")
|
||||
batch_op.drop_column("timezone")
|
||||
|
||||
with op.batch_alter_table("federation_posts", schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f("ix_federation_posts_user_id"))
|
||||
|
||||
op.drop_table("federation_posts")
|
||||
op.drop_table("federation_pending_checks")
|
||||
with op.batch_alter_table("federation_milestone_marks", schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f("ix_federation_milestone_marks_user_id"))
|
||||
|
||||
op.drop_table("federation_milestone_marks")
|
||||
# ### end Alembic commands ###
|
||||
Reference in new issue
Block a user