"""products_cpu_fields_and_drop_description

Revision ID: 008
Revises: 007
Create Date: 2026-05-16 00:00:00.000000

产品规格字段重构：
- 删除 products.description（前端不再展示长描述）
- 删除 products.cpu（旧的单字符串字段，被结构化四列取代）
- 新增 vcpu (Integer) / cpu_model (String 64) / cpu_base_mhz (Integer) / cpu_turbo_mhz (Integer)
  主频 / 睿频统一以 "MHz" 整数存储，避免小数。前端展示时除以 1000 得 GHz。
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "008"
down_revision: Union[str, None] = "007"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.drop_column("products", "description")
    op.drop_column("products", "cpu")
    op.add_column("products", sa.Column("vcpu", sa.Integer(), nullable=True))
    op.add_column("products", sa.Column("cpu_model", sa.String(length=64), nullable=True))
    op.add_column("products", sa.Column("cpu_base_mhz", sa.Integer(), nullable=True))
    op.add_column("products", sa.Column("cpu_turbo_mhz", sa.Integer(), nullable=True))


def downgrade() -> None:
    op.drop_column("products", "cpu_turbo_mhz")
    op.drop_column("products", "cpu_base_mhz")
    op.drop_column("products", "cpu_model")
    op.drop_column("products", "vcpu")
    op.add_column("products", sa.Column("cpu", sa.String(length=64), nullable=True))
    op.add_column("products", sa.Column("description", sa.Text(), nullable=True))
