"""Add missing date column on Event model

Revision ID: 92408c73bdb9
Revises: 21ee688a6aa6
Create Date: 2020-09-09 13:40:13.489661

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '92408c73bdb9'
down_revision = '21ee688a6aa6'
branch_labels = None
depends_on = None


def upgrade():
    # Temp default to circumnavigate non null constraint
    from datetime import datetime
    temp = str(datetime(1900, 1, 1).date())

    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('event', sa.Column('date', sa.Date(), nullable=False, server_default=temp))
    op.create_unique_constraint('uix__event__guid', 'event', ['guid'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('uix__event__guid', 'event', type_='unique')
    op.drop_column('event', 'date')
    # ### end Alembic commands ###
