Files
provenance/backend/migrations/versions/d4a9c1e7b2f3_tree_visibility_site_members.py
T
justin 4a3fe983fa Visibility phase 1: add site_members value + 4-option dropdown
First step of the public-viewing feature (design: docs/design/tree-visibility.md).
No non-member behavior change yet — this only widens the vocabulary and UI.

- TreeVisibility gains `site_members` (any authenticated user of the instance),
  giving the four-level model: public / site_members / unlisted / private.
- Alembic migration adds the enum value via an autocommit block (ALTER TYPE
  ADD VALUE can't run in a transaction on older Postgres); downgrade is a no-op
  since PG can't drop an enum value.
- Regenerated openapi.json + frontend TS client.
- Trees-list dropdown now offers Private / Public – Members / Unlisted / Public
  with an explanatory tooltip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Justin Paul <justin@jpaul.me>
2026-06-09 08:54:45 -04:00

29 lines
871 B
Python

"""tree_visibility: add 'site_members' value
Revision ID: d4a9c1e7b2f3
Revises: c7e1a4f2d3b8
Create Date: 2026-06-09
"""
from collections.abc import Sequence
from alembic import op
revision: str = "d4a9c1e7b2f3"
down_revision: str | None = "c7e1a4f2d3b8"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
# ALTER TYPE ... ADD VALUE cannot run inside a transaction block on older
# Postgres; run it in an autocommit block so it applies regardless of version.
with op.get_context().autocommit_block():
op.execute("ALTER TYPE tree_visibility ADD VALUE IF NOT EXISTS 'site_members'")
def downgrade() -> None:
# Postgres cannot drop an enum value without rebuilding the type; treat the
# added value as irreversible. (Rows using it would block a rebuild anyway.)
pass