# Code generated by sqlc. DO NOT EDIT.
# versions:
#   sqlc v1.29.0
# source: _12_create_hyrex_task_run_table.sql
import dataclasses

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


CREATE_TASK_RUN_TABLE = """-- name: create_task_run_table \\:exec
CREATE TABLE IF NOT EXISTS hyrex_task_run (
                                              id              UUID                        NOT NULL PRIMARY KEY,
                                              durable_id      UUID                        NOT NULL,
                                              root_id         UUID                        NOT NULL,
                                              parent_id       UUID,
                                              workflow_run_id UUID DEFAULT NULL,
                                              workflow_dependencies UUID[] DEFAULT NULL,
                                              task_name       VARCHAR                     NOT NULL,
                                              args            JSON                        NOT NULL,
                                              queue           VARCHAR                     NOT NULL,
                                              max_retries     SMALLINT                    NOT NULL,
                                              priority        SMALLINT                    NOT NULL,
                                              timeout_seconds INT                         DEFAULT NULL CHECK (timeout_seconds IS NULL OR timeout_seconds > 0),
                                              status          task_run_status             NOT NULL,
                                              attempt_number  SMALLINT                    NOT NULL,
                                              scheduled_start TIMESTAMP WITH TIME ZONE,
                                              executor_id     UUID,
                                              queued          TIMESTAMP WITH TIME ZONE,
                                              started         TIMESTAMP WITH TIME ZONE,
                                              finished        TIMESTAMP WITH TIME ZONE,
                                              last_heartbeat  TIMESTAMP WITH TIME ZONE,
                                              idempotency_key VARCHAR,
                                              log_link        VARCHAR
)
"""


@dataclasses.dataclass()
class CreateTaskRunTableParams:

    pass

class Querier:
    def __init__(self, conn: sqlalchemy.engine.Connection):
        self._conn = conn

    def create_task_run_table(self, arg: CreateTaskRunTableParams) -> None:
        self._conn.execute(sqlalchemy.text(CREATE_TASK_RUN_TABLE))


class AsyncQuerier:
    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
        self._conn = conn

    async def create_task_run_table(self, arg: CreateTaskRunTableParams) -> None:
        await self._conn.execute(sqlalchemy.text(CREATE_TASK_RUN_TABLE))
