"""Init Revision ID: b2d35cbc76bd Revises: Create Date: 2025-02-21 00:59:31.520384 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = 'b2d35cbc76bd' 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('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', 'source'], unique=False) 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_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='卡片名称'), sa.Column('card_number', sa.String(length=225), nullable=True, comment='卡片编号'), sa.Column('card_type', sa.String(length=20), nullable=True, 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=True, comment='创建者'), sa.Column('perfect_user_id', sa.Integer(), nullable=True, comment='完善者'), sa.Column('category', sa.Enum('SPORTS', 'ANIME', 'OTHER', name='cardcategorytype', inherit_schema=True), nullable=True, 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('user_id', sa.Integer(), autoincrement=True, nullable=False, comment='用户id'), sa.Column('nickname', sa.String(length=20), nullable=False, comment='昵称'), sa.Column('gender', sa.Integer(), nullable=True, comment='性别'), sa.Column('avatar_url', sa.String(length=500), nullable=False, comment='头像链接'), sa.Column('wechat_openid', sa.String(length=100), nullable=False, comment='微信openid'), sa.Column('wechat_union_id', sa.String(length=100), nullable=True, comment='微信unionid'), sa.Column('phone', sa.String(length=11), nullable=True, comment='手机号码'), sa.Column('vip_expire_date', sa.Date(), nullable=False, comment='会员到期时间'), sa.Column('points', sa.Integer(), nullable=False, comment='会员积分'), 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('user_id'), sa.UniqueConstraint('user_id', name='uniq_user_id'), comment='用户表' ) op.create_index('wechat_openid', 'system_users', ['wechat_openid'], unique=False) 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('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.user_id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id', 'card_id', name='uniq_user_card'), comment='卡片收藏关联表' ) op.create_table('system_user_followers', sa.Column('follower_id', sa.Integer(), nullable=False, comment='关注者的用户id'), sa.Column('followed_id', sa.Integer(), nullable=False, comment='被关注者的用户id'), 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.ForeignKeyConstraint(['followed_id'], ['system_users.user_id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['follower_id'], ['system_users.user_id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), comment='用户关注关系表' ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_table('system_user_followers') op.drop_table('system_user_collections') op.drop_index('wechat_openid', table_name='system_users') 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 ###