"""initial migration

Revision ID: feff0a935860
Revises:
Create Date: 2021-05-11 10:52:32.784352

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

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "organisation",
        sa.Column("id", postgresql.UUID(), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("domain", sa.String(), nullable=False),
        sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
        sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_organisation_created_at"), "organisation", ["created_at"], unique=False)
    op.create_index(op.f("ix_organisation_domain"), "organisation", ["domain"], unique=True)
    op.create_index(op.f("ix_organisation_name"), "organisation", ["name"], unique=False)
    op.create_table(
        "programme",
        sa.Column("id", postgresql.UUID(), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("programme_manager", sa.String(), nullable=False),
        sa.Column("organisation_id", postgresql.UUID(), nullable=False),
        sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
        sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
        sa.ForeignKeyConstraint(["organisation_id"], ["organisation.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_programme_created_at"), "programme", ["created_at"], unique=False)
    op.create_index(op.f("ix_programme_name"), "programme", ["name"], unique=False)
    op.create_index(
        op.f("ix_programme_programme_manager"),
        "programme",
        ["programme_manager"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_programme_programme_manager"), table_name="programme")
    op.drop_index(op.f("ix_programme_name"), table_name="programme")
    op.drop_index(op.f("ix_programme_created_at"), table_name="programme")
    op.drop_table("programme")
    op.drop_index(op.f("ix_organisation_name"), table_name="organisation")
    op.drop_index(op.f("ix_organisation_domain"), table_name="organisation")
    op.drop_index(op.f("ix_organisation_created_at"), table_name="organisation")
    op.drop_table("organisation")
    # ### end Alembic commands ###
