"""fc3b: rename credential.kind -> credential_type, drop status, add last_verified

Revision ID: 0011
Revises: 0010
Create Date: 2026-05-20

Aligns the credential table with the GallerySubscriber wire-field names
so the existing browser extension can POST to FC unmodified. Greenfield —
no rows exist in production yet, so no data preservation logic is
needed; the rename uses ALTER COLUMN rather than copy-then-drop.
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "0011"
down_revision: Union[str, None] = "0010"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.alter_column("credential", "kind", new_column_name="credential_type")
    op.drop_column("credential", "status")
    op.add_column(
        "credential",
        sa.Column("last_verified", sa.DateTime(timezone=True), nullable=True),
    )


def downgrade() -> None:
    op.drop_column("credential", "last_verified")
    op.add_column(
        "credential",
        sa.Column(
            "status", sa.String(length=32), nullable=False,
            server_default="active",
        ),
    )
    op.alter_column("credential", "credential_type", new_column_name="kind")
