"""Add audit table for audit entries.

Revision ID: 04f3eab9ae7a
Revises: b517e37877c8
Create Date: 2017-04-11 18:40:04.195180

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '04f3eab9ae7a'
down_revision = 'b517e37877c8'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('audit',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.Integer(), nullable=False),
    sa.Column('type', sa.String(length=64), nullable=False),
    sa.Column('data', sa.JSON(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    mysql_charset='utf8mb4'
    )
    op.create_index(op.f('ix_audit_timestamp'), 'audit', ['timestamp'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_audit_timestamp'), table_name='audit')
    op.drop_table('audit')
    # ### end Alembic commands ###
