"""Json

迁移 ID: 5740c5aae763
父迁移: 25b14ed0ad3c
创建时间: 2025-08-21 15:46:52.697364

"""

from __future__ import annotations

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "5740c5aae763"
down_revision: str | Sequence[str] | None = "25b14ed0ad3c"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade(name: str = "") -> None:
    if name:
        return
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("suggarchat_memory_data", schema=None) as batch_op:
        batch_op.alter_column(
            "memory_json",
            existing_type=sa.TEXT(),
            type_=sa.JSON(),
            existing_nullable=False,
            existing_server_default="'{}'",
        )
        batch_op.alter_column(
            "sessions_json",
            existing_type=sa.TEXT(),
            type_=sa.JSON(),
            existing_nullable=False,
            existing_server_default="'[]'",
        )

    # ### end Alembic commands ###


def downgrade(name: str = "") -> None:
    if name:
        return
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("suggarchat_memory_data", schema=None) as batch_op:
        batch_op.alter_column(
            "sessions_json",
            existing_type=sa.JSON(),
            type_=sa.TEXT(),
            existing_nullable=False,
            existing_server_default="'[]'",
        )
        batch_op.alter_column(
            "memory_json",
            existing_type=sa.JSON(),
            type_=sa.TEXT(),
            existing_nullable=False,
            existing_server_default="'{}'",
        )

    # ### end Alembic commands ###
