<gh_stars>100-1000
"""Alter Constraints

Revision ID: 3a37e844b277
Revises: <PASSWORD>
Create Date: 2016-05-30 15:57:56.017519

"""

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '<PASSWORD>'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'last_name')
    op.drop_column('users', 'first_name')
    ### end Alembic commands ###
    with op.batch_alter_table("notes") as batch_op:
        batch_op.drop_constraint(
            "notes_author_id_fkey", type_="foreignkey")
    with op.batch_alter_table("notebooks") as batch_op:
        batch_op.drop_constraint(
            "notebooks_author_id_fkey", type_="foreignkey")
    op.create_foreign_key(
        "notes_author_id_fkey", "notes", "users", 
        ["author_id"], ["id"], ondelete="CASCADE")
    op.create_foreign_key(
        "notebooks_author_id_fkey", "notebooks", "users", 
        ["author_id"], ["id"], ondelete="CASCADE")

def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('first_name', sa.VARCHAR(length=200), autoincrement=False, nullable=True))
    op.add_column('users', sa.Column('last_name', sa.VARCHAR(length=200), autoincrement=False, nullable=True))
    ### end Alembic commands ###
   