41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""add asset state nodes
|
|
|
|
Revision ID: f4f0c9c9426e
|
|
Revises: 6c2a57f2b1e9
|
|
Create Date: 2026-04-25 21:20:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'f4f0c9c9426e'
|
|
down_revision = '6c2a57f2b1e9'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
'asset_state_nodes',
|
|
sa.Column('id', sa.Uuid(), nullable=False),
|
|
sa.Column('entry_id', sa.Uuid(), nullable=False),
|
|
sa.Column('title', sa.String(length=255), nullable=False),
|
|
sa.Column('at_time', sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(['entry_id'], ['asset_log_entries.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
)
|
|
with op.batch_alter_table('asset_state_nodes', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_asset_state_nodes_entry_id'), ['entry_id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_asset_state_nodes_at_time'), ['at_time'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
with op.batch_alter_table('asset_state_nodes', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_asset_state_nodes_at_time'))
|
|
batch_op.drop_index(batch_op.f('ix_asset_state_nodes_entry_id'))
|
|
|
|
op.drop_table('asset_state_nodes') |