"""Baseline

Revision ID: 4cec02cae1c1
Revises:
Create Date: 2023-11-18 15:50:35.279991

"""

from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "user_stripe",
        sa.Column("user_account_uuid", sa.UUID(), nullable=False),
        sa.Column("stripe_customer_id", sa.String(length=30), nullable=False),
        sa.ForeignKeyConstraint(
            ["user_account_uuid"], ["user_account.uuid"], ondelete="CASCADE"
        ),
        sa.PrimaryKeyConstraint("user_account_uuid"),
        sa.UniqueConstraint("stripe_customer_id"),
        sa.UniqueConstraint("user_account_uuid"),
    )
    op.create_unique_constraint(
        "_granted_permission_uc",
        "granted_permission",
        ["user_role_uuid", "permission_uuid"],
    )
    op.create_unique_constraint(
        "_granted_user_role_uc",
        "granted_user_role",
        ["user_account_uuid", "user_role_uuid"],
    )
    op.create_unique_constraint(None, "user_login", ["user_account_uuid"])
    op.create_unique_constraint(None, "user_profile", ["user_account_uuid"])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "user_profile", type_="unique")
    op.drop_constraint(None, "user_login", type_="unique")
    op.drop_constraint("_granted_user_role_uc", "granted_user_role", type_="unique")
    op.drop_constraint("_granted_permission_uc", "granted_permission", type_="unique")
    op.drop_table("user_stripe")
    # ### end Alembic commands ###
