"""initial schema

Revision ID: 07c4fb2af22c
Revises: 
Create Date: 2022-03-31 12:36:02.922753

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '07c4fb2af22c'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('group',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('group_name', sa.String(length=80), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=False),
    sa.Column('eotk', sa.Boolean(), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=False),
    sa.Column('updated', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_group')),
    sa.UniqueConstraint('group_name', name=op.f('uq_group_group_name'))
    )
    op.create_table('bridge_conf',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('group_id', sa.Integer(), nullable=False),
    sa.Column('provider', sa.String(length=20), nullable=False),
    sa.Column('method', sa.String(length=20), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('number', sa.Integer(), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=False),
    sa.Column('updated', sa.DateTime(), nullable=False),
    sa.Column('destroyed', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_bridge_conf_group_id_group')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_bridge_conf'))
    )
    op.create_table('origin',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('group_id', sa.Integer(), nullable=False),
    sa.Column('domain_name', sa.String(length=255), 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.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_origin_group_id_group')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_origin')),
    sa.UniqueConstraint('domain_name', name=op.f('uq_origin_domain_name'))
    )
    op.create_table('bridge',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('conf_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('destroyed', sa.DateTime(), nullable=True),
    sa.Column('terraform_updated', sa.DateTime(), nullable=True),
    sa.Column('fingerprint', sa.String(length=255), nullable=True),
    sa.Column('hashed_fingerprint', sa.String(length=255), nullable=True),
    sa.Column('bridgeline', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['conf_id'], ['bridge_conf.id'], name=op.f('fk_bridge_conf_id_bridge_conf')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_bridge'))
    )
    op.create_table('mirror',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('origin_id', sa.Integer(), nullable=False),
    sa.Column('url', sa.String(length=255), 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('destroyed', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['origin_id'], ['origin.id'], name=op.f('fk_mirror_origin_id_origin')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_mirror')),
    sa.UniqueConstraint('url', name=op.f('uq_mirror_url'))
    )
    op.create_table('proxy',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('origin_id', sa.Integer(), nullable=False),
    sa.Column('provider', sa.String(length=20), nullable=False),
    sa.Column('slug', sa.String(length=20), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=False),
    sa.Column('updated', sa.DateTime(), nullable=False),
    sa.Column('deprecated', sa.DateTime(), nullable=True),
    sa.Column('destroyed', sa.DateTime(), nullable=True),
    sa.Column('terraform_updated', sa.DateTime(), nullable=True),
    sa.Column('url', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['origin_id'], ['origin.id'], name=op.f('fk_proxy_origin_id_origin')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_proxy'))
    )
    op.create_table('alarm',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('target', sa.String(length=60), nullable=False),
    sa.Column('group_id', sa.Integer(), nullable=True),
    sa.Column('origin_id', sa.Integer(), nullable=True),
    sa.Column('proxy_id', sa.Integer(), nullable=True),
    sa.Column('bridge_id', sa.Integer(), nullable=True),
    sa.Column('alarm_type', sa.String(length=255), nullable=False),
    sa.Column('alarm_state', sa.Enum('UNKNOWN', 'OK', 'WARNING', 'CRITICAL', name='alarmstate'), nullable=False),
    sa.Column('state_changed', sa.DateTime(), nullable=False),
    sa.Column('last_updated', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['bridge_id'], ['bridge.id'], name=op.f('fk_alarm_bridge_id_bridge')),
    sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_alarm_group_id_group')),
    sa.ForeignKeyConstraint(['origin_id'], ['origin.id'], name=op.f('fk_alarm_origin_id_origin')),
    sa.ForeignKeyConstraint(['proxy_id'], ['proxy.id'], name=op.f('fk_alarm_proxy_id_proxy')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_alarm'))
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('alarm')
    op.drop_table('proxy')
    op.drop_table('mirror')
    op.drop_table('bridge')
    op.drop_table('origin')
    op.drop_table('bridge_conf')
    op.drop_table('group')
    # ### end Alembic commands ###
