Port bun-mariadb conventions: init globals, db handler, split schema sync

- init() loads config, schema and the SQLite client once into globals
- all CRUD queries go through lib/db-handler.ts (optional per-call config)
- split db-schema-manager.ts into lib/schema/* with FK-aware table ordering
- add bun:test tests for schema ordering, FK constraints and schema sync
- config/schema files can be .ts/.js/.json/.yaml/.yml; db_schema_file_name
  is now optional (defaults to schema.* in db_dir)
- add export/import commands (database snapshot + schema archives)
- package exports map, type re-exports, hardened publish.sh
- validate table name in delete

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 02:37:35 +01:00
co-authored by Claude Opus 5.5
parent 66f73c4228
commit 87da436f81
54 changed files with 2385 additions and 857 deletions
+6 -1
View File
@@ -1,6 +1,11 @@
export const AppData = {
ConfigFileName: "bun-sqlite.config.ts",
ConfigFileName: "bun-sqlite.config",
MaxBackups: 10,
MaxExports: 10,
DefaultBackupDirName: ".backups",
DefaultExportDirName: ".exports",
DbSchemaManagerTableName: "__db_schema_manager__",
DbSchemaFileName: "schema",
/** Priority order when resolving config/schema files */
SupportedDataFileExtensions: [".ts", ".js", ".json", ".yaml", ".yml"] as const,
} as const;