-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteardown.ts
More file actions
52 lines (47 loc) · 1.35 KB
/
teardown.ts
File metadata and controls
52 lines (47 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { prisma } from '@/lib/prisma';
/**
* Teardown script to clean the database
* Truncates all tables and restarts identity sequences
*/
async function main() {
console.log('Starting database teardown...\n');
try {
console.log('Truncating all tables...');
await prisma.$executeRaw`
TRUNCATE TABLE
"Comment",
"Review",
"Task",
"Assessment",
"TaskTemplate",
"AssessmentTemplate",
"Application",
"Candidate",
"Position",
"PositionTag",
"TaskTemplateTag",
"Member",
"Invitation",
"Session",
"Account",
"Verification",
"User",
"Organization",
RESTART IDENTITY CASCADE;
`;
console.log('All tables truncated successfully');
console.log('Identity sequences restarted');
console.log('\nDatabase teardown completed successfully!');
} catch (error) {
console.error('\nTeardown failed:', error);
throw error;
}
}
main()
.catch((e) => {
console.error('Teardown failed:', e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});