Skip to content

Conversation

@exKAZUu
Copy link
Member

@exKAZUu exKAZUu commented Dec 9, 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.

exKAZUu and others added 4 commits December 9, 2025 16:50
Copilot AI review requested due to automatic review settings December 9, 2025 08:15
@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 refines the prisma reset command within the prismaScripts.ts utility to consistently remove test database files. The change ensures that development and testing environments are properly cleaned up, preventing the persistence of stale test data across database resets and streamlining the development workflow.

Highlights

  • Enhanced Prisma Reset Command: The prisma reset command has been updated to include an additional step that explicitly removes test database files, ensuring a cleaner state after a reset.
  • Targeted Test Database Removal: The modification specifically targets and deletes files named test.db* or test.sqlite*.
  • Conditional Directory Cleanup: The directory where test database files are searched for (db or prisma) is now conditionally determined based on whether the project utilizes Blitz.js.
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.

@exKAZUu exKAZUu enabled auto-merge (squash) December 9, 2025 08:16
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 reset コマンドが常にテストデータベースを削除するように変更するものです。変更は packages/wb/src/scripts/prismaScripts.tsreset メソッドに適用されています。主な変更点は、blitz プロジェクトかどうかによって db または prisma ディレクトリ内のテストデータベース (test.db* または test.sqlite*) を削除するコマンドを追加することです。コードは全体的に良好ですが、可読性と保守性を向上させるために、blitz プロジェクトであるかどうかのチェックを一度だけ行い、その結果を再利用することを提案します。

Comment on lines 42 to 48
const resetOptions = additionalOptions.trim();
const baseReset = `PRISMA migrate reset --force${resetOptions ? ` ${resetOptions}` : ''}`;
const resetCommand = project.packageJson.dependencies?.blitz ? `${baseReset} && ${this.seed(project)}` : baseReset;
const resetCommandForTest = project.packageJson.dependencies?.blitz
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${resetCommandForTest}`;

Choose a reason for hiding this comment

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

medium

可読性と保守性を向上させるため、project.packageJson.dependencies?.blitz の評価を一度だけ行い、その結果を定数に格納して再利用することをお勧めします。また、db または prisma のディレクトリ名も定数に格納すると、コードがよりクリーンになります。

Suggested change
const resetOptions = additionalOptions.trim();
const baseReset = `PRISMA migrate reset --force${resetOptions ? ` ${resetOptions}` : ''}`;
const resetCommand = project.packageJson.dependencies?.blitz ? `${baseReset} && ${this.seed(project)}` : baseReset;
const resetCommandForTest = project.packageJson.dependencies?.blitz
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${resetCommandForTest}`;
const isBlitz = !!project.packageJson.dependencies?.blitz;
const resetOptions = additionalOptions.trim();
const baseReset = `PRISMA migrate reset --force${resetOptions ? ` ${resetOptions}` : ''}`;
const resetCommand = isBlitz ? `${baseReset} && ${this.seed(project)}` : baseReset;
const dirName = isBlitz ? 'db' : 'prisma';
const resetCommandForTest = String.raw`find ${dirName} \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${resetCommandForTest}`;

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 enhances the prisma reset command to automatically remove test database files (test.db* and test.sqlite*) after performing a database reset. The implementation differentiates between Blitz.js projects (which store databases in the db directory) and standard Prisma projects (which use the prisma directory).

Key Changes:

  • Refactored the reset method to improve code organization by extracting common logic
  • Added automatic cleanup of test database files using Unix find command
  • Maintained backward compatibility with both Blitz.js and non-Blitz projects

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

Comment on lines 40 to +48
reset(project: Project, additionalOptions = ''): string {
// cf. https://www.prisma.io/docs/guides/database/seed-database#integrated-seeding-with-prisma-migrate
if (project.packageJson.dependencies?.blitz) {
// Blitz does not trigger seed automatically, so we need to run it manually.
return `PRISMA migrate reset --force ${additionalOptions} && ${this.seed(project)}`;
}
return `PRISMA migrate reset --force ${additionalOptions}`;
const resetOptions = additionalOptions.trim();
const baseReset = `PRISMA migrate reset --force ${resetOptions}`;
const resetCommand = project.packageJson.dependencies?.blitz ? `${baseReset} && ${this.seed(project)}` : baseReset;
const resetCommandForTest = project.packageJson.dependencies?.blitz
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${resetCommandForTest}`;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The behavior change should be tested to ensure that test database files are properly removed after a reset operation. Currently, there are no tests for the reset method or the prismaScripts module. Consider adding a test that:

  1. Creates mock test database files (e.g., test.db, test.sqlite)
  2. Calls the reset method
  3. Verifies that the generated command includes the correct find command for removing test databases
  4. Optionally, executes the command and verifies the files are removed

This is especially important since this is a new feature that changes the behavior of the reset command.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +48
const resetCommandForTest = project.packageJson.dependencies?.blitz
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${resetCommandForTest}`;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable name resetCommandForTest is misleading. It suggests this is a command for running tests, but it's actually a command to delete test database files. Consider renaming to something more descriptive like:

  • deleteTestDbCommand
  • cleanupTestDbCommand
  • removeTestDbCommand

This would make the code's intent clearer to future maintainers.

Suggested change
const resetCommandForTest = project.packageJson.dependencies?.blitz
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${resetCommandForTest}`;
const deleteTestDbCommand = project.packageJson.dependencies?.blitz
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
return `${resetCommand} && ${deleteTestDbCommand}`;

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +47
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The find command will fail if the directory doesn't exist. When resetCommandForTest runs and the prisma directory doesn't exist (e.g., in a fresh project or after a clean), the command will return a non-zero exit code, causing the entire reset operation to fail.

Consider using the -maxdepth 1 flag or checking if the directory exists first:

const resetCommandForTest = project.packageJson.dependencies?.blitz
  ? String.raw`find db -maxdepth 1 \( -name "test.db*" -o -name "test.sqlite*" \) -delete 2>/dev/null || true`
  : String.raw`find prisma -maxdepth 1 \( -name "test.db*" -o -name "test.sqlite*" \) -delete 2>/dev/null || true`;

The 2>/dev/null || true ensures the command succeeds even if the directory doesn't exist or no files are found.

Suggested change
? String.raw`find db \( -name "test.db*" -o -name "test.sqlite*" \) -delete`
: String.raw`find prisma \( -name "test.db*" -o -name "test.sqlite*" \) -delete`;
? String.raw`find db -maxdepth 1 \( -name "test.db*" -o -name "test.sqlite*" \) -delete 2>/dev/null || true`
: String.raw`find prisma -maxdepth 1 \( -name "test.db*" -o -name "test.sqlite*" \) -delete 2>/dev/null || true`;

Copilot uses AI. Check for mistakes.
@exKAZUu exKAZUu merged commit bf88920 into main Dec 9, 2025
7 checks passed
@exKAZUu exKAZUu deleted the reset branch December 9, 2025 08:19
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