feat: show D1 storage capacity in admin (#1117)

* feat: show D1 storage usage in admin

* test: add D1 storage E2E coverage

* test: use exact D1 storage labels
This commit is contained in:
Dream Hunter
2026-08-19 16:16:54 +08:00
committed by GitHub
parent 2762741226
commit 108b8ef4ac
13 changed files with 468 additions and 5 deletions
+3 -1
View File
@@ -219,11 +219,13 @@ export default {
},
getVersion: async (c: Context<HonoCustomType>) => {
const version = await utils.getSetting(c, CONSTANTS.DB_VERSION_KEY);
const sizeResult = await c.env.DB.prepare("SELECT 1").run();
return c.json({
need_initialization: !version,
need_migration: version && version != CONSTANTS.DB_VERSION,
current_db_version: version,
code_db_version: CONSTANTS.DB_VERSION
code_db_version: CONSTANTS.DB_VERSION,
database_size: sizeResult.meta.size_after ?? null
});
},
}