-
Notifications
You must be signed in to change notification settings - Fork 0
fix: improve prisma scripts #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -137,6 +137,13 @@ const resetCommand: CommandModule<unknown, InferredOptionTypes<typeof builder>> | |||||||||||||
| for (const project of prepareForRunningCommand('prisma reset', allProjects)) { | ||||||||||||||
| await runWithSpawn(prismaScripts.reset(project, unknownOptions), project, argv); | ||||||||||||||
| } | ||||||||||||||
| // Force to reset test database | ||||||||||||||
| if (process.env.WB_ENV !== 'test') { | ||||||||||||||
| process.env.WB_ENV = 'test'; | ||||||||||||||
| for (const project of prepareForRunningCommand('WB_ENV=test prisma reset', await findPrismaProjects(argv))) { | ||||||||||||||
| await runWithSpawn(prismaScripts.reset(project, unknownOptions), project, argv); | ||||||||||||||
|
Comment on lines
+142
to
+144
|
||||||||||||||
| process.env.WB_ENV = 'test'; | |
| for (const project of prepareForRunningCommand('WB_ENV=test prisma reset', await findPrismaProjects(argv))) { | |
| await runWithSpawn(prismaScripts.reset(project, unknownOptions), project, argv); | |
| const testEnv = { ...process.env, WB_ENV: 'test' }; | |
| for (const project of prepareForRunningCommand('WB_ENV=test prisma reset', await findPrismaProjects(argv))) { | |
| await runWithSpawn(prismaScripts.reset(project, unknownOptions), project, argv, { env: testEnv }); |
exKAZUu marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,8 +23,9 @@ class PrismaScripts { | |||||
|
|
||||||
| deployForce(project: Project): string { | ||||||
| const dirPath = getDatabaseDirPath(project); | ||||||
| // `prisma migrate reset` sometimes fails if the existing database schema, so we remove it first. | ||||||
|
||||||
| // `prisma migrate reset` sometimes fails if the existing database schema, so we remove it first. | |
| // `prisma migrate reset` sometimes fails if the existing database schema exists, so we remove it first. |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the security concern in the removeSqliteArtifacts method, using rm -Rf ${dirPath}/prod.sqlite3* with a wildcard could be dangerous if dirPath is empty or misconfigured. While getDatabaseDirPath returns fixed paths, consider adding validation or using more explicit file patterns to prevent accidental deletion of unintended files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
await findPrismaProjects(argv)again inside the handler after already calling it at line 135 introduces redundant work. The function performs file system operations to find projects, which is unnecessary since the projects list is already available inallProjects. Consider reusing theallProjectsvariable instead of callingfindPrismaProjectsagain.