feat(db): add Customer.add_time column + migration

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-05 18:39:17 +08:00
parent 9499110427
commit b5733f15d2
3 changed files with 38 additions and 0 deletions
+1
View File
@@ -33,6 +33,7 @@ class CustomerOut(BaseModel):
dept_name: str | None = None
head_image_url: str | None = None
last_chat_time: int | None = None
add_time: int | None = None
message_count: int | None = None
version: str | None = None
# Verbatim upstream friend record (~60 camelCase fields). Surfaced so the
+1
View File
@@ -233,6 +233,7 @@ class Customer(Base):
dept_name: Mapped[str | None] = mapped_column(String(255), nullable=True)
head_image_url: Mapped[str | None] = mapped_column(String(1024), nullable=True)
last_chat_time: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
add_time: Mapped[int | None] = mapped_column(BigInteger, nullable=True) # ms epoch; from raw_json.addTime
send_num: Mapped[int | None] = mapped_column(Integer, nullable=True)
receive_num: Mapped[int | None] = mapped_column(Integer, nullable=True)
message_count: Mapped[int | None] = mapped_column(Integer, nullable=True)
@@ -0,0 +1,36 @@
"""customer add_time
Revision ID: 3892dbfab839
Revises: 96975050fa79
Create Date: 2026-08-05 18:37:00.679685
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = '3892dbfab839'
down_revision: str | Sequence[str] | None = '96975050fa79'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('customer', schema=None) as batch_op:
batch_op.add_column(sa.Column('add_time', sa.BigInteger(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('customer', schema=None) as batch_op:
batch_op.drop_column('add_time')
# ### end Alembic commands ###