Build, Test, and Push CFDM Docker Image / test (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / create-release (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been cancelled
39 lines
953 B
JavaScript
39 lines
953 B
JavaScript
import Database from "better-sqlite3";
|
|
import { existsSync } from "node:fs";
|
|
|
|
const path = process.argv[2] ?? "../../data/app.db";
|
|
if (!existsSync(path)) {
|
|
console.log("missing:", path);
|
|
process.exit(1);
|
|
}
|
|
|
|
const db = new Database(path, { readonly: true });
|
|
const tables = db
|
|
.prepare("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")
|
|
.all()
|
|
.map((t) => t.name);
|
|
console.log("path:", path);
|
|
console.log("tables:", tables.join(", "));
|
|
for (const t of [
|
|
"domains",
|
|
"groups",
|
|
"dns_records",
|
|
"services",
|
|
"_migrations",
|
|
]) {
|
|
if (!tables.includes(t)) continue;
|
|
console.log(t, db.prepare(`SELECT COUNT(*) as c FROM ${t}`).get().c);
|
|
}
|
|
if (tables.includes("domains")) {
|
|
console.log(
|
|
"sample:",
|
|
db.prepare("SELECT id, zone_name FROM domains LIMIT 5").all(),
|
|
);
|
|
}
|
|
if (tables.includes("_migrations")) {
|
|
console.log(
|
|
"migrations:",
|
|
db.prepare("SELECT name FROM _migrations ORDER BY name").all(),
|
|
);
|
|
}
|