9d60e0afc6
统一用户账号体系(阶段1,非破坏): - UserRepository 新增 get_by_wx_mini_openid。 - /auth/wx-login:小程序登录(X-Client=miniprogram)按 wx_mini_openid 建/复用 users 账号(role=opc_member, source=mini_program, auth_type=wx_openid), 并带 nickName/avatarUrl;非小程序仍走 wx_openid。 - /auth/me + 登录响应补齐小程序契约字段 name/phone/phoneBound。 - users 增 opc_status/topics 列(alembic 0010);desktop/web profile 也输出 name/phone/phoneBound/status/topics,且 update-profile 支持 name/status/topics 映射。 - scripts/db/seed.py 增 accounts→users 幂等迁移:旧小程序账号并入全局 users (wx_mini_openid/phone 关联 + opc_member 身份),由用户执行 migrate+seed。 Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
854 B
Python
33 lines
854 B
Python
"""user opc profile fields (status_label / topics)
|
|
|
|
Revision ID: 0010_user_opc_profile
|
|
Revises: 0009_task_system_fields
|
|
Create Date: 2026-08-25
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "0010_user_opc_profile"
|
|
down_revision = "0009_task_system_fields"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def _add(table, col):
|
|
conn = op.get_bind()
|
|
cols = {r[1] for r in conn.execute(sa.text(f"PRAGMA table_info({table})"))}
|
|
if col.name not in cols:
|
|
op.add_column(table, col)
|
|
|
|
|
|
def upgrade() -> None:
|
|
# OPC 成员报名资料(小程序/网页「报名资料」字段):现状标签 + 关注主题(JSON)
|
|
_add("users", sa.Column("opc_status", sa.String, server_default=""))
|
|
_add("users", sa.Column("topics", sa.String, server_default=""))
|
|
|
|
|
|
def downgrade() -> None:
|
|
pass
|