"""empty message

Revision ID: b0cad5321c88
Revises:
Create Date: 2022-01-04 16:17:04.902652

"""
import sqlalchemy as sa
from alembic import op

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


def upgrade():
    """
    Run upgrade
    """
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'cbsd_states',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'domain_proxy_logs',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('log_from', sa.String(), nullable=True),
        sa.Column('log_to', sa.String(), nullable=True),
        sa.Column('log_name', sa.String(), nullable=True),
        sa.Column('log_message', sa.String(), nullable=True),
        sa.Column('cbsd_serial_number', sa.String(), nullable=True),
        sa.Column('network_id', sa.String(), nullable=True),
        sa.Column('fcc_id', sa.String(), nullable=True),
        sa.Column('response_code', sa.Integer(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'grant_states',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'request_states',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'request_types',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'cbsds',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('state_id', sa.Integer(), nullable=False),
        sa.Column('cbsd_id', sa.String(), nullable=True),
        sa.Column('user_id', sa.String(), nullable=True),
        sa.Column('fcc_id', sa.String(), nullable=True),
        sa.Column('cbsd_serial_number', sa.String(), nullable=True),
        sa.Column('last_seen', sa.DateTime(timezone=True), nullable=True),
        sa.Column('min_power', sa.Float(), nullable=True),
        sa.Column('max_power', sa.Float(), nullable=True),
        sa.Column('antenna_gain', sa.Float(), nullable=True),
        sa.Column('number_of_ports', sa.Integer(), nullable=True),
        sa.Column('network_id', sa.String(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(
            ['state_id'], ['cbsd_states.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'active_mode_configs',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('cbsd_id', sa.Integer(), nullable=False),
        sa.Column('desired_state_id', sa.Integer(), nullable=False),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['desired_state_id'], ['cbsd_states.id'],
            ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('cbsd_id'),
    )
    op.create_table(
        'channels',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('cbsd_id', sa.Integer(), nullable=True),
        sa.Column('low_frequency', sa.BigInteger(), nullable=False),
        sa.Column('high_frequency', sa.BigInteger(), nullable=False),
        sa.Column('channel_type', sa.String(), nullable=False),
        sa.Column('rule_applied', sa.String(), nullable=False),
        sa.Column('max_eirp', sa.Float(), nullable=True),
        sa.Column('last_used_max_eirp', sa.Float(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'requests',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('type_id', sa.Integer(), nullable=True),
        sa.Column('state_id', sa.Integer(), nullable=True),
        sa.Column('cbsd_id', sa.Integer(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.Column('payload', sa.JSON(), nullable=True),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['state_id'], ['request_states.id'], ondelete='CASCADE',
        ),
        sa.ForeignKeyConstraint(
            ['type_id'], ['request_types.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'grants',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('state_id', sa.Integer(), nullable=False),
        sa.Column('cbsd_id', sa.Integer(), nullable=True),
        sa.Column('channel_id', sa.Integer(), nullable=True),
        sa.Column('grant_id', sa.String(), nullable=False),
        sa.Column(
            'grant_expire_time', sa.DateTime(
                timezone=True,
            ), nullable=True,
        ),
        sa.Column(
            'transmit_expire_time', sa.DateTime(
                timezone=True,
            ), nullable=True,
        ),
        sa.Column('heartbeat_interval', sa.Integer(), nullable=True),
        sa.Column(
            'last_heartbeat_request_time',
            sa.DateTime(timezone=True), nullable=True,
        ),
        sa.Column('channel_type', sa.String(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['channel_id'], ['channels.id'], ondelete='CASCADE',
        ),
        sa.ForeignKeyConstraint(
            ['state_id'], ['grant_states.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'responses',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('request_id', sa.Integer(), nullable=True),
        sa.Column('grant_id', sa.Integer(), nullable=True),
        sa.Column('response_code', sa.Integer(), nullable=False),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column('payload', sa.JSON(), nullable=True),
        sa.ForeignKeyConstraint(
            ['grant_id'], ['grants.id'], ondelete='CASCADE',
        ),
        sa.ForeignKeyConstraint(
            ['request_id'], ['requests.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    # ### end Alembic commands ###


def downgrade():
    """
    Run downgrade
    """
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('responses')
    op.drop_table('grants')
    op.drop_table('requests')
    op.drop_table('channels')
    op.drop_table('active_mode_configs')
    op.drop_table('cbsds')
    op.drop_table('request_types')
    op.drop_table('request_states')
    op.drop_table('grant_states')
    op.drop_table('domain_proxy_logs')
    op.drop_table('cbsd_states')
    # ### end Alembic commands ###

"""empty message

Revision ID: b0cad5321c88
Revises:
Create Date: 2022-01-04 16:17:04.902652

"""
import sqlalchemy as sa
from alembic import op

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


def upgrade():
    """
    Run upgrade
    """
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'cbsd_states',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'domain_proxy_logs',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('log_from', sa.String(), nullable=True),
        sa.Column('log_to', sa.String(), nullable=True),
        sa.Column('log_name', sa.String(), nullable=True),
        sa.Column('log_message', sa.String(), nullable=True),
        sa.Column('cbsd_serial_number', sa.String(), nullable=True),
        sa.Column('network_id', sa.String(), nullable=True),
        sa.Column('fcc_id', sa.String(), nullable=True),
        sa.Column('response_code', sa.Integer(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'grant_states',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'request_states',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'request_types',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'cbsds',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('state_id', sa.Integer(), nullable=False),
        sa.Column('cbsd_id', sa.String(), nullable=True),
        sa.Column('user_id', sa.String(), nullable=True),
        sa.Column('fcc_id', sa.String(), nullable=True),
        sa.Column('cbsd_serial_number', sa.String(), nullable=True),
        sa.Column('last_seen', sa.DateTime(timezone=True), nullable=True),
        sa.Column('min_power', sa.Float(), nullable=True),
        sa.Column('max_power', sa.Float(), nullable=True),
        sa.Column('antenna_gain', sa.Float(), nullable=True),
        sa.Column('number_of_ports', sa.Integer(), nullable=True),
        sa.Column('network_id', sa.String(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(
            ['state_id'], ['cbsd_states.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'active_mode_configs',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('cbsd_id', sa.Integer(), nullable=False),
        sa.Column('desired_state_id', sa.Integer(), nullable=False),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['desired_state_id'], ['cbsd_states.id'],
            ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('cbsd_id'),
    )
    op.create_table(
        'channels',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('cbsd_id', sa.Integer(), nullable=True),
        sa.Column('low_frequency', sa.BigInteger(), nullable=False),
        sa.Column('high_frequency', sa.BigInteger(), nullable=False),
        sa.Column('channel_type', sa.String(), nullable=False),
        sa.Column('rule_applied', sa.String(), nullable=False),
        sa.Column('max_eirp', sa.Float(), nullable=True),
        sa.Column('last_used_max_eirp', sa.Float(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'requests',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('type_id', sa.Integer(), nullable=True),
        sa.Column('state_id', sa.Integer(), nullable=True),
        sa.Column('cbsd_id', sa.Integer(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.Column('payload', sa.JSON(), nullable=True),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['state_id'], ['request_states.id'], ondelete='CASCADE',
        ),
        sa.ForeignKeyConstraint(
            ['type_id'], ['request_types.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'grants',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('state_id', sa.Integer(), nullable=False),
        sa.Column('cbsd_id', sa.Integer(), nullable=True),
        sa.Column('channel_id', sa.Integer(), nullable=True),
        sa.Column('grant_id', sa.String(), nullable=False),
        sa.Column(
            'grant_expire_time', sa.DateTime(
                timezone=True,
            ), nullable=True,
        ),
        sa.Column(
            'transmit_expire_time', sa.DateTime(
                timezone=True,
            ), nullable=True,
        ),
        sa.Column('heartbeat_interval', sa.Integer(), nullable=True),
        sa.Column(
            'last_heartbeat_request_time',
            sa.DateTime(timezone=True), nullable=True,
        ),
        sa.Column('channel_type', sa.String(), nullable=True),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column(
            'updated_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=True,
        ),
        sa.ForeignKeyConstraint(['cbsd_id'], ['cbsds.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['channel_id'], ['channels.id'], ondelete='CASCADE',
        ),
        sa.ForeignKeyConstraint(
            ['state_id'], ['grant_states.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'responses',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('request_id', sa.Integer(), nullable=True),
        sa.Column('grant_id', sa.Integer(), nullable=True),
        sa.Column('response_code', sa.Integer(), nullable=False),
        sa.Column(
            'created_date', sa.DateTime(timezone=True), server_default=sa.text(
                'statement_timestamp()',
            ), nullable=False,
        ),
        sa.Column('payload', sa.JSON(), nullable=True),
        sa.ForeignKeyConstraint(
            ['grant_id'], ['grants.id'], ondelete='CASCADE',
        ),
        sa.ForeignKeyConstraint(
            ['request_id'], ['requests.id'], ondelete='CASCADE',
        ),
        sa.PrimaryKeyConstraint('id'),
    )
    # ### end Alembic commands ###


def downgrade():
    """
    Run downgrade
    """
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('responses')
    op.drop_table('grants')
    op.drop_table('requests')
    op.drop_table('channels')
    op.drop_table('active_mode_configs')
    op.drop_table('cbsds')
    op.drop_table('request_types')
    op.drop_table('request_states')
    op.drop_table('grant_states')
    op.drop_table('domain_proxy_logs')
    op.drop_table('cbsd_states')
    # ### end Alembic commands ###

empty message  Revision ID: b0cad5321c88 Revises: Create Date: 2022-01-04 16:17:04.902652 # revision identifiers, used by Alembic. Run upgrade # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### Run downgrade # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###