'''create alerts table

Revision ID: 0ea6b0444581
Revises: 409581df8e2d
Create Date: 2021-08-02 16:09:19.328185

'''
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '0ea6b0444581'
down_revision = '409581df8e2d'
branch_labels = ()
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'alerts',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.Column('query', sa.String(length=2048), nullable=True),
        sa.Column('duration', sa.String(length=32), server_default='1m', nullable=False),
        sa.Column('severity', sa.String(length=32), server_default='warn', nullable=False),
        sa.Column('annotations', sa.JSON(), nullable=False),
        sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('project_id', 'name', name='u_project_name'),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('alerts')
    # ### end Alembic commands ###
