twenty/server/test/utils/reset-db.ts
Jérémy M 157e5b9a2e
feat: implement e2e test for CompanyResolver (#944)
* feat: wip e2e server test

* feat: use github action postgres & use infra for local

* feat: company e2e test

* feat: add company e2e test for permissions

* Simplify server e2e test run

* Fix lint

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-07-27 09:48:40 -07:00

19 lines
505 B
TypeScript

import { PrismaClient, Prisma } from '@prisma/client';
import { camelCase } from 'src/utils/camel-case';
const prisma = new PrismaClient();
export default async () => {
const models = Prisma.dmmf.datamodel.models;
const modelNames = models.map((model) => model.name);
const entities = modelNames.map((modelName) => camelCase(modelName));
await prisma.$transaction(
entities.map((entity) => {
console.log('entity: ', entity);
return prisma[entity].deleteMany();
}),
);
};