feat(migrations): 新增 alembic 迁移(public_nav / nav_category / 友链 / 访问统计)

This commit is contained in:
bwstudio
2026-09-06 21:34:39 +08:00
parent 0bfe6f9d8c
commit 1a33648b9a
11 changed files with 624 additions and 0 deletions
@@ -0,0 +1,48 @@
"""add public_nav table
Revision ID: 38751d88d42c
Revises: fdbdc3aab8da
Create Date: 2026-09-05 14:54:32.013804
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '38751d88d42c'
down_revision = 'fdbdc3aab8da'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('public_nav',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='导航ID'),
sa.Column('category', sa.String(length=50), nullable=False, comment='分类'),
sa.Column('title', sa.String(length=100), nullable=False, comment='标题'),
sa.Column('url', sa.String(length=255), nullable=False, comment='链接'),
sa.Column('description', sa.String(length=255), nullable=True, comment='简介'),
sa.Column('icon', sa.String(length=100), nullable=True, comment='图标'),
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
sa.Column('status', sa.Integer(), nullable=True, comment='状态(1启用,0关闭)'),
sa.Column('is_external', sa.Integer(), nullable=True, comment='是否外链'),
sa.Column('create_by', sa.String(length=50), nullable=True, comment='创建者'),
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('update_at', sa.DateTime(), nullable=True, comment='更新时间'),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('public_nav', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_public_nav_category'), ['category'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('public_nav', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_public_nav_category'))
op.drop_table('public_nav')
# ### end Alembic commands ###