"""system settings table

Revision ID: 002
Revises: 001
Create Date: 2026-03-01

"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa

revision: str = "002"
down_revision: Union[str, None] = "001"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "system_settings",
        sa.Column("key", sa.String(100), primary_key=True),
        sa.Column("value", sa.Text(), nullable=True),
        sa.Column("updated_at", sa.DateTime(), nullable=True, server_default=sa.func.now()),
    )
    # Insert defaults
    op.execute(
        "INSERT INTO system_settings (key, value, updated_at) VALUES "
        "('thumbnail_renderer', 'pillow', NOW())"
    )


def downgrade() -> None:
    op.drop_table("system_settings")
