<?php

namespace App\Contracts;

interface DatabaseDriverInterface
{
    /**
     * Set the connection parameters and establish a connection.
     */
    public function connect(array $config): bool;

    /**
     * Execute a raw query.
     */
    public function query(string $sql, array $bindings = []): array;

    /**
     * Get the table schema.
     */
    public function getTableSchema(string $table): array;

    /**
     * Get table data.
     */
    public function getTableData(string $table, int $limit = 100, int $offset = 0, array $filters = []): array;

    /**
     * Get the count of rows in a table.
     */
    public function getTableCount(string $table, array $filters = []): int;

    /**
     * Get the underlying connection instance.
     */
    public function getConnection();

    /**
     * Export the database.
     */
    public function export(array $config, array $filters = []): string;

    /**
     * Import the database.
     */
    public function import(array $config, string $filePath): bool;

    /**
     * Get database metadata (charset, collation, size, etc.)
     */
    public function getDatabaseMetadata(string $database): array;

    /**
     * Get table metadata.
     */
    public function getTableMetadata(string $database, string $table): array;

    /**
     * Get metadata for all tables in a database.
     */
    public function getTablesMetadata(string $database): array;

    /**
     * Truncate a table.
     */
    public function truncateTable(string $table): bool;

    /**
     * Drop a table.
     */
    public function dropTable(string $table): bool;

    /**
     * Optimize a table.
     */
    public function optimizeTable(string $table): bool;

    /**
     * Perform batch update on a table.
     */
    public function batchUpdate(string $table, array $changes): bool;

    /**
     * Create a new database.
     */
    public function createDatabase(string $name, string $charset = 'utf8mb4', string $collation = 'utf8mb4_unicode_ci'): bool;
}
