"""Initial metadata

Revision ID: cfae1eb34e12
Revises:
Create Date: 2020-11-29 01:42:48.998482

"""
import sqlalchemy as sa
from alembic import op

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "dialogs",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column(
            "messenger",
            sa.Enum("telegram", "viber", "whatapp", name="messengers"),
            nullable=False,
        ),
        sa.Column("username", sa.String(), nullable=True),
        sa.PrimaryKeyConstraint("id", "messenger"),
    )
    op.create_table(
        "dialog_steps",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("dialog_id", sa.Integer(), nullable=True),
        sa.Column(
            "messenger",
            sa.Enum("telegram", "viber", "whatapp", name="messengers"),
            nullable=True,
        ),
        sa.Column("question", sa.String(), nullable=True),
        sa.Column("answer", sa.String(), nullable=True),
        sa.ForeignKeyConstraint(
            ["dialog_id", "messenger"],
            ["dialogs.id", "dialogs.messenger"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("dialog_steps")
    op.drop_table("dialogs")
    # ### end Alembic commands ###
