Format and style

Format SQL query in clean database, run npm run format
This commit is contained in:
Aaron William Po
2023-05-08 00:04:01 -04:00
parent 301a2bb247
commit 90a7cf8d56
4 changed files with 17 additions and 14 deletions

View File

@@ -10,16 +10,17 @@ const cleanDatabase = async () => {
* schema then loops through each table and truncates it.
*/
await prisma.$executeRaw`
DO $$
DECLARE
statements CURSOR FOR
DO $$
DECLARE
statements CURSOR FOR
SELECT tablename FROM pg_tables
WHERE schemaname = 'public';
BEGIN
FOR statement IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(statement.tablename) || ' CASCADE;';
END LOOP;
END;
WHERE schemaname = 'public'
AND tablename != '_prisma_migrations';
BEGIN
FOR statement IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(statement.tablename) || ' CASCADE;';
END LOOP;
END;
$$ LANGUAGE plpgsql;
`;