"""empty message

Revision ID: dab9687afeeb
Revises: 37f460a1f4d2
Create Date: 2019-04-24 16:47:12.721137

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'dab9687afeeb'
down_revision = '37f460a1f4d2'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('space',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('project_space_assoc',
    sa.Column('project', sa.Integer(), nullable=True),
    sa.Column('space', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['project'], ['project.id'], ),
    sa.ForeignKeyConstraint(['space'], ['space.id'], )
    )
    op.add_column('field', sa.Column('space_id', sa.Integer(), nullable=True))
    op.drop_constraint('field_project_id_fkey', 'field', type_='foreignkey')
    op.create_foreign_key(None, 'field', 'space', ['space_id'], ['id'])
    op.drop_column('field', 'project_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('field', sa.Column('project_id', sa.INTEGER(), autoincrement=False, nullable=False))
    op.drop_constraint(None, 'field', type_='foreignkey')
    op.create_foreign_key('field_project_id_fkey', 'field', 'project', ['project_id'], ['id'])
    op.drop_column('field', 'space_id')
    op.drop_table('project_space_assoc')
    op.drop_table('space')
    # ### end Alembic commands ###
