fixed bug in miration
This commit is contained in:
parent
aa2bc5a447
commit
c867ef7cc0
@ -0,0 +1,59 @@
|
|||||||
|
"""Coupled Host and Hostgroup into single Table
|
||||||
|
|
||||||
|
Revision ID: 54537e95fc4d
|
||||||
|
Revises: c6fe061ad732
|
||||||
|
Create Date: 2026-01-01 15:03:09.122667
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '54537e95fc4d'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = 'c6fe061ad732'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('pillar_tool_host', sa.Column('parent_id', sa.UUID(), nullable=True))
|
||||||
|
op.drop_constraint(op.f('pillar_tool_host_unique_name'), 'pillar_tool_host', type_='unique')
|
||||||
|
op.create_unique_constraint('pillar_tool_host_unique_name', 'pillar_tool_host', ['name', 'parent_id'])
|
||||||
|
op.drop_constraint(op.f('pillar_tool_host_host_group_id_fkey'), 'pillar_tool_host', type_='foreignkey')
|
||||||
|
op.create_foreign_key(None, 'pillar_tool_host', 'pillar_tool_host', ['parent_id'], ['id'])
|
||||||
|
op.drop_column('pillar_tool_host', 'host_group_id')
|
||||||
|
op.drop_constraint(op.f('pillar_value_unique_pillar_value'), 'pillar_tool_pillar_value', type_='unique')
|
||||||
|
op.create_unique_constraint('pillar_value_unique_pillar_value', 'pillar_tool_pillar_value', ['pillar_id', 'host_id'])
|
||||||
|
op.drop_constraint(op.f('pillar_tool_pillar_value_host_group_id_fkey'), 'pillar_tool_pillar_value', type_='foreignkey')
|
||||||
|
op.drop_column('pillar_tool_pillar_value', 'host_group_id')
|
||||||
|
op.drop_table('pillar_tool_host_group')
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('pillar_tool_pillar_value', sa.Column('host_group_id', sa.UUID(), autoincrement=False, nullable=True))
|
||||||
|
op.create_foreign_key(op.f('pillar_tool_pillar_value_host_group_id_fkey'), 'pillar_tool_pillar_value', 'pillar_tool_host_group', ['host_group_id'], ['id'])
|
||||||
|
op.drop_constraint('pillar_value_unique_pillar_value', 'pillar_tool_pillar_value', type_='unique')
|
||||||
|
op.create_unique_constraint(op.f('pillar_value_unique_pillar_value'), 'pillar_tool_pillar_value', ['pillar_id', 'host_id', 'host_group_id'], postgresql_nulls_not_distinct=False)
|
||||||
|
op.add_column('pillar_tool_host', sa.Column('host_group_id', sa.UUID(), autoincrement=False, nullable=True))
|
||||||
|
op.drop_constraint(None, 'pillar_tool_host', type_='foreignkey')
|
||||||
|
op.create_foreign_key(op.f('pillar_tool_host_host_group_id_fkey'), 'pillar_tool_host', 'pillar_tool_host_group', ['host_group_id'], ['id'])
|
||||||
|
op.drop_constraint('pillar_tool_host_unique_name', 'pillar_tool_host', type_='unique')
|
||||||
|
op.create_unique_constraint(op.f('pillar_tool_host_unique_name'), 'pillar_tool_host', ['name'], postgresql_nulls_not_distinct=False)
|
||||||
|
op.drop_column('pillar_tool_host', 'parent_id')
|
||||||
|
op.create_table('pillar_tool_host_group',
|
||||||
|
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||||
|
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||||
|
sa.Column('parent_id', sa.UUID(), autoincrement=False, nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['parent_id'], ['pillar_tool_host_group.id'], name=op.f('pillar_tool_host_group_parent_id_fkey')),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pillar_tool_host_group_pkey')),
|
||||||
|
sa.UniqueConstraint('name', 'parent_id', name=op.f('pillar_tool_host_group_unique_name_parent'), postgresql_include=[], postgresql_nulls_not_distinct=False)
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
Loading…
x
Reference in New Issue
Block a user