Skip to content

Conversation

@exKAZUu
Copy link
Member

@exKAZUu exKAZUu commented Dec 16, 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 16, 2025 04:23
@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 utility to offer a more comprehensive and reliable database reset process. The primary enhancement involves the addition of a pre-reset cleanup mechanism specifically targeting SQLite databases, which ensures that all related database files are removed before the Prisma migration reset proceeds. This change improves the consistency and effectiveness of database resets across various project setups.

Highlights

  • Improved Prisma Reset Command: The prisma reset command has been enhanced to include a pre-reset cleanup step, ensuring a more thorough database reset, especially for SQLite databases.
  • SQLite Database Cleanup: A new utility function, cleanUpSqliteDbIfNeeded, was introduced to intelligently identify and remove SQLite database files, including their associated WAL and SHM files, based on the DATABASE_URL.
  • Refactored Command Construction: The logic for constructing the reset command was refactored to use a sequence of steps, allowing for greater flexibility and the integration of pre-reset actions.
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 resetコマンドの改善を目的としています。主な変更点は、SQLiteデータベースの場合にリセット前にデータベースファイルをクリーンアップする機能の追加と、それに伴うresetメソッドのリファクタリングです。全体的に、コマンドの堅牢性を高める良い変更だと思います。リポジトリのスタイルガイドに従い、レビューは日本語で行っています。コードの重複を減らし、可読性を向上させるための提案をいくつかさせていただきます。

Comment on lines 110 to 124
const FILE_SCHEMA = 'file:';
const dbUrl = project.env.DATABASE_URL;
if (!dbUrl?.startsWith(FILE_SCHEMA)) return;

const rawDbPath = dbUrl.slice(FILE_SCHEMA.length).replace(/[?#].*$/, '');
if (!rawDbPath) return;

const POSSIBLE_PATHS = [
{ schemaPath: path.join('prisma', 'schema.prisma'), dbPath: 'prisma' },
{ schemaPath: path.join('prisma', 'schema'), dbPath: path.join('prisma', 'schema') },
{ schemaPath: path.join('db', 'schema.prisma'), dbPath: 'db' },
];
const baseDir = POSSIBLE_PATHS.find(({ schemaPath }) =>
fs.existsSync(path.resolve(project.dirPath, schemaPath))
)?.dbPath;

Choose a reason for hiding this comment

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

medium

FILE_SCHEMA定数とPOSSIBLE_PATHS定数、およびbaseDirを見つけるロジックが、72行目と84-99行目のstudioメソッド内にも存在しており、コードが重複しています。コードの重複は将来のメンテナンス性を低下させる可能性があります。これらの定数とロジックをファイルスコープの定数やヘルパー関数として抽出し、両方の場所から再利用することを検討してください。

例えば、以下のようなヘルパー関数を定義できます。

const FILE_SCHEMA = 'file:';

const POSSIBLE_PRISMA_PATHS = [
  { schemaPath: path.join('prisma', 'schema.prisma'), dbPath: 'prisma' },
  { schemaPath: path.join('prisma', 'schema'), dbPath: path.join('prisma', 'schema') },
  { schemaPath: path.join('db', 'schema.prisma'), dbPath: 'db' },
];

function getPrismaBaseDir(project: Project): string | undefined {
  return POSSIBLE_PRISMA_PATHS.find(({ schemaPath }) =>
    fs.existsSync(path.resolve(project.dirPath, schemaPath))
  )?.dbPath;
}

これにより、cleanUpSqliteDbIfNeededstudioの両方のメソッドがシンプルになり、一貫性が保たれます。

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 the Prisma reset command by adding automatic cleanup of SQLite database files before running the reset. The change addresses potential issues where stale WAL (Write-Ahead Logging) and SHM (Shared Memory) files could interfere with the database reset process.

Key Changes:

  • Refactored the reset method to build commands using an array-based approach with conditional steps
  • Added a new cleanUpSqliteDbIfNeeded utility function that generates shell commands to remove SQLite database files and their associated WAL/SHM files before reset
  • The cleanup is only performed for SQLite databases (detected via file: protocol in DATABASE_URL)

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

…aScripts

- Remove if/else redundancy by moving resetCommand push outside conditional
- Extract FILE_SCHEMA and POSSIBLE_PRISMA_PATHS as file-level constants
- Add getPrismaBaseDir helper function to eliminate code duplication
- Simplify studio and cleanUpSqliteDbIfNeeded methods

Co-authored-by: WillBooster (Claude Code) <[email protected]>
@exKAZUu exKAZUu merged commit 4d2da99 into main Dec 16, 2025
7 checks passed
@exKAZUu exKAZUu deleted the reset branch December 16, 2025 23:54
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