"""Add raw file models

Revision ID: 0007
Revises: 0006
Create Date: 2022-04-04 18:09:09.363168

"""

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

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


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "raw_file",
        sa.Column("id", postgresql.UUID(), nullable=False),
        sa.Column("secure_hash", sa.String(), nullable=True),
        sa.Column("hash_retrieval_link", sa.String(), nullable=True),
        sa.Column("boefje_meta_id", postgresql.UUID(), nullable=False),
        sa.Column("mime_types", postgresql.ARRAY(sa.String()), nullable=True),
        sa.ForeignKeyConstraint(["boefje_meta_id"], ["boefje_meta.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.drop_column("boefje_meta", "hash_retrieval_link")
    op.drop_column("boefje_meta", "secure_hash")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("boefje_meta", sa.Column("secure_hash", sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column("boefje_meta", sa.Column("hash_retrieval_link", sa.VARCHAR(), autoincrement=False, nullable=True))
    op.drop_table("raw_file")
    # ### end Alembic commands ###
