"""3.10.1

Revision ID: 655d3fa2c68d
Revises: e2dec87a3d12
Create Date: 2025-04-03 10:19:06.323166

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '655d3fa2c68d'
down_revision = 'e2dec87a3d12'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('project_detect',
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('detect_name', sa.String(length=64), nullable=False),
    sa.Column('detect_version', sa.Integer(), nullable=False),
    sa.Column('detect_no', sa.String(length=32), nullable=False),
    sa.Column('detect_status', sa.Integer(), nullable=False),
    sa.Column('file_type', sa.String(length=10), nullable=False),
    sa.Column('folder_url', sa.String(length=255), nullable=False),
    sa.Column('rtsp_url', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目推理集合'
    )
    op.create_table('project_detect_img',
    sa.Column('detect_id', sa.Integer(), nullable=False),
    sa.Column('file_name', sa.String(length=64), nullable=False),
    sa.Column('image_url', sa.String(length=255), nullable=False),
    sa.Column('thumb_image_url', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='待推理图片'
    )
    op.create_table('project_detect_log',
    sa.Column('detect_id', sa.Integer(), nullable=False),
    sa.Column('detect_version', sa.String(length=10), nullable=False),
    sa.Column('detect_name', sa.String(length=64), nullable=False),
    sa.Column('train_id', sa.Integer(), nullable=False),
    sa.Column('train_version', sa.String(length=10), nullable=False),
    sa.Column('pt_type', sa.String(length=10), nullable=False),
    sa.Column('pt_url', sa.String(length=255), nullable=False),
    sa.Column('folder_url', sa.String(length=255), nullable=False),
    sa.Column('detect_folder_url', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目推理记录'
    )
    op.create_table('project_detect_log_img',
    sa.Column('log_id', sa.Integer(), nullable=False),
    sa.Column('file_name', sa.String(length=64), nullable=False),
    sa.Column('image_url', sa.String(length=255), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目训练版本信息表'
    )
    op.create_table('project_image',
    sa.Column('img_type', sa.String(length=10), nullable=False),
    sa.Column('file_name', sa.String(length=64), nullable=False),
    sa.Column('image_url', sa.String(length=255), nullable=False),
    sa.Column('thumb_image_url', sa.String(length=255), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目图片表'
    )
    op.create_table('project_img_label',
    sa.Column('image_id', sa.Integer(), nullable=False),
    sa.Column('label_id', sa.Integer(), nullable=False),
    sa.Column('mark_center_x', sa.String(length=64), nullable=False),
    sa.Column('mark_center_y', sa.String(length=64), nullable=False),
    sa.Column('mark_width', sa.String(length=64), nullable=False),
    sa.Column('mark_height', sa.String(length=64), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目图片标签对应表，一张图片对应多个label'
    )
    op.create_table('project_img_leafer',
    sa.Column('image_id', sa.Integer(), nullable=False),
    sa.Column('leafer', sa.JSON(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目图片leafer表'
    )
    op.create_table('project_info',
    sa.Column('project_no', sa.String(length=32), nullable=False),
    sa.Column('project_name', sa.String(length=32), nullable=False),
    sa.Column('type_code', sa.String(length=10), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=False),
    sa.Column('project_status', sa.String(length=10), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('dept_id', sa.Integer(), nullable=False),
    sa.Column('train_version', sa.Integer(), nullable=False),
    sa.Column('del_flag', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('project_name'),
    sa.UniqueConstraint('project_no'),
    comment='项目类别表 - 标识项目的类型目前存在的（目标识别，OCR识别，瑕疵检测，图像分类）'
    )
    op.create_table('project_label',
    sa.Column('label_name', sa.String(length=32), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('meta', sa.JSON(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('label_name'),
    comment='项目标签表'
    )
    op.create_table('project_train',
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('train_version', sa.String(length=32), nullable=False),
    sa.Column('train_url', sa.String(length=255), nullable=False),
    sa.Column('train_data', sa.String(length=255), nullable=False),
    sa.Column('weights_id', sa.Integer(), nullable=False),
    sa.Column('weights_name', sa.String(length=32), nullable=False),
    sa.Column('epochs', sa.Integer(), nullable=False),
    sa.Column('patience', sa.Integer(), nullable=False),
    sa.Column('best_pt', sa.String(length=255), nullable=False),
    sa.Column('last_pt', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    comment='项目训练版本信息表'
    )
    op.create_table('project_type',
    sa.Column('type_code', sa.String(length=20), nullable=False),
    sa.Column('type_name', sa.String(length=20), nullable=False),
    sa.Column('icon_path', sa.String(length=255), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=False),
    sa.Column('type_status', sa.String(length=10), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False, comment='更新时间'),
    sa.Column('delete_datetime', sa.DateTime(), nullable=True, comment='删除时间'),
    sa.Column('is_delete', sa.Boolean(), nullable=False, comment='是否软删除'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('type_code'),
    comment='项目类别表 - 标识项目的类型目前存在的（目标识别，OCR识别，瑕疵检测，图像分类）'
    )
    op.alter_column('vadmin_auth_dept', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_dept', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_menu', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_menu', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_role', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_role', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_user', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_user', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue_category', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue_category', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_login', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_login', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_sms_send', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_sms_send', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_resource_images', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_resource_images', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_details', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_details', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_type', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_type', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings_tab', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings_tab', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('now()'),
               existing_comment='更新时间',
               existing_nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('vadmin_system_settings_tab', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings_tab', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_settings', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_type', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_type', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_details', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_system_dict_details', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_resource_images', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_resource_images', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_sms_send', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_sms_send', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_login', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_record_login', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue_category', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue_category', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_help_issue', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_user', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_user', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_role', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_role', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_menu', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_menu', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_dept', 'update_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='更新时间',
               existing_nullable=False)
    op.alter_column('vadmin_auth_dept', 'create_datetime',
               existing_type=mysql.DATETIME(),
               server_default=sa.text('CURRENT_TIMESTAMP'),
               existing_comment='创建时间',
               existing_nullable=False)
    op.drop_table('project_type')
    op.drop_table('project_train')
    op.drop_table('project_label')
    op.drop_table('project_info')
    op.drop_table('project_img_leafer')
    op.drop_table('project_img_label')
    op.drop_table('project_image')
    op.drop_table('project_detect_log_img')
    op.drop_table('project_detect_log')
    op.drop_table('project_detect_img')
    op.drop_table('project_detect')
    # ### end Alembic commands ###
