/**
 * The media schema for the Lucid store, as standalone functions.
 *
 * By default {@link LucidMediaStore} auto-creates the `media` table on first use
 * (`autoCreateSchema`, the ecosystem convention — a lib owns its own schema, same
 * as `@adonis-agora/authz`'s `createAuthzTables` and `@adonis-agora/durable`'s
 * `createDurableTables`). An app that prefers explicit control sets
 * `autoCreateSchema: false` and calls {@link createMediaTables} from a Lucid
 * migration instead. Both paths run the SAME DDL — the store's `ensureSchema`
 * delegates here — so they never drift.
 */
/** The bindings a Lucid `rawQuery` accepts (mirrors `RawQueryBindings`). */
export type LucidQueryBindings = readonly unknown[] | Record<string, unknown>;
/** The slice of a Lucid query client the schema functions rely on. */
export interface LucidQueryClient {
    rawQuery(sql: string, bindings?: LucidQueryBindings): Promise<unknown>;
}
/** A Lucid `Database` / connection / query client. */
export interface LucidDatabase extends LucidQueryClient {
    dialect?: {
        name?: string;
    };
    connection?(name?: string): {
        dialect?: {
            name?: string;
        };
    };
}
/** Table-name override (default matches the `media` table). */
export interface MediaTableNames {
    media?: string;
}
/** The default table names for the Lucid store's media schema. */
export declare const MEDIA_TABLES: Required<MediaTableNames>;
/** Options the schema functions take. */
export interface MediaSchemaOptions {
    /** Table-name override (defaults to {@link MEDIA_TABLES}). */
    table?: string;
    /**
     * Database schema the table lives in (a Postgres schema, a MySQL database). Every statement
     * names it. Default: the connection's current schema.
     */
    schema?: string;
}
/** Reject any table name that is not a bare SQL identifier (these are interpolated, never bound). */
export declare function assertSafeIdentifier(id: string): string;
export declare function isPostgres(dialect: string | undefined): boolean;
export declare function isMysql(dialect: string | undefined): boolean;
/**
 * Validate a `schema` option: `undefined` passes through; anything else must be a plain identifier
 * (letters, digits, `_`, `$`, at most 63 characters) on a dialect that has schemas. SQLite fails.
 */
export declare function assertSchema(schema: string | undefined, dialect: string | undefined, where: string): string | undefined;
/**
 * A table name for Lucid's query builder: `schema.table` (knex quotes the two parts separately,
 * `"schema"."table"`), or the bare table without a schema.
 */
export declare function qualifiedTable(table: string, schema: string | undefined): string;
/**
 * Best-effort dialect name from a Lucid client; `undefined` when it can't be read.
 */
export declare function detectDialect(db: LucidDatabase): string | undefined;
/** The rows of a Lucid `rawQuery` result, whatever the driver returned. */
export declare function rowsOf(result: unknown): Record<string, unknown>[];
/** Whether `schema` exists, read from `information_schema` (Postgres and MySQL). */
export declare function mediaSchemaExists(db: LucidQueryClient, schema: string): Promise<boolean>;
/** What {@link inspectSchemaTables} reports for `agora:doctor`. */
export interface MediaSchemaInspection {
    schema: string;
    /** Whether the schema exists (and this connection can see it). */
    exists: boolean;
    /** The tables not found in the schema. */
    missingTables: string[];
    /** Why a no-op write failed, or `null` when it went through. */
    writeError: string | null;
}
/**
 * Whether `schema` exists, which of `tables` are missing from it, and whether this connection may
 * write to each one present (a no-op `INSERT … SELECT … WHERE 1 = 0` and `DELETE … WHERE 1 = 0`, which
 * change nothing but need the privileges).
 */
export declare function inspectSchemaTables(db: LucidQueryClient, schema: string, tables: readonly string[]): Promise<MediaSchemaInspection>;
/**
 * Create the `media` table (idempotent — `CREATE TABLE IF NOT EXISTS`). Safe to call
 * from a Lucid migration `up()` or repeatedly at boot.
 *
 * The shape mirrors the migration published by `node ace configure @adonis-agora/media`:
 * JSON payloads (`custom_properties`, `conversions`) are stored as TEXT — the store
 * (de)serializes them — and timestamps as epoch-ms integers, so the schema is portable
 * across SQLite / Postgres / MySQL. With `options.schema`, the schema is created when missing
 * and the table lives in it.
 *
 * @param db a Lucid `Database` or connection client
 * @param options.table optional table-name override (defaults to {@link MEDIA_TABLES})
 * @param options.schema optional database schema (a MySQL database)
 */
export declare function createMediaTables(db: LucidDatabase, options?: MediaSchemaOptions): Promise<void>;
/**
 * Drop the `media` table (idempotent — `DROP TABLE IF EXISTS`). For a migration `down()`.
 *
 * @param db a Lucid `Database` or connection client
 * @param options.table optional table-name override (defaults to {@link MEDIA_TABLES})
 * @param options.schema optional database schema (a MySQL database)
 */
export declare function dropMediaTables(db: LucidDatabase, options?: MediaSchemaOptions): Promise<void>;
/**
 * Whether the `media` table has the `tenant_id` column tenancy needs (a zero-row probe query).
 *
 * @param db a Lucid `Database` or connection client
 * @param options.table optional table-name override (defaults to {@link MEDIA_TABLES})
 * @param options.schema optional database schema (a MySQL database)
 */
export declare function hasMediaTenantColumn(db: LucidDatabase, options?: MediaSchemaOptions): Promise<boolean>;
/**
 * Characters of each column MySQL indexes in `<table>_tenant_owner_idx`. InnoDB caps a key at 3072
 * bytes; four utf8mb4 VARCHAR(255) columns are 4080. 4 × 191 × 4 = 3056 fits, and equality lookups
 * on values up to 191 characters still resolve in the index alone.
 */
export declare const TENANT_INDEX_MYSQL_PREFIX = 191;
/**
 * Add the nullable `tenant_id` column and its `(tenant_id, owner_type, owner_id, collection)` index
 * to the `media` table when missing (idempotent). Tenancy (organizations as tenants) stamps new
 * files with it; existing rows stay `NULL`. Same DDL as the migration
 * `node ace media:publish-migration tenancy` publishes.
 *
 * @param db a Lucid `Database` or connection client
 * @param options.table optional table-name override (defaults to {@link MEDIA_TABLES})
 * @param options.schema optional database schema (a MySQL database)
 */
export declare function ensureMediaTenantColumn(db: LucidDatabase, options?: MediaSchemaOptions): Promise<void>;
//# sourceMappingURL=lucid-schema.d.ts.map