Skip to content

Conversation

@exKAZUu
Copy link
Member

@exKAZUu exKAZUu commented Dec 12, 2025

Close #

Self Check

  • I've confirmed All checks have passed on this page.
    • PR title follows Angular's commit message format.
    • PR title doesn't have WIP:.
    • The test command (e.g., yarn test) passed.
    • The lint command (e.g., yarn lint) passed.
    • You may leave this box unchecked due to long workflows.
  • I've reviewed my changes on the GitHub diff view.
  • I've written the steps to test my changes.
  • I've added screenshots (if the UI changed).
    • You may leave this box unchecked if you didn't modify the UI.

Copilot AI review requested due to automatic review settings December 12, 2025 04:58
@gemini-code-assist
Copy link

Summary of Changes

Hello @exKAZUu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the reliability and robustness of Prisma-related utility scripts. The changes streamline database reset and deployment processes, particularly by ensuring consistent test database environments, preventing prisma migrate reset failures during forced deployments, and simplifying the overall script logic for better maintainability and predictability.

Highlights

  • Enhanced Test Database Reset: The prisma reset command now includes logic to explicitly force a reset of the test database environment (WB_ENV=test) after a standard reset, ensuring consistency across different environments.
  • Robust deployForce Command: The deployForce script has been improved to pre-emptively remove existing prod.sqlite3* database files before executing prisma migrate reset. This change addresses potential failures that could occur if prisma migrate reset encounters an incompatible existing database schema.
  • Simplified reset Script Logic: The reset script in prismaScripts.ts has been refactored. It now directly integrates the seeding process for Blitz projects, acknowledging that Blitz does not automatically trigger seeding. The previous complex logic for deleting test database files has been removed for a cleaner implementation.
  • Generalized SQLite Artifact Cleanup: The removeSqliteArtifacts utility function has been simplified to use a wildcard (*) when deleting SQLite-related files. This ensures more comprehensive removal of associated files like WAL, SHM, and Litestream sidecar files, reducing the chance of leftover artifacts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

このプルリクエストは、Prisma関連のスクリプトを改善するものです。主な変更点は、テストデータベースのリセットを強制的に行う処理の追加、deploy-forceコマンドの簡略化、resetコマンドのリファクタリング、そしてSQLiteのアーティファクト削除処理の単純化です。

全体的に良い改善ですが、いくつかフィードバックがあります。process.envの変更による副作用の可能性と、冗長なコマンドの削除についてコメントしました。ご確認ください。

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Prisma database management scripts by refactoring the reset command logic, simplifying file cleanup operations, and adding automatic test database reset functionality.

Key Changes:

  • Simplified the reset method by removing test database cleanup logic (now handled separately)
  • Added proactive database removal in deployForce to prevent migration reset failures
  • Introduced automatic test database reset after main database reset in the reset command handler

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/wb/src/scripts/prismaScripts.ts Refactored deployForce to remove database before reset, simplified reset method logic by removing test database cleanup, and simplified removeSqliteArtifacts to use wildcard pattern
packages/wb/src/commands/prisma.ts Added automatic test database reset logic when WB_ENV is not 'test' to ensure both production and test databases are reset together
Comments suppressed due to low confidence (1)

packages/wb/src/scripts/prismaScripts.ts:122

  • The use of rm -Rf ${sqlitePath}* with a wildcard is potentially dangerous. If sqlitePath is empty or evaluates to a short path, this could delete unintended files. Consider using more specific removal like the previous implementation that explicitly listed the files to remove (${sqlitePath}, ${sqlitePath}-shm, ${sqlitePath}-wal, ${sqlitePath}-litestream). Alternatively, add validation to ensure sqlitePath is not empty before executing the command.
  return project.packageJson.dependencies?.blitz ? 'db/mount' : 'prisma/mount';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// `prisma migrate reset` sometimes fails if the existing database schema, so we remove it first.
// Don't skip "migrate deploy" because restored database may be older than the current schema.
return `PRISMA migrate reset --force --skip-seed && rm -Rf ${dirPath}/prod.sqlite3*
return `rm -Rf ${dirPath}/prod.sqlite3*; PRISMA migrate reset --force --skip-seed && rm -Rf ${dirPath}/prod.sqlite3*
Copy link

Copilot AI Dec 12, 2025

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.

Copilot uses AI. Check for mistakes.
// 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))) {
Copy link

Copilot AI Dec 12, 2025

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 in allProjects. Consider reusing the allProjects variable instead of calling findPrismaProjects again.

Suggested change
for (const project of prepareForRunningCommand('WB_ENV=test prisma reset', await findPrismaProjects(argv))) {
for (const project of prepareForRunningCommand('WB_ENV=test prisma reset', allProjects)) {

Copilot uses AI. Check for mistakes.

deployForce(project: Project): string {
const dirPath = getDatabaseDirPath(project);
// `prisma migrate reset` sometimes fails if the existing database schema, so we remove it first.
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has a grammatical error. It should read "if the existing database schema exists" or "with the existing database schema".

Suggested change
// `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 uses AI. Check for mistakes.
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);
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutating process.env.WB_ENV at runtime in a command handler has potential side effects that could affect other parts of the application. This creates a stateful change that persists beyond this command execution. Consider using environment variable passing through the command execution instead of mutating the global process.env object, or document this side effect clearly if it's intentional.

Suggested change
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 });

Copilot uses AI. Check for mistakes.
@exKAZUu exKAZUu merged commit dc5cb75 into main Dec 12, 2025
7 checks passed
@exKAZUu exKAZUu deleted the prisma branch December 12, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants