"""empty message

Revision ID: f0567e8d0c62
Revises: a23682ccc1f1
Create Date: 2018-04-26 17:24:47.093547

"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
import uuid

# revision identifiers, used by Alembic.
revision = "f0567e8d0c62"
down_revision = "a23682ccc1f1"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "entity",
        sa.Column(
            "source_id",
            sqlalchemy_utils.types.uuid.UUIDType(binary=False),
            default=uuid.uuid4,
            nullable=True,
        ),
    )
    op.create_index(
        op.f("ix_entity_source_id"), "entity", ["source_id"], unique=False
    )
    op.create_foreign_key(None, "entity", "entity", ["source_id"], ["id"])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "entity", type_="foreignkey")
    op.drop_index(op.f("ix_entity_source_id"), table_name="entity")
    op.drop_column("entity", "source_id")
    # ### end Alembic commands ###
