<?php

declare(strict_types=1);

namespace Apexl\Vault\Interfaces;

use stdClass;

/**
 * Reading and shaping the structure of a store, as opposed to the rows in it.
 *
 * These sat on the query builder, which is why `mongodb` had to implement
 * `createTable(..., string $engine = 'INNODB')` — an argument that only means
 * anything to MySQL, on a store with no tables and no engines. DDL is not something
 * every builder can do, and where a store can do it the vocabulary is its own, so it
 * is a contract of its own and the MySQL-shaped details live in the MySQL
 * implementation.
 */
interface SchemaInterface
{
    /**
     * The columns of a table, one row per column, in whatever shape the store
     * describes them. Empty where the store has no fixed structure to report.
     *
     * @return array<int, stdClass>
     */
    public function describe(string $table): array;

    /**
     * @param stdClass $colList `_columns`, `primary_key`, and optionally `_indexes`
     *                          and `_unique`.
     */
    public function createTable(string $table, stdClass $colList, bool $existsCheck = true): void;

    public function keyIsAutoIncrementing(string $keyField, string $table): bool;
}
