@dossierhq/sqlite-core
Version:
A library used by concrete SQLite adapters for Dossier.
16 lines (15 loc) • 1.07 kB
TypeScript
import { type ErrorType, type PromiseResult } from '@dossierhq/core';
import type { TransactionContext } from '@dossierhq/database-adapter';
import { type Database, type QueryOrQueryAndValues } from './QueryFunctions.js';
export interface SchemaVersionMigrationPlan {
temporarilyDisableForeignKeys: boolean;
queries: (QueryOrQueryAndValues | InteractiveMigrationQuery)[];
}
export type InteractiveMigrationQuery = (database: Database, context: TransactionContext) => PromiseResult<void, typeof ErrorType.Generic>;
export declare function getCurrentSchemaVersion(database: Database, context: TransactionContext): PromiseResult<number, typeof ErrorType.Generic>;
/** Migrates the database to the latest version.
*
* The latest version is determined by `schemaVersionGenerator` returning null. The migration of
* each version is run in a transaction.
*/
export declare function migrate(database: Database, context: TransactionContext, schemaVersionGenerator: (version: number) => SchemaVersionMigrationPlan | null): PromiseResult<void, typeof ErrorType.Generic>;