Let a super admin read the database from the app

A new super admin settings page, /admin/settings/database, lists every
table with its record count and size, and one page of the open table's
records newest key first. Values are cut inside SQL (400 characters, with
a flag saying so) and a record opens whole in a modal, so a table of long
texts reads without shipping it all. A search matches every column's
text, word by word or as a phrase, which is the one thing that also works
on a virtual table. Nothing in it writes: the catalog, the records and
the single record are all reads, GET only.
This commit is contained in:
2026-10-23 06:03:42 +01:00
parent 9b26c169d6
commit 41bb4aaac2
48 changed files with 2573 additions and 0 deletions
@@ -0,0 +1,41 @@
import { describe, expect, test } from "bun:test";
import { renderToString } from "react-dom/server";
import type { DatabaseTableSummary } from "@/src/types";
import DatabaseTableRow from "./database-table-row";
const table: DatabaseTableSummary = {
name: "bot_file_vectors",
type: "virtual",
rows: 12,
size_bytes: 2048,
columns: [],
key: { kind: "none" },
};
describe("DatabaseTableRow", () => {
test("names the table, its record count and its size", () => {
const html = renderToString(<DatabaseTableRow table={table} selected={false} onOpen={() => {}} />);
expect(html).toContain("bot_file_vectors");
expect(html).toContain("12");
expect(html).toContain("2.0 KB");
});
test("links to the table's own address", () => {
const html = renderToString(<DatabaseTableRow table={table} selected={false} onOpen={() => {}} />);
expect(html).toContain(`href="/admin/settings/database?table=bot_file_vectors"`);
});
test("a table with no count yet shows a dash", () => {
const html = renderToString(
<DatabaseTableRow
table={{ ...table, rows: null, size_bytes: null }}
selected={false}
onOpen={() => {}}
/>,
);
expect(html).toContain("-");
});
});