Document typedefs better. Fix tables deletion schema sync issue.

This commit is contained in:
2026-04-05 09:03:47 +01:00
parent 01b96d788e
commit 259a684136
14 changed files with 869 additions and 104 deletions
+7
View File
@@ -0,0 +1,7 @@
import type { BUN_SQLITE_DatabaseSchemaType } from "../types";
type Params = {
schema: BUN_SQLITE_DatabaseSchemaType;
};
export declare function writeLiveSchema({ schema }: Params): void;
export declare function readLiveSchema(): BUN_SQLITE_DatabaseSchemaType | undefined;
export {};
+15
View File
@@ -0,0 +1,15 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
import grabDirNames from "../data/grab-dir-names";
import path from "path";
const { BUN_SQLITE_LIVE_SCHEMA } = grabDirNames();
export function writeLiveSchema({ schema }) {
mkdirSync(path.dirname(BUN_SQLITE_LIVE_SCHEMA), { recursive: true });
writeFileSync(BUN_SQLITE_LIVE_SCHEMA, JSON.stringify(schema));
}
export function readLiveSchema() {
if (!existsSync(BUN_SQLITE_LIVE_SCHEMA)) {
return undefined;
}
const live_schema = readFileSync(BUN_SQLITE_LIVE_SCHEMA, "utf-8");
return JSON.parse(live_schema);
}