forked from iti-framework/iTi-Flask
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
5.0 KiB
Python
89 lines
5.0 KiB
Python
"""empty message
|
|
|
|
Revision ID: 5409f28814f9
|
|
Revises: 83b464bfff02
|
|
Create Date: 2025-10-30 22:31:50.159590
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '5409f28814f9'
|
|
down_revision = '83b464bfff02'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('sys_file_directory',
|
|
sa.Column('name', sa.String(length=255), nullable=False, comment='目录名称'),
|
|
sa.Column('path', sa.String(length=1024), nullable=False, comment='完整路径'),
|
|
sa.Column('parent_id', sa.String(length=36), nullable=True),
|
|
sa.Column('level', sa.Integer(), nullable=True, comment='层级'),
|
|
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
|
sa.Column('icon', sa.String(length=128), nullable=True, comment='目录图标'),
|
|
sa.Column('color', sa.String(length=32), nullable=True, comment='颜色标记'),
|
|
sa.Column('description', sa.Text(), nullable=True, comment='目录描述'),
|
|
sa.Column('default_storage_type', sa.String(length=32), nullable=True, comment='默认存储类型'),
|
|
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
|
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False, comment='更新时间'),
|
|
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
|
sa.ForeignKeyConstraint(['parent_id'], ['sys_file_directory.id'], name=op.f('fk_sys_file_directory_parent_id_sys_file_directory'), ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_file_directory')),
|
|
mysql_charset='utf8mb4',
|
|
mysql_collate='utf8mb4_general_ci'
|
|
)
|
|
with op.batch_alter_table('sys_file_directory', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_sys_file_directory_path'), ['path'], unique=False)
|
|
|
|
op.create_table('sys_file',
|
|
sa.Column('filename', sa.String(length=255), nullable=False, comment='原始文件名'),
|
|
sa.Column('file_key', sa.String(length=512), nullable=False, comment='存储路径'),
|
|
sa.Column('file_hash', sa.String(length=64), nullable=True, comment='文件哈希'),
|
|
sa.Column('mime_type', sa.String(length=128), nullable=True, comment='MIME类型'),
|
|
sa.Column('file_size', sa.BigInteger(), nullable=False, comment='文件大小(字节)'),
|
|
sa.Column('extension', sa.String(length=32), nullable=True, comment='文件扩展名'),
|
|
sa.Column('storage_type', sa.Enum('local', 'aliyun_oss', 'tencent_cos', 'qiniu_kodo', 'huawei_obs', 'aws_s3', 'minio', name='storagetypeenum'), nullable=False, comment='存储类型'),
|
|
sa.Column('storage_bucket', sa.String(length=128), nullable=True, comment='存储桶'),
|
|
sa.Column('storage_region', sa.String(length=64), nullable=True, comment='存储区域'),
|
|
sa.Column('storage_endpoint', sa.String(length=255), nullable=True, comment='存储端点'),
|
|
sa.Column('storage_meta', sa.JSON(), nullable=True, comment='存储元信息'),
|
|
sa.Column('directory_id', sa.String(length=36), nullable=True),
|
|
sa.Column('metadata', sa.JSON(), nullable=True, comment='扩展元数据'),
|
|
sa.Column('status', sa.Enum('enabled', 'disabled', name='statusenum'), nullable=False, comment='状态'),
|
|
sa.Column('id', sa.String(length=36), nullable=False, comment='标识'),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False, comment='创建时间'),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False, comment='更新时间'),
|
|
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
|
sa.ForeignKeyConstraint(['directory_id'], ['sys_file_directory.id'], name=op.f('fk_sys_file_directory_id_sys_file_directory'), ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_sys_file')),
|
|
mysql_charset='utf8mb4',
|
|
mysql_collate='utf8mb4_general_ci'
|
|
)
|
|
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_sys_file_directory_id'), ['directory_id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_sys_file_file_hash'), ['file_hash'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_sys_file_file_key'), ['file_key'], unique=True)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('sys_file', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_sys_file_file_key'))
|
|
batch_op.drop_index(batch_op.f('ix_sys_file_file_hash'))
|
|
batch_op.drop_index(batch_op.f('ix_sys_file_directory_id'))
|
|
|
|
op.drop_table('sys_file')
|
|
with op.batch_alter_table('sys_file_directory', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_sys_file_directory_path'))
|
|
|
|
op.drop_table('sys_file_directory')
|
|
# ### end Alembic commands ###
|