45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""202602281918
|
|
|
|
Revision ID: 4bf27c66ae63
|
|
Revises: 7672d8f0f939
|
|
Create Date: 2026-02-28 19:18:38.332468
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '4bf27c66ae63'
|
|
down_revision: Union[str, None] = '7672d8f0f939'
|
|
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! ###
|
|
# Add columns as nullable first
|
|
op.add_column('ontology_class', sa.Column('is_system_default', sa.Boolean(), nullable=True, comment='是否为系统默认类型'))
|
|
op.add_column('ontology_scene', sa.Column('is_system_default', sa.Boolean(), nullable=True, comment='是否为系统默认场景'))
|
|
|
|
# Set default value for existing rows
|
|
op.execute("UPDATE ontology_class SET is_system_default = false WHERE is_system_default IS NULL")
|
|
op.execute("UPDATE ontology_scene SET is_system_default = false WHERE is_system_default IS NULL")
|
|
|
|
# Now make columns NOT NULL
|
|
op.alter_column('ontology_class', 'is_system_default', nullable=False)
|
|
op.alter_column('ontology_scene', 'is_system_default', nullable=False)
|
|
|
|
op.create_index(op.f('ix_ontology_scene_is_system_default'), 'ontology_scene', ['is_system_default'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_ontology_scene_is_system_default'), table_name='ontology_scene')
|
|
op.drop_column('ontology_scene', 'is_system_default')
|
|
op.drop_column('ontology_class', 'is_system_default')
|
|
# ### end Alembic commands ###
|