"""Add toxicity score table

Revision ID: 2cdcefae64ef
Revises: 2d71226b9961
Create Date: 2023-11-13 20:07:05.047192

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "2cdcefae64ef"
down_revision = "2d71226b9961"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "keyword_matches",
        sa.Column("id", sa.String(), nullable=False),
        sa.Column("rule_result_detail_id", sa.String(), nullable=False),
        sa.Column("keyword", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["rule_result_detail_id"],
            ["rule_result_details.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_keyword_matches_id"),
        "keyword_matches",
        ["id"],
        unique=False,
    )
    op.create_table(
        "regex_matches",
        sa.Column("id", sa.String(), nullable=False),
        sa.Column("rule_result_detail_id", sa.String(), nullable=False),
        sa.Column("matching_text", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["rule_result_detail_id"],
            ["rule_result_details.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_regex_matches_id"), "regex_matches", ["id"], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_regex_matches_id"), table_name="regex_matches")
    op.drop_table("regex_matches")
    op.drop_index(op.f("ix_keyword_matches_id"), table_name="keyword_matches")
    op.drop_table("keyword_matches")
    # ### end Alembic commands ###
