"""convert savings_record.dishes from json to jsonb

PG only. SQLite 上 JSON/JSONB 都是 TEXT, 此迁移是 no-op。

Revision ID: ef96beb47b1e
Revises: c8d9e0f1a2b3
Create Date: 2026-05-29 10:57:21.471774
"""
from typing import Sequence, Union

from alembic import op
from sqlalchemy.dialects.postgresql import JSONB


revision: str = 'ef96beb47b1e'
down_revision: Union[str, Sequence[str], None] = 'c8d9e0f1a2b3'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    if op.get_bind().dialect.name != "postgresql":
        return
    op.execute(
        "ALTER TABLE savings_record "
        "ALTER COLUMN dishes TYPE JSONB USING dishes::JSONB"
    )


def downgrade() -> None:
    if op.get_bind().dialect.name != "postgresql":
        return
    op.execute(
        "ALTER TABLE savings_record "
        "ALTER COLUMN dishes TYPE JSON USING dishes::JSON"
    )
