From 5dd791016734ae36b64e3677c5702494c662a97d Mon Sep 17 00:00:00 2001 From: xingc Date: Fri, 25 Apr 2025 17:06:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(db):=20=E8=B0=83=E6=95=B4=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84=20=E5=A2=9E=E5=8A=A0`card=5Fbrand`=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E9=95=BF=E5=BA=A6=E4=B8=BA255=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E`diy=5Fsource`=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++++++- alembic/versions/b2d35cbc76bd_init.py | 2 +- core/db/engine.py | 4 ++-- core/db/models.py | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1169a03..8bf582b 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,14 @@ pip install -r requirements.txt - 数据库和redis连接信息 - 图片资源上传目录 - 境外代理 +- +4.迁移/更新数据库配置 -4.启动服务 +```shell +alembic upgrade head +``` + +5.启动服务 ```shell uvicorn main:app diff --git a/alembic/versions/b2d35cbc76bd_init.py b/alembic/versions/b2d35cbc76bd_init.py index 6a91918..71d4673 100644 --- a/alembic/versions/b2d35cbc76bd_init.py +++ b/alembic/versions/b2d35cbc76bd_init.py @@ -35,7 +35,7 @@ def upgrade() -> None: op.create_table('system_cards', sa.Column('cert_number', sa.String(length=50), nullable=False, comment='评级卡号'), sa.Column('card_year', sa.String(length=50), nullable=True, comment='卡片年份'), - sa.Column('card_brand', sa.String(length=50), nullable=True, comment='卡片品牌'), + sa.Column('card_brand', sa.String(length=255), nullable=True, comment='卡片品牌'), sa.Column('card_score', sa.DECIMAL(precision=10, scale=1), nullable=True, comment='卡片评分'), sa.Column('auto_score', sa.DECIMAL(precision=10, scale=1), nullable=True, comment='签字评分'), sa.Column('card_name', sa.String(length=225), nullable=True, comment='卡片名称'), diff --git a/core/db/engine.py b/core/db/engine.py index c656cd4..22e08ff 100644 --- a/core/db/engine.py +++ b/core/db/engine.py @@ -35,8 +35,8 @@ session_maker = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit async def get_async_session() -> AsyncGenerator[AsyncSession, None]: async with session_maker() as session: - async with session.begin(): - yield session + # async with session.begin(): + yield session def create_redis_pool(): diff --git a/core/db/models.py b/core/db/models.py index bd96d47..b4acda1 100644 --- a/core/db/models.py +++ b/core/db/models.py @@ -129,7 +129,7 @@ class Card(BaseModel, DateModel): cert_number: Mapped[str] = mapped_column(String(50), comment='评级卡号') card_year: Mapped[str] = mapped_column(String(50), nullable=True, comment='卡片年份') - card_brand: Mapped[str] = mapped_column(String(50), nullable=True, comment='卡片品牌') + card_brand: Mapped[str] = mapped_column(String(255), nullable=True, comment='卡片品牌') card_score: Mapped[float] = mapped_column(DECIMAL(10, 1), nullable=True, comment='卡片评分') auto_score: Mapped[float] = mapped_column(DECIMAL(10, 1), nullable=True, comment='签字评分') card_name: Mapped[str] = mapped_column(String(225), nullable=True, comment='卡片名称') @@ -148,6 +148,7 @@ class Card(BaseModel, DateModel): Enum(base_schema.PlatformSourceType, inherit_schema=True), comment='来源,PSA、BGS、CGC、GBTC、CCG、BCTC :采集 、OTHER:自定义' ) + diy_source: Mapped[str] = mapped_column(String(50), nullable=True, comment='自定义品牌名') collections: Mapped[list['UserCollection']] = relationship( back_populates='card',