add size audit db

This commit is contained in:
Ean Milligan
2026-04-07 03:51:06 -04:00
parent 90d578e662
commit 8f98899d6d

View File

@@ -8,6 +8,7 @@ await dbClient.execute(`USE ${config.db.name}`);
console.log('DB created');
console.log('Attempt to drop all tables');
await dbClient.execute(`DROP VIEW IF EXISTS db_size;`);
await dbClient.execute(`DROP TABLE IF EXISTS plans;`);
await dbClient.execute(`DROP TABLE IF EXISTS users;`);
console.log('Tables dropped');
@@ -42,5 +43,19 @@ await dbClient.execute(`
`);
console.log('Table created');
console.log('Attempting to create view db_size');
await dbClient.execute(`
CREATE VIEW db_size AS
SELECT
table_name AS "table",
ROUND(((data_length + index_length) / 1024 / 1024), 3) AS "size",
table_rows AS "rows"
FROM information_schema.TABLES
WHERE
table_schema = "${config.db.name}"
AND table_name <> "db_size";
`);
console.log('View Created');
await dbClient.close();
console.log('Done!');