"""price_int_to_decimal

Revision ID: fc349d0897f2
Revises: 013
Create Date: 2026-05-16 22:04:23.534515

"""
from typing import Sequence, Union

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

revision: str = 'fc349d0897f2'
down_revision: Union[str, None] = '013'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.alter_column('product_pricings', 'price',
               existing_type=mysql.INTEGER(),
               type_=sa.Numeric(precision=10, scale=2),
               comment='周期内价格(元)',
               existing_nullable=False)
    op.alter_column('product_pricings', 'original_price',
               existing_type=mysql.INTEGER(),
               type_=sa.Numeric(precision=10, scale=2),
               comment='划线价(元)，仅用于前台展示',
               existing_nullable=True)
    op.alter_column('product_pricings', 'setup_fee',
               existing_type=mysql.INTEGER(),
               type_=sa.Numeric(precision=10, scale=2),
               comment='该周期下的一次性安装费(元)',
               existing_nullable=False,
               existing_server_default=sa.text("'0'"))
    op.alter_column('products', 'base_setup_fee',
               existing_type=mysql.INTEGER(),
               type_=sa.Numeric(precision=10, scale=2),
               comment='一次性安装费(元)',
               existing_nullable=False,
               existing_server_default=sa.text("'0'"))
    op.alter_column('products', 'base_price',
               existing_type=mysql.INTEGER(),
               type_=sa.Numeric(precision=10, scale=2),
               comment='基础月价(元)，用于卡片展示',
               existing_nullable=False,
               existing_server_default=sa.text("'0'"))


def downgrade() -> None:
    op.alter_column('products', 'base_price',
               existing_type=sa.Numeric(precision=10, scale=2),
               type_=mysql.INTEGER(),
               comment=None,
               existing_nullable=False,
               existing_server_default=sa.text("'0'"))
    op.alter_column('products', 'base_setup_fee',
               existing_type=sa.Numeric(precision=10, scale=2),
               type_=mysql.INTEGER(),
               comment=None,
               existing_nullable=False,
               existing_server_default=sa.text("'0'"))
    op.alter_column('product_pricings', 'setup_fee',
               existing_type=sa.Numeric(precision=10, scale=2),
               type_=mysql.INTEGER(),
               comment=None,
               existing_nullable=False,
               existing_server_default=sa.text("'0'"))
    op.alter_column('product_pricings', 'original_price',
               existing_type=sa.Numeric(precision=10, scale=2),
               type_=mysql.INTEGER(),
               comment=None,
               existing_nullable=True)
    op.alter_column('product_pricings', 'price',
               existing_type=sa.Numeric(precision=10, scale=2),
               type_=mysql.INTEGER(),
               comment=None,
               existing_nullable=False)
