"""rethink_authors

Revision ID: f7c8c10f5aea
Revises: a456f2c3a68d
Create Date: 2017-07-14 13:20:01.610676

"""
import zeus
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "f7c8c10f5aea"
down_revision = "a456f2c3a68d"
branch_labels = ()
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("ix_build_author_id", table_name="build")
    op.drop_constraint("build_author_id_fkey", "build", type_="foreignkey")
    op.drop_column("build", "author_id")
    op.add_column(
        "source", sa.Column("author_id", zeus.db.types.guid.GUID(), nullable=True)
    )
    op.create_index(op.f("ix_source_author_id"), "source", ["author_id"], unique=False)
    op.create_foreign_key(None, "source", "author", ["author_id"], ["id"])


# ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "source", type_="foreignkey")
    op.drop_index(op.f("ix_source_author_id"), table_name="source")
    op.drop_column("source", "author_id")
    op.add_column(
        "build",
        sa.Column("author_id", postgresql.UUID(), autoincrement=False, nullable=True),
    )
    op.create_foreign_key(
        "build_author_id_fkey", "build", "author", ["author_id"], ["id"]
    )
    op.create_index("ix_build_author_id", "build", ["author_id"], unique=False)


# ### end Alembic commands ###
