b4a1832a5c
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
20 lines
991 B
TypeScript
20 lines
991 B
TypeScript
import type { PrismaClient } from '@prisma/client';
|
|
|
|
/**
|
|
* FK-safe full reset for DB-backed specs. TRUNCATE … CASCADE clears every kernel
|
|
* table regardless of relation order, so specs don't each need to know the full
|
|
* delete order (which broke once Inbox added FK references to interaction/thread/actor).
|
|
*/
|
|
export async function resetDb(prisma: PrismaClient): Promise<void> {
|
|
await prisma.$executeRawUnsafe(
|
|
`TRUNCATE TABLE
|
|
"IiosInboundRawEvent","IiosDeliveryAttempt","IiosOutboundCommand","IiosRateLimitBucket",
|
|
"IiosTicketStateHistory","IiosTicketThreadLink","IiosCallbackRequest","IiosTicket",
|
|
"IiosSupportTeamMember","IiosSupportQueue",
|
|
"IiosInboxItemStateHistory","IiosInboxItem","IiosUnreadCounter","IiosMessageReceipt",
|
|
"IiosOutboxEvent","IiosProcessedEvent","IiosMessagePart","IiosInteraction",
|
|
"IiosThreadParticipant","IiosThread","IiosActorRef","IiosSourceHandle","IiosChannel","IiosScope"
|
|
RESTART IDENTITY CASCADE`,
|
|
);
|
|
}
|