"""Add audit table

Revision ID: 161e0f33603c
Revises: 02c137632f24
Create Date: 2022-11-21 17:50:45.798110

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '161e0f33603c'
down_revision = '02c137632f24'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('audit_history',
        sa.Column('id', sa.Integer(), nullable=False, autoincrement=True),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('username', sa.String(length=128), nullable=True),
        sa.Column('action', sa.Enum('NAMESPACE_CREATE', 'MODULE_PROVIDER_CREATE', 'MODULE_PROVIDER_DELETE', 'MODULE_PROVIDER_UPDATE_GIT_TAG_FORMAT', 'MODULE_PROVIDER_UPDATE_GIT_PROVIDER', 'MODULE_PROVIDER_UPDATE_GIT_PATH', 'MODULE_PROVIDER_UPDATE_GIT_CUSTOM_BASE_URL', 'MODULE_PROVIDER_UPDATE_GIT_CUSTOM_CLONE_URL', 'MODULE_PROVIDER_UPDATE_GIT_CUSTOM_BROWSE_URL', 'MODULE_PROVIDER_UPDATE_VERIFIED', 'MODULE_VERSION_INDEX', 'MODULE_VERSION_PUBLISH', 'MODULE_VERSION_DELETE', 'USER_GROUP_CREATE', 'USER_GROUP_DELETE', 'USER_GROUP_NAMESPACE_PERMISSION_ADD', 'USER_GROUP_NAMESPACE_PERMISSION_MODIFY', 'USER_GROUP_NAMESPACE_PERMISSION_DELETE', 'USER_LOGIN', name='auditaction'), nullable=True),
        sa.Column('object_type', sa.String(length=128), nullable=True),
        sa.Column('object_id', sa.String(length=128), nullable=True),
        sa.Column('old_value', sa.String(length=128), nullable=True),
        sa.Column('new_value', sa.String(length=128), nullable=True),
        sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


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