# type: ignore
"""Add service job resources

Revision ID: 024848c488c2
Revises: 4dfd6eed368a
Create Date: 2025-06-30 16:17:52.294508+00:00

"""

from __future__ import annotations

import warnings
from typing import TYPE_CHECKING

import sqlalchemy as sa
from alembic import op
from advanced_alchemy.types import (
    EncryptedString,
    EncryptedText,
    GUID,
    ORA_JSONB,
    DateTimeUTC,
)
from sqlalchemy import Text  # noqa: F401

if TYPE_CHECKING:
    pass

__all__ = [
    "downgrade",
    "upgrade",
    "schema_upgrades",
    "schema_downgrades",
    "data_upgrades",
    "data_downgrades",
]

sa.GUID = GUID
sa.DateTimeUTC = DateTimeUTC
sa.ORA_JSONB = ORA_JSONB
sa.EncryptedString = EncryptedString
sa.EncryptedText = EncryptedText

# revision identifiers, used by Alembic.
revision = "024848c488c2"
down_revision = "4dfd6eed368a"
branch_labels = None
depends_on = None


def upgrade() -> None:
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", category=UserWarning)
        with op.get_context().autocommit_block():
            schema_upgrades()
            data_upgrades()


def downgrade() -> None:
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", category=UserWarning)
        with op.get_context().autocommit_block():
            data_downgrades()
            schema_downgrades()


def schema_upgrades() -> None:
    """schema upgrade migrations go here."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("service", schema=None) as batch_op:
        batch_op.add_column(sa.Column("time", sa.String(), nullable=True))
        batch_op.add_column(sa.Column("ntasks_per_node", sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column("mem", sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column("gres", sa.String(), nullable=True))
        batch_op.add_column(sa.Column("partition", sa.String(), nullable=True))
        batch_op.add_column(sa.Column("constraint", sa.String(), nullable=True))

    # ### end Alembic commands ###


def schema_downgrades() -> None:
    """schema downgrade migrations go here."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("service", schema=None) as batch_op:
        batch_op.drop_column("constraint")
        batch_op.drop_column("partition")
        batch_op.drop_column("gres")
        batch_op.drop_column("mem")
        batch_op.drop_column("ntasks_per_node")
        batch_op.drop_column("time")

    # ### end Alembic commands ###


def data_upgrades() -> None:
    """Add any optional data upgrade migrations here!"""


def data_downgrades() -> None:
    """Add any optional data downgrade migrations here!"""
