"""add profile tables (profiles, profile_favorites) Revision ID: 0010_add_profile_tables Revises: 0009_add_group_tables Create Date: 2026-09-15 00:00:00.000000 app/models/profile.py. Models + migration + owner-only /api/profile/me endpoints only -- the public profile view endpoint (GET /api/profile/{user_id}) belongs to a sibling task that depends on this one. """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision: str = "0010_add_profile_tables" down_revision: Union[str, None] = "0009_add_group_tables" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "profiles", sa.Column("user_id", sa.Integer(), sa.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True), sa.Column( "avatar_asset_id", sa.Integer(), sa.ForeignKey("assets.id", ondelete="SET NULL"), nullable=True, ), sa.Column("bio", sa.Text(), nullable=True), sa.Column("privacy_json", postgresql.JSONB(), nullable=False, server_default="{}"), sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False), sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False), ) op.create_index("ix_profiles_avatar_asset_id", "profiles", ["avatar_asset_id"]) op.create_table( "profile_favorites", sa.Column( "user_id", sa.Integer(), sa.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True, ), sa.Column( "world_id", sa.Integer(), sa.ForeignKey("worlds.id", ondelete="CASCADE"), primary_key=True, ), sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False), ) op.create_index("ix_profile_favorites_world_id", "profile_favorites", ["world_id"]) def downgrade() -> None: op.drop_index("ix_profile_favorites_world_id", table_name="profile_favorites") op.drop_table("profile_favorites") op.drop_index("ix_profiles_avatar_asset_id", table_name="profiles") op.drop_table("profiles")