"""Add relation to users in to todo modul

Revision ID: 28f748937454
Revises: 5169d562c728
Create Date: 2014-01-03 21:18:02.855767

"""

# revision identifiers, used by Alembic.
revision = '28f748937454'
down_revision = '5169d562c728'

from alembic import op
import sqlalchemy as sa


INSERTS = """"""
DELETES = """"""


def iter_statements(stmts):
    for st in [x for x in stmts.split('\n') if x]:
        op.execute(st)


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('nm_todo_users',
    sa.Column('uid', sa.Integer(), nullable=True),
    sa.Column('tid', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['tid'], ['todos.id'], ),
    sa.ForeignKeyConstraint(['uid'], ['users.id'], ),
    sa.PrimaryKeyConstraint()
    )
    op.add_column(u'todos', sa.Column('assigned_id', sa.Integer(), nullable=True))
    ### end Alembic commands ###
    iter_statements(INSERTS)


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column(u'todos', 'assigned_id')
    op.drop_table('nm_todo_users')
    ### end Alembic commands ###
    iter_statements(DELETES)
