"""Revamp CustomerMEter

Revision ID: b8cab456f609
Revises: 09ba7a51ad09
Create Date: 2025-04-04 08:46:19.220184

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

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


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("DELETE FROM customer_meters")

    op.add_column(
        "customer_meters", sa.Column("consumed_units", sa.Numeric(), nullable=False)
    )
    op.add_column(
        "customer_meters", sa.Column("credited_units", sa.Integer(), nullable=False)
    )
    op.add_column("customer_meters", sa.Column("balance", sa.Numeric(), nullable=False))
    op.drop_column("customer_meters", "units_balance")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("DELETE FROM customer_meters")

    op.add_column(
        "customer_meters",
        sa.Column("units_balance", sa.NUMERIC(), autoincrement=False, nullable=False),
    )
    op.drop_column("customer_meters", "balance")
    op.drop_column("customer_meters", "credited_units")
    op.drop_column("customer_meters", "consumed_units")
    # ### end Alembic commands ###
