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

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


CREATE_TASK_RUN_TABLE_INDEXES = """-- name: create_task_run_table_indexes \\:exec
DO $$
BEGIN
    -- Create indexes for hyrex_task_run table
    CREATE INDEX IF NOT EXISTS ix_hyrex_task_run_task_name
        ON public.hyrex_task_run (task_name);

    CREATE INDEX IF NOT EXISTS ix_hyrex_task_run_status
        ON public.hyrex_task_run (status);

    CREATE INDEX IF NOT EXISTS ix_hyrex_task_run_queue
        ON public.hyrex_task_run (queue);

    CREATE INDEX IF NOT EXISTS ix_hyrex_task_run_scheduled_start
        ON public.hyrex_task_run (scheduled_start);

    CREATE INDEX IF NOT EXISTS index_queue_status
        ON public.hyrex_task_run (status, queue, scheduled_start, task_name);

    CREATE UNIQUE INDEX IF NOT EXISTS ix_hyrex_task_run_idempotency_key
        ON public.hyrex_task_run (task_name, idempotency_key)
        WHERE idempotency_key IS NOT NULL;

    CREATE INDEX IF NOT EXISTS idx_hyrex_task_run_queue_status_priority_queued
        ON hyrex_task_run (queue, status, priority ASC, queued);

    CREATE INDEX IF NOT EXISTS idx_htr_queued_started_finished
        ON hyrex_task_run(queued, started, finished);

    CREATE INDEX IF NOT EXISTS idx_hyrex_task_run_root_id
        ON hyrex_task_run(root_id);
END $$
"""


@dataclasses.dataclass()
class CreateTaskRunTableIndexesParams:

    pass

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

    def create_task_run_table_indexes(self, arg: CreateTaskRunTableIndexesParams) -> None:
        self._conn.execute(sqlalchemy.text(CREATE_TASK_RUN_TABLE_INDEXES))


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

    async def create_task_run_table_indexes(self, arg: CreateTaskRunTableIndexesParams) -> None:
        await self._conn.execute(sqlalchemy.text(CREATE_TASK_RUN_TABLE_INDEXES))
