"""Add trial fields

Revision ID: 715685e22026
Revises: 58d4a7f5f6bb
Create Date: 2025-09-19 09:03:30.990749

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "715685e22026"
down_revision = "58d4a7f5f6bb"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "checkout_links",
        sa.Column(
            "trial_interval",
            sa.String(),
            nullable=True,
        ),
    )
    op.add_column(
        "checkout_links", sa.Column("trial_interval_count", sa.Integer(), nullable=True)
    )
    op.add_column(
        "checkouts", sa.Column("trial_end", sa.TIMESTAMP(timezone=True), nullable=True)
    )
    op.add_column(
        "checkouts",
        sa.Column(
            "trial_interval",
            sa.String(),
            nullable=True,
        ),
    )
    op.add_column(
        "checkouts", sa.Column("trial_interval_count", sa.Integer(), nullable=True)
    )
    op.add_column(
        "products",
        sa.Column(
            "trial_interval",
            sa.String(),
            nullable=True,
        ),
    )
    op.add_column(
        "products", sa.Column("trial_interval_count", sa.Integer(), nullable=True)
    )
    op.add_column(
        "subscriptions",
        sa.Column("trial_start", sa.TIMESTAMP(timezone=True), nullable=True),
    )
    op.add_column(
        "subscriptions",
        sa.Column("trial_end", sa.TIMESTAMP(timezone=True), nullable=True),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("subscriptions", "trial_end")
    op.drop_column("subscriptions", "trial_start")
    op.drop_column("products", "trial_interval_count")
    op.drop_column("products", "trial_interval")
    op.drop_column("checkouts", "trial_interval_count")
    op.drop_column("checkouts", "trial_interval")
    op.drop_column("checkouts", "trial_end")
    op.drop_column("checkout_links", "trial_interval_count")
    op.drop_column("checkout_links", "trial_interval")
    # ### end Alembic commands ###
