"""empty message

Revision ID: fc8b9a0a819c
Revises: c48c45d5402e
Create Date: 2023-12-16 16:25:40.257569

"""
import sqlalchemy as sa
from alembic import op

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


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        "filepaths_story_id_post_id_message_id_mass_message_id_media_key",
        "filepaths",
        schema="fansly",
        type_="unique",
    )
    op.create_unique_constraint(
        "filepaths_un",
        "filepaths",
        ["story_id", "post_id", "message_id", "mass_message_id", "media_id"],
        schema="fansly",
    )
    op.drop_constraint(
        "filepaths_story_id_post_id_message_id_mass_message_id_media_key",
        "filepaths",
        schema="onlyfans",
        type_="unique",
    )
    op.create_unique_constraint(
        "filepaths_un",
        "filepaths",
        ["story_id", "post_id", "message_id", "mass_message_id", "media_id"],
        schema="onlyfans",
    )
    op.execute(
        f"""
        ALTER TABLE onlyfans.filepaths
        ADD CONSTRAINT filepaths_un_check
        CHECK (
            (story_id IS NOT DISTINCT FROM story_id) AND
            (post_id IS NOT DISTINCT FROM post_id) AND
            (message_id IS NOT DISTINCT FROM message_id) AND
            (mass_message_id IS NOT DISTINCT FROM mass_message_id) AND
            (media_id IS NOT DISTINCT FROM media_id)
        )
        """
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("filepaths_un", "filepaths", schema="onlyfans", type_="unique")
    op.create_unique_constraint(
        "filepaths_story_id_post_id_message_id_mass_message_id_media_key",
        "filepaths",
        ["story_id", "post_id", "message_id", "mass_message_id", "media_id"],
        schema="onlyfans",
    )
    op.execute(
        f"ALTER TABLE onlyfans.filepaths DROP CONSTRAINT IF EXISTS filepaths_un_check"
    )
    op.drop_constraint("filepaths_un", "filepaths", schema="fansly", type_="unique")
    op.create_unique_constraint(
        "filepaths_story_id_post_id_message_id_mass_message_id_media_key",
        "filepaths",
        ["story_id", "post_id", "message_id", "mass_message_id", "media_id"],
        schema="fansly",
    )
    op.execute(
        f"ALTER TABLE fansly.filepaths DROP CONSTRAINT IF EXISTS filepaths_un_check"
    )
    # ### end Alembic commands ###
