mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-18 17:12:53 +03:00
19 lines
505 B
TypeScript
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();
|
||
|
}),
|
||
|
);
|
||
|
};
|