[add] migration script
This commit is contained in:
@@ -10,7 +10,7 @@ class MemoryConfig(Base):
|
||||
|
||||
# 主键
|
||||
config_id = Column(UUID(as_uuid=True), primary_key=True, comment="配置ID")
|
||||
|
||||
config_id_old = Column(Integer, nullable=True, comment="备份的配置ID")
|
||||
# 基本信息
|
||||
config_name = Column(String, nullable=False, comment="配置名称")
|
||||
config_desc = Column(String, nullable=True, comment="配置描述")
|
||||
|
||||
57
api/migrations/versions/75f0ec80e50b_202601271517.py
Normal file
57
api/migrations/versions/75f0ec80e50b_202601271517.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""202601271517
|
||||
|
||||
Revision ID: 75f0ec80e50b
|
||||
Revises: 325b759cd66b
|
||||
Create Date: 2026-01-27 15:26:48.696600
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '75f0ec80e50b'
|
||||
down_revision: Union[str, None] = '325b759cd66b'
|
||||
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.alter_column('memory_config', 'config_id',
|
||||
existing_type=sa.UUID(),
|
||||
comment='配置ID',
|
||||
existing_nullable=False)
|
||||
op.alter_column('memory_config', 'config_id_old',
|
||||
existing_type=sa.INTEGER(),
|
||||
comment='备份的配置ID',
|
||||
existing_comment='配置ID',
|
||||
existing_nullable=True)
|
||||
op.add_column('tenants', sa.Column('external_id', sa.String(length=100), nullable=True))
|
||||
op.add_column('tenants', sa.Column('external_source', sa.String(length=50), nullable=True))
|
||||
op.create_index(op.f('ix_tenants_external_id'), 'tenants', ['external_id'], unique=False)
|
||||
op.add_column('users', sa.Column('external_id', sa.String(length=100), nullable=True))
|
||||
op.add_column('users', sa.Column('external_source', sa.String(length=50), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('users', 'external_source')
|
||||
op.drop_column('users', 'external_id')
|
||||
op.drop_index(op.f('ix_tenants_external_id'), table_name='tenants')
|
||||
op.drop_column('tenants', 'external_source')
|
||||
op.drop_column('tenants', 'external_id')
|
||||
op.alter_column('memory_config', 'config_id_old',
|
||||
existing_type=sa.INTEGER(),
|
||||
comment='配置ID',
|
||||
existing_comment='备份的配置ID',
|
||||
existing_nullable=True)
|
||||
op.alter_column('memory_config', 'config_id',
|
||||
existing_type=sa.UUID(),
|
||||
comment=None,
|
||||
existing_comment='配置ID',
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user