chore (backend): remove a horrible and unused function

This commit is contained in:
naskya 2024-04-19 03:42:49 +09:00
parent 4b7724ed1f
commit c6e2776298
No known key found for this signature in database
GPG Key ID: 712D413B3A9FED5C
1 changed files with 0 additions and 28 deletions

View File

@ -237,31 +237,3 @@ export async function initDb(force = false) {
await db.initialize();
}
}
export async function resetDb() {
const reset = async () => {
await redisClient.flushdb();
const tables = await db.query(`SELECT relname AS "table"
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind = 'r'
AND nspname !~ '^pg_toast';`);
for (const table of tables) {
await db.query(`DELETE FROM "${table.table}" CASCADE`);
}
};
for (let i = 1; i <= 3; i++) {
try {
await reset();
} catch (e) {
if (i === 3) {
throw e;
} else {
await new Promise((resolve) => setTimeout(resolve, 1000));
continue;
}
}
break;
}
}