"""Server-wide settings set from the Admin page (the monthly AI spending cap).

Revision ID: 0005
Revises: 0004
Create Date: 2026-09-18
"""

from alembic import op

revision = "0005"
down_revision = "0004"
branch_labels = None
depends_on = None

UPGRADE = """
CREATE TABLE app_settings (
    name text PRIMARY KEY,
    value jsonb NOT NULL,
    updated_by integer REFERENCES users(id) ON DELETE SET NULL,
    updated_at timestamptz NOT NULL DEFAULT now()
);
"""


def upgrade() -> None:
    op.execute(UPGRADE)


def downgrade() -> None:
    op.execute("DROP TABLE app_settings")
