majuna/migrations/versions/0a0a65db7f01_add_automations.py

54 lines
2 KiB
Python

"""add automations
Revision ID: 0a0a65db7f01
Revises: c3d6e95caa79
Create Date: 2022-05-08 16:24:53.779353
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0a0a65db7f01'
down_revision = 'c3d6e95caa79'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('automation',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('description', sa.String(length=255), nullable=False),
sa.Column('added', sa.DateTime(), nullable=False),
sa.Column('updated', sa.DateTime(), nullable=False),
sa.Column('destroyed', sa.DateTime(), nullable=True),
sa.Column('short_name', sa.String(length=25), nullable=False),
sa.Column('state', sa.Enum('IDLE', 'RUNNING', 'ERROR', name='automationstate'), nullable=False),
sa.Column('enabled', sa.Boolean(), nullable=False),
sa.Column('last_run', sa.DateTime(), nullable=True),
sa.Column('next_run', sa.DateTime(), nullable=True),
sa.Column('next_is_full', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_automation'))
)
op.create_table('automation_logs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('added', sa.DateTime(), nullable=False),
sa.Column('updated', sa.DateTime(), nullable=False),
sa.Column('deprecated', sa.DateTime(), nullable=True),
sa.Column('deprecation_reason', sa.String(), nullable=True),
sa.Column('destroyed', sa.DateTime(), nullable=True),
sa.Column('automation_id', sa.Integer(), nullable=False),
sa.Column('logs', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['automation_id'], ['automation.id'], name=op.f('fk_automation_logs_automation_id_automation')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_automation_logs'))
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('automation_logs')
op.drop_table('automation')
# ### end Alembic commands ###