"""Add signing provider model

Revision ID: 09a2929108d9
Revises: ec68d3eb14b1
Create Date: 2023-05-19 08:24:39.803682

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "09a2929108d9"
down_revision = "ec68d3eb14b1"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "signing_provider",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("url", sa.String(length=256), nullable=False),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("url"),
    )
    op.add_column("raw_file", sa.Column("signing_provider_id", sa.Integer(), nullable=True))
    op.create_index(op.f("ix_raw_file_signing_provider_id"), "raw_file", ["signing_provider_id"], unique=False)
    op.create_foreign_key(None, "raw_file", "signing_provider", ["signing_provider_id"], ["id"], ondelete="CASCADE")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "raw_file", type_="foreignkey")
    op.drop_index(op.f("ix_raw_file_signing_provider_id"), table_name="raw_file")
    op.drop_column("raw_file", "signing_provider_id")
    op.drop_table("signing_provider")
    # ### end Alembic commands ###
