"""empty message

Revision ID: 22771e69d10c
Revises: 8c7cbf0f76c6
Create Date: 2021-07-14 18:46:48.994109

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "22771e69d10c"
down_revision = "8c7cbf0f76c6"
branch_labels = None
depends_on = None


def upgrade():
    op.drop_constraint("participant_github_key", "participant", type_="unique")
    op.alter_column(
        "user", "username", existing_nullable=False, new_column_name="github_username"
    )
    op.add_column("user", sa.Column("first_name", sa.String(length=50), nullable=True))
    op.add_column("user", sa.Column("last_name", sa.String(length=50), nullable=True))
    op.add_column("user", sa.Column("email", sa.String(length=200), nullable=True))
    op.add_column("user", sa.Column("phone", sa.String(length=13), nullable=True))
    op.add_column("user", sa.Column("slack", sa.String(length=21), nullable=True))
    op.add_column("user", sa.Column("is_admin", sa.Boolean(), nullable=True))
    op.create_unique_constraint(None, "user", ["github_username"])

    op.alter_column(
        "participant",
        "github",
        nullable=False,
        new_column_name="github_username",
        server_default=None,
    )


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "user", type_="unique")
    op.create_unique_constraint("user_username_key", "user", ["username"])
    op.drop_column("user", "is_admin")
    op.drop_column("user", "slack")
    op.drop_column("user", "phone")
    op.drop_column("user", "email")
    op.drop_column("user", "last_name")
    op.drop_column("user", "first_name")
    op.drop_constraint(None, "participant", type_="unique")
    op.alter_column(
        "user", "github_username", nullable=False, new_column_name="username"
    )

    op.alter_column(
        "participant",
        "github_username",
        existing_nullable=False,
        new_column_name="github",
    )
    # ### end Alembic commands ###
