"""add service info settings

Revision ID: 0008_service_settings
Revises: 0007_email_templates
Create Date: 2026-02-13
"""

from alembic import op
import sqlalchemy as sa


revision = "0008_service_settings"
down_revision = "0007_email_templates"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.create_table(
        "service_info_settings",
        sa.Column("id", sa.Integer(), primary_key=True),
        sa.Column("current_version", sa.String(length=64), nullable=False, server_default="0.1.0"),
        sa.Column("release_check_url", sa.String(length=500), nullable=True),
        sa.Column("latest_version", sa.String(length=64), nullable=True),
        sa.Column("update_available", sa.Boolean(), nullable=False, server_default=sa.false()),
        sa.Column("last_checked_at", sa.DateTime(timezone=True), nullable=True),
        sa.Column("last_check_error", sa.Text(), nullable=True),
        sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.text("now()")),
        sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.text("now()")),
    )


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