"""Remove ads

Revision ID: 09f81a375c7f
Revises: e80c47585ffb
Create Date: 2025-02-28 10:46:46.559140

"""

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

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "09f81a375c7f"
down_revision = "e80c47585ffb"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        "ix_advertisement_campaigns_created_at", table_name="advertisement_campaigns"
    )
    op.drop_index(
        "ix_advertisement_campaigns_deleted_at", table_name="advertisement_campaigns"
    )
    op.drop_index(
        "ix_advertisement_campaigns_modified_at", table_name="advertisement_campaigns"
    )
    op.drop_table("advertisement_campaigns")

    op.execute("DELETE FROM benefits WHERE type = 'ads'")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "advertisement_campaigns",
        sa.Column("user_id", sa.UUID(), autoincrement=False, nullable=False),
        sa.Column("views", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column("clicks", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column("image_url", sa.VARCHAR(), autoincrement=False, nullable=False),
        sa.Column("image_url_dark", sa.VARCHAR(), autoincrement=False, nullable=True),
        sa.Column("text", sa.VARCHAR(), autoincrement=False, nullable=False),
        sa.Column("link_url", sa.VARCHAR(), autoincrement=False, nullable=False),
        sa.Column("id", sa.UUID(), autoincrement=False, nullable=False),
        sa.Column(
            "created_at",
            postgresql.TIMESTAMP(timezone=True),
            autoincrement=False,
            nullable=False,
        ),
        sa.Column(
            "modified_at",
            postgresql.TIMESTAMP(timezone=True),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "deleted_at",
            postgresql.TIMESTAMP(timezone=True),
            autoincrement=False,
            nullable=True,
        ),
        sa.ForeignKeyConstraint(
            ["user_id"], ["users.id"], name="advertisement_campaigns_user_id_fkey"
        ),
        sa.PrimaryKeyConstraint("id", name="advertisement_campaigns_pkey"),
    )
    op.create_index(
        "ix_advertisement_campaigns_modified_at",
        "advertisement_campaigns",
        ["modified_at"],
        unique=False,
    )
    op.create_index(
        "ix_advertisement_campaigns_deleted_at",
        "advertisement_campaigns",
        ["deleted_at"],
        unique=False,
    )
    op.create_index(
        "ix_advertisement_campaigns_created_at",
        "advertisement_campaigns",
        ["created_at"],
        unique=False,
    )
    # ### end Alembic commands ###
