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:
@@ -1,11 +1,9 @@
|
||||
import { Command } from "commander";
|
||||
import init from "../functions/init";
|
||||
import path from "path";
|
||||
import grabDBDir from "../utils/grab-db-dir";
|
||||
import grabDBBackupFileName from "../utils/grab-db-backup-file-name";
|
||||
import chalk from "chalk";
|
||||
import trimBackups from "../utils/trim-backups";
|
||||
import DbClient from "../lib/sqlite";
|
||||
import snapshotDb from "../utils/snapshot-db";
|
||||
|
||||
export default function () {
|
||||
@@ -14,14 +12,14 @@ export default function () {
|
||||
.action(async (opts) => {
|
||||
console.log(`Backing up database ...`);
|
||||
|
||||
const { config } = await init();
|
||||
const config = global.CONFIG;
|
||||
|
||||
const { backup_dir } = grabDBDir({ config });
|
||||
|
||||
const new_db_file_name = grabDBBackupFileName({ config });
|
||||
|
||||
snapshotDb({
|
||||
db: DbClient,
|
||||
db: global.SQLITE_CLIENT,
|
||||
dst: path.join(backup_dir, new_db_file_name),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user