- Add is_public field to Tree model (private by default) - Update access control: users see default trees, public trees, or their own - Update all tree endpoints (list, search, get, categories) with new visibility logic - Default/system trees are automatically marked as public - Add migration 004 to add is_public column and update existing defaults - Fix pydantic settings to ignore extra env vars (DATABASE_URL_SYNC) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
894 B
Python
33 lines
894 B
Python
"""Add is_public field to trees
|
|
|
|
Revision ID: 004
|
|
Revises: 003
|
|
Create Date: 2026-02-01
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '004'
|
|
down_revision: Union[str, None] = '003'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Add is_public column with default False (private by default)
|
|
op.add_column('trees', sa.Column('is_public', sa.Boolean(), nullable=False, server_default='false'))
|
|
op.create_index('ix_trees_is_public', 'trees', ['is_public'])
|
|
|
|
# Make existing default trees public
|
|
op.execute("UPDATE trees SET is_public = true WHERE is_default = true")
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index('ix_trees_is_public', table_name='trees')
|
|
op.drop_column('trees', 'is_public')
|