"""create oem table

Revision ID: 008
Revises: 007
Create Date: 2026-05-21

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "008"
down_revision: Union[str, None] = "007"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "oem",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("user_id", sa.Integer(), nullable=False),
        sa.Column("software_name", sa.String(length=128), server_default="", nullable=False),
        sa.Column("logo_path", sa.Text(), nullable=True),
        sa.Column("wechat", sa.String(length=128), nullable=True),
        sa.Column("qq", sa.String(length=128), nullable=True),
        sa.Column("wechat_qrcode", sa.Text(), nullable=True),
        sa.Column("qq_qrcode", sa.Text(), nullable=True),
        sa.Column("description", sa.String(length=255), nullable=True),
        sa.Column(
            "created_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("CURRENT_TIMESTAMP"),
            nullable=False,
        ),
        sa.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("CURRENT_TIMESTAMP"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="RESTRICT"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_oem_user_id"), "oem", ["user_id"], unique=False)


def downgrade() -> None:
    op.drop_index(op.f("ix_oem_user_id"), table_name="oem")
    op.drop_table("oem")
