first init

This commit is contained in:
xingc
2025-02-18 14:26:47 +08:00
commit 48a02974fc
41 changed files with 2297 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
"""Init
Revision ID: 4c950125b0a6
Revises:
Create Date: 2025-02-17 03:17:02.044360
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '4c950125b0a6'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('system_cache_cards',
sa.Column('cert_number', sa.String(length=50), nullable=False, comment='评级卡号'),
sa.Column('card_number', sa.String(length=50), nullable=False, comment='卡片编号'),
sa.Column('data', sa.JSON(), nullable=False, comment='标准数据'),
sa.Column('raw_data', sa.JSON(), nullable=False, comment='原始数据'),
sa.Column('source', sa.Enum('PSA', 'BGS', 'CGC', 'GBTC', 'CCG', 'BCTC', name='supportplatformtype', inherit_schema=True), nullable=False, comment='数据来源PSA、BGS、CGC、GBTC、CCG、BCTC'),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='自增id'),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='创建时间'),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='更新时间'),
sa.PrimaryKeyConstraint('id'),
comment='搜索卡片信息缓存表'
)
op.create_index('cert_and_card_number_source', 'system_cache_cards', ['cert_number', 'card_number', 'source'], unique=False)
op.create_table('system_cards',
sa.Column('cert_number', sa.String(length=50), nullable=False, comment='评级卡号'),
sa.Column('card_year', sa.Integer(), nullable=False, comment='卡片年份'),
sa.Column('card_brand', sa.Integer(), nullable=False, comment='卡片品牌'),
sa.Column('card_score', sa.DECIMAL(precision=10, scale=1), nullable=False, comment='卡片评分'),
sa.Column('auto_score', sa.DECIMAL(precision=10, scale=1), nullable=False, comment='签字评分'),
sa.Column('card_name', sa.String(length=225), nullable=False, comment='卡片名称'),
sa.Column('card_number', sa.String(length=225), nullable=False, comment='卡片编号'),
sa.Column('card_type', sa.String(length=20), nullable=False, comment='卡片类型'),
sa.Column('card_picture', sa.JSON(), nullable=False, comment='卡片正、反图片(本地)'),
sa.Column('card_spare_picture', sa.JSON(), nullable=False, comment='卡片正、反图片(远程)'),
sa.Column('create_user_id', sa.Integer(), nullable=False, comment='创建者'),
sa.Column('category', sa.Enum('SPORTS', 'ANIME', 'OTHER', name='cardcategorytype', inherit_schema=True), nullable=False, comment='卡片分类'),
sa.Column('source', sa.Enum('PSA', 'BGS', 'CGC', 'GBTC', 'CCG', 'BCTC', 'OTHER', name='platformsourcetype', inherit_schema=True), nullable=False, comment='来源PSA、BGS、CGC、GBTC、CCG、BCTC :采集 、OTHER自定义'),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='自增id'),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='创建时间'),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='更新时间'),
sa.PrimaryKeyConstraint('id'),
comment='卡片表'
)
op.create_index('cert_number_category_source', 'system_cards', ['cert_number', 'category', 'source'], unique=False)
op.create_table('system_users',
sa.Column('nickname', sa.String(length=20), nullable=False, comment='昵称'),
sa.Column('user_id', sa.Integer(), nullable=False, comment='用户id'),
sa.Column('head_avatar', sa.String(length=500), nullable=False, comment='头像链接'),
sa.Column('wechat_openid', sa.String(length=100), nullable=True, comment='微信openid'),
sa.Column('wechat_union_id', sa.String(length=100), nullable=True, comment='微信unionid'),
sa.Column('phone', sa.Integer(), nullable=False, comment='手机号码'),
sa.Column('vip_expire_date', sa.Date(), nullable=False, comment='会员到期时间'),
sa.Column('integral', sa.Integer(), nullable=False, comment='会员积分'),
sa.Column('card_total', sa.Integer(), nullable=True, comment='卡牌总数'),
sa.Column('card_show_total', sa.Integer(), nullable=True, comment='卡片展示总数'),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='自增id'),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='创建时间'),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='更新时间'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id', name='uniq_user_id'),
comment='用户表'
)
op.create_table('system_user_collections',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('card_id', sa.Integer(), nullable=False),
sa.Column('purchase_price', sa.DECIMAL(precision=10, scale=2), nullable=False),
sa.Column('display_price', sa.DECIMAL(precision=10, scale=2), nullable=False),
sa.Column('displayed', sa.Boolean(), nullable=False),
sa.Column('updated_at', sa.Boolean(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='自增id'),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='创建时间'),
sa.CheckConstraint('display_value >= 0', name='check_display_price'),
sa.CheckConstraint('purchase_price >= 0', name='check_purchase_price'),
sa.ForeignKeyConstraint(['card_id'], ['system_cards.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['user_id'], ['system_users.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id', 'card_id', name='uniq_user_card')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('system_user_collections')
op.drop_table('system_users')
op.drop_index('cert_number_category_source', table_name='system_cards')
op.drop_table('system_cards')
op.drop_index('cert_and_card_number_source', table_name='system_cache_cards')
op.drop_table('system_cache_cards')
# ### end Alembic commands ###