Implements the full User Connections & Notification Centre feature: Phase 1 - Database: migrations 039-043 adding umbral_name to users, profile/social fields to settings, notifications table, connection request/user_connection tables, and linked_user_id to people. Phase 2 - Notifications: backend CRUD router + service + 90-day purge, frontend NotificationsPage with All/Unread filter, bell icon in sidebar with unread badge polling every 60s. Phase 3 - Settings: profile fields (phone, mobile, address, company, job_title), social card with accept_connections toggle and per-field sharing defaults, umbral name display with CopyableField. Phase 4 - Connections: timing-safe user search, send/accept/reject flow with atomic status updates, bidirectional UserConnection + Person records, in-app + ntfy notifications, per-receiver pending cap, nginx rate limiting. Phase 5 - People integration: batch-loaded shared profiles (N+1 prevention), Ghost icon for umbral contacts, Umbral filter pill, split Add Person button, shared field indicators (synced labels + Lock icons), disabled form inputs for synced fields on umbral contacts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""Add umbral_name to users table.
|
|
|
|
3-step migration: add nullable → backfill from username → alter to NOT NULL.
|
|
Backfill uses username || '_' || id as fallback if uniqueness conflicts arise.
|
|
|
|
Revision ID: 039
|
|
Revises: 038
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "039"
|
|
down_revision = "038"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Step 1: Add nullable column
|
|
op.add_column("users", sa.Column("umbral_name", sa.String(50), nullable=True))
|
|
|
|
# Step 2: Backfill from username (handles uniqueness conflicts with fallback)
|
|
op.execute("UPDATE users SET umbral_name = username")
|
|
# Fix any remaining NULLs (shouldn't happen, but defensive)
|
|
op.execute(
|
|
"UPDATE users SET umbral_name = username || '_' || id "
|
|
"WHERE umbral_name IS NULL"
|
|
)
|
|
|
|
# Step 3: Alter to NOT NULL and add unique index
|
|
op.alter_column("users", "umbral_name", nullable=False)
|
|
op.create_index("ix_users_umbral_name", "users", ["umbral_name"], unique=True)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_users_umbral_name", table_name="users")
|
|
op.drop_column("users", "umbral_name")
|