openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
22 lines (21 loc) • 1.12 kB
JavaScript
import { t as openNodeSqliteDatabase } from "./node-sqlite-DWTcT2ek.mjs";
import { D as resolveDatabasePath, s as detectOpenClawStateDatabaseSchemaMigrationsFromDatabase } from "./openclaw-state-db-existing-schema-CUJtAJx4.mjs";
import { l as withExistingOpenClawStateDatabaseArtifactPreservingReadOnly } from "./openclaw-state-db-readonly-BLZyK3So.mjs";
import { existsSync } from "node:fs";
//#region src/state/openclaw-state-db-schema-discovery.ts
function detectOpenClawStateDatabaseSchemaMigrations(options = {}, behavior = {}) {
const pathname = resolveDatabasePath(options);
if (!existsSync(pathname)) return [];
if (behavior.artifactPreservingReadOnly) return withExistingOpenClawStateDatabaseArtifactPreservingReadOnly(({ db }) => detectOpenClawStateDatabaseSchemaMigrationsFromDatabase(db, pathname), {
...options,
path: pathname
}) ?? [];
const db = openNodeSqliteDatabase(pathname, { readOnly: true });
try {
return detectOpenClawStateDatabaseSchemaMigrationsFromDatabase(db, pathname);
} finally {
db.close();
}
}
//#endregion
export { detectOpenClawStateDatabaseSchemaMigrations as t };