"""Add note_type and metadata columns to notes table for entity types."""

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

revision = "0036"
down_revision = "0035"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "notes",
        sa.Column("note_type", sa.Text(), nullable=False, server_default="note"),
    )
    op.add_column(
        "notes",
        sa.Column("metadata", JSONB(), nullable=True),
    )
    op.create_index("ix_notes_note_type", "notes", ["note_type"])


def downgrade() -> None:
    op.drop_index("ix_notes_note_type", table_name="notes")
    op.drop_column("notes", "metadata")
    op.drop_column("notes", "note_type")
