Skip to content

fix: preserve custom database scripts#867

Merged
exKAZUu merged 1 commit into
mainfrom
fix/preserve-custom-db-scripts
Jun 10, 2026
Merged

fix: preserve custom database scripts#867
exKAZUu merged 1 commit into
mainfrom
fix/preserve-custom-db-scripts

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Jun 10, 2026

Copy link
Copy Markdown
Member

Customer Summary

  • Keeps repository-specific database migration wrappers intact when applying wbfy.
  • Prevents generated package scripts from dropping setup logic required by SQLite or multi-client database workflows.
  • No product behavior changes are introduced.

Technical Summary

  • Updated package script generation to preserve existing database scripts that are not already managed wb db or wb prisma commands.
  • Added a regression test for a Drizzle project with a custom migration wrapper.
  • Left standard generated wb database scripts in place for projects without custom scripts.

Why

  • Applying wbfy to moti-ai replaced its custom migration wrapper with a generic wb db migrate command.
  • The generic command did not create the SQLite database directory before Drizzle opened the file, causing CI setup to fail.

Testing

  • yarn vitest test/packageJson.test.ts
  • yarn verify
  • pre-commit cleanup hook
  • pre-push oxlint hook

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the package.json generator to preserve custom database scripts instead of unconditionally overwriting them with generated wb commands. A test has been added to verify this behavior. The reviewer pointed out that the regular expression used to identify generated scripts is too loose and could accidentally overwrite custom wrapper scripts, and provided a more precise regex suggestion.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1146 to 1148
function isGeneratedDatabaseScript(script: string): boolean {
return /\bwb\s+(?:db|prisma)\b/u.test(script);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current regular expression /�wb\s+(?:db|prisma)�/u is too loose. If a repository has a custom database script that wraps or chains a wb command (for example, node setup.js && wb db migrate or wb db migrate && node cleanup.js), it will be incorrectly identified as a generated script and overwritten.

To prevent overwriting these custom wrappers, make the regex match only the exact generated script formats (allowing for an optional bun --bun prefix).

Suggested change
function isGeneratedDatabaseScript(script: string): boolean {
return /\bwb\s+(?:db|prisma)\b/u.test(script);
}
function isGeneratedDatabaseScript(script: string): boolean {
return /^(?:bun\s+--bun\s+)?wb\s+(?:db|prisma)\s+(?:migrate-dev|migrate(?:\s+--check-idempotency)?|studio)$/u.test(script);
}

@exKAZUu exKAZUu enabled auto-merge (squash) June 10, 2026 03:59
@exKAZUu exKAZUu merged commit b9ca1bb into main Jun 10, 2026
7 checks passed
@exKAZUu exKAZUu deleted the fix/preserve-custom-db-scripts branch June 10, 2026 04:00
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.

1 participant