chore (backend): remove a horrible and unused function
This commit is contained in:
parent
4b7724ed1f
commit
c6e2776298
1 changed files with 0 additions and 28 deletions
|
@ -237,31 +237,3 @@ export async function initDb(force = false) {
|
||||||
await db.initialize();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue