"""meeting motion / vote support

Revision ID: 4e95ae391320
Revises: f8079d6a160c
Create Date: 2020-06-06 12:11:20.831100

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4e95ae391320'
down_revision = 'f8079d6a160c'
branch_labels = None
depends_on = None


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('motion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('interest_id', sa.Integer(), nullable=True),
    sa.Column('meeting_id', sa.Integer(), nullable=True),
    sa.Column('agendaitem_id', sa.Integer(), nullable=True),
    sa.Column('motion', sa.Text(), nullable=True),
    sa.Column('status', sa.Enum('open', 'tabled', 'approved', 'rejected'), nullable=True),
    sa.Column('comments', sa.Text(), nullable=True),
    sa.Column('version_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['agendaitem_id'], ['agendaitem.id'], ),
    sa.ForeignKeyConstraint(['interest_id'], ['localinterest.id'], ),
    sa.ForeignKeyConstraint(['meeting_id'], ['meeting.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('motionvote',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('interest_id', sa.Integer(), nullable=True),
    sa.Column('motion_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('vote', sa.Enum('approved', 'rejected', 'abstained', 'novote'), nullable=True),
    sa.Column('version_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['interest_id'], ['localinterest.id'], ),
    sa.ForeignKeyConstraint(['motion_id'], ['motion.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['localuser.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade_():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('motionvote')
    op.drop_table('motion')
    # ### end Alembic commands ###


def upgrade_users():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###


def downgrade_users():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###

