Private
Public Access
Adds room_invites table + migration, owner/admin/member role enforcement (require_room_role), and endpoints for private room creation, room management (update/delete/leave/transfer-ownership/change-role/remove-member), and the invite lifecycle (create/list/accept/decline/revoke). Registration stays invite-only via the CLI from Phase 1 — this is a separate, room-level invite system for adding existing users to private rooms. Frontend is untouched: the UI redesign is happening separately, so this phase is backend + tests only (35 passing). Verified no regressions in the Phase 1 open-room/WebSocket flow via manual smoke test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
54 lines
2.3 KiB
Python
54 lines
2.3 KiB
Python
"""room invites
|
|
|
|
Revision ID: 0699d20789b3
|
|
Revises: c7981d17890c
|
|
Create Date: 2026-08-13 20:14:22.346544
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '0699d20789b3'
|
|
down_revision: Union[str, Sequence[str], None] = 'c7981d17890c'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('room_invites',
|
|
sa.Column('id', sa.Uuid(), nullable=False),
|
|
sa.Column('room_id', sa.Uuid(), nullable=False),
|
|
sa.Column('invited_by', sa.Uuid(), nullable=False),
|
|
sa.Column('token', sa.String(length=64), nullable=False),
|
|
sa.Column('target_user_id', sa.Uuid(), nullable=True),
|
|
sa.Column('target_email', sa.String(length=255), nullable=True),
|
|
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column('status', sa.Enum('pending', 'accepted', 'revoked', name='invite_status'), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.CheckConstraint('target_user_id IS NOT NULL OR target_email IS NOT NULL', name='room_invites_target_required'),
|
|
sa.ForeignKeyConstraint(['invited_by'], ['users.id'], ),
|
|
sa.ForeignKeyConstraint(['room_id'], ['rooms.id'], ),
|
|
sa.ForeignKeyConstraint(['target_user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_room_invites_room_id'), 'room_invites', ['room_id'], unique=False)
|
|
op.create_index(op.f('ix_room_invites_target_user_id'), 'room_invites', ['target_user_id'], unique=False)
|
|
op.create_index(op.f('ix_room_invites_token'), 'room_invites', ['token'], unique=True)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_room_invites_token'), table_name='room_invites')
|
|
op.drop_index(op.f('ix_room_invites_target_user_id'), table_name='room_invites')
|
|
op.drop_index(op.f('ix_room_invites_room_id'), table_name='room_invites')
|
|
op.drop_table('room_invites')
|
|
# ### end Alembic commands ###
|