File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -120,13 +120,18 @@ export async function cleanupDb(prisma: PrismaClient) {
120
120
{ name : string } [ ]
121
121
> `SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_prisma_migrations';`
122
122
123
- await prisma . $transaction ( [
123
+ try {
124
124
// Disable FK constraints to avoid relation conflicts during deletion
125
- prisma . $executeRawUnsafe ( `PRAGMA foreign_keys = OFF` ) ,
126
- // Delete all rows from each table, preserving table structures
127
- ...tables . map ( ( { name } ) =>
128
- prisma . $executeRawUnsafe ( `DELETE from "${ name } "` ) ,
129
- ) ,
130
- prisma . $executeRawUnsafe ( `PRAGMA foreign_keys = ON` ) ,
131
- ] )
125
+ await prisma . $executeRawUnsafe ( `PRAGMA foreign_keys = OFF` )
126
+ await prisma . $transaction ( [
127
+ // Delete all rows from each table, preserving table structures
128
+ ...tables . map ( ( { name } ) =>
129
+ prisma . $executeRawUnsafe ( `DELETE from "${ name } "` ) ,
130
+ ) ,
131
+ ] )
132
+ } catch ( error ) {
133
+ console . error ( 'Error cleaning up database:' , error )
134
+ } finally {
135
+ await prisma . $executeRawUnsafe ( `PRAGMA foreign_keys = ON` )
136
+ }
132
137
}
You can’t perform that action at this time.
0 commit comments