"""add missing_elevations_processing to 'users' and 'workouts' tables

Revision ID: c59425f77851
Revises: e63433a1d62e
Create Date: 2025-11-09 19:09:16.579739

"""

from alembic import op
import sqlalchemy as sa

from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "c59425f77851"
down_revision = "3dbea67b5e3b"
branch_labels = None
depends_on = None

elevations_processing = postgresql.ENUM(
    'NONE', 'OPEN_ELEVATION', 'OPEN_ELEVATION_SMOOTH',
    name="elevations_processing"
)
elevations_processing.create(op.get_bind(), checkfirst=True)


def upgrade():
    with op.batch_alter_table("users", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "missing_elevations_processing",
                elevations_processing,
                server_default="NONE",
                nullable=False,
            )
        )

    with op.batch_alter_table("workouts", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "missing_elevations_processing",
                elevations_processing,
                server_default="NONE",
                nullable=False,
            )
        )


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("workouts", schema=None) as batch_op:
        batch_op.drop_column("missing_elevations_processing")

    with op.batch_alter_table("users", schema=None) as batch_op:
        batch_op.drop_column("missing_elevations_processing")

    # ### end Alembic commands ###
    elevations_processing.drop(op.get_bind())
