aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e6f7a8b9c0d1_drop_swarm_sources.py
blob: 0e613908bb56cf6a9f8cdc89ec9af4c4978e8667 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""drop the public-content swarm table

Nodes registered the hashes of their public groups here and nothing ever read
them back: the swarm was written and never used.

Revision ID: e6f7a8b9c0d1
Revises: c4d5e6f7a8b9
"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "e6f7a8b9c0d1"
down_revision: str | Sequence[str] | None = "c4d5e6f7a8b9"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.drop_index("ix_swarm_hash", table_name="swarm_sources")
    op.drop_table("swarm_sources")


def downgrade() -> None:
    op.create_table(
        "swarm_sources",
        sa.Column("content_hash", sa.String(64), nullable=False),
        sa.Column("node_id", sa.String(36), nullable=False),
        sa.Column("endpoint", sa.String(128), nullable=False),
        sa.Column("registered_at", sa.DateTime(timezone=True), nullable=False,
                  server_default=sa.func.now()),
        sa.Column("last_seen", sa.DateTime(timezone=True), nullable=False,
                  server_default=sa.func.now()),
        sa.PrimaryKeyConstraint("content_hash", "node_id"),
    )
    op.create_index("ix_swarm_hash", "swarm_sources", ["content_hash"])