"""create settings table

Revision ID: a1b2c3d4e5f2
Revises: 6b2c3d4e5f01
Create Date: 2026-08-30

A single-row branding table (id always 1) for the company name and the uploaded
logo / favicon the rest of the interface displays.
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op


revision: str = 'a1b2c3d4e5f2'
down_revision: Union[str, None] = '6b2c3d4e5f01'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        'settings',
        sa.Column('id', sa.Integer(), primary_key=True),
        sa.Column(
            'company_name',
            sa.String(length=200),
            server_default='ISP Management System',
            nullable=False,
        ),
        sa.Column('logo_path', sa.String(length=500), server_default='', nullable=False),
        sa.Column('logo_content_type', sa.String(length=100), server_default='', nullable=False),
        sa.Column('favicon_path', sa.String(length=500), server_default='', nullable=False),
        sa.Column('favicon_content_type', sa.String(length=100), server_default='', nullable=False),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
        sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
    )
    # One row, always id 1 — the singleton the get endpoint reads.
    op.execute(
        "INSERT INTO settings (id, company_name) VALUES (1, 'ISP Management System')"
    )


def downgrade() -> None:
    op.drop_table('settings')
