Skip to content

fix: allow explicit litestream config for restore#879

Merged
exKAZUu merged 1 commit into
mainfrom
fix/wb-litestream-config-option
Jun 15, 2026
Merged

fix: allow explicit litestream config for restore#879
exKAZUu merged 1 commit into
mainfrom
fix/wb-litestream-config-option

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Jun 15, 2026

Copy link
Copy Markdown
Member

Customer Summary

  • Adds a way to pass a Litestream config file explicitly when listing backups or restoring a database with wb.
  • This avoids confusion in workspace repositories where the command runs inside a package but the config is generated elsewhere.
  • No app behavior changes; this only improves the wb db operational workflow.

Technical Summary

  • Adds --config to wb db list-backups and wb db restore.
  • Passes the explicit config path through both Prisma and Drizzle Litestream script generation.
  • Covers Drizzle command generation with tests for explicit config paths.

Why

  • In workspace repos, wb db list-backups and wb db restore execute from the database package directory, so a config generated in the root or /tmp is not discovered automatically.
  • Explicit --config lets operators generate sensitive config into /tmp and use it without writing secrets into a package directory.

Testing

  • yarn workspace @willbooster/wb exec vitest run test/scripts/drizzleScripts.test.ts test/prisma.test.ts
  • yarn workspace @willbooster/wb typecheck
  • yarn verify

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Jun 15, 2026

@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 adds support for specifying a custom Litestream configuration file path via a new --config option in the list-backups and restore commands for both Prisma and Drizzle. The feedback suggests improving robustness by wrapping database and output paths in double quotes within prismaScripts.ts to handle paths with spaces or special characters. Additionally, it is recommended to resolve the custom configuration path to an absolute path using path.resolve() in both script files to ensure correct path resolution in monorepo setups.

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 +48 to 51
listBackups(project: Project, configPath?: string): string {
const dirPath = getDatabaseDirPath(project);
return `litestream ltx ${getLitestreamConfigOption(project)} ${dirPath}/prod.sqlite3`;
return `litestream ltx ${getLitestreamConfigOption(project, configPath)} ${dirPath}/prod.sqlite3`;
}

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.

medium

To prevent issues with spaces or special characters in the database directory path, wrap the SQLite database path in double quotes, similar to how it is done in Drizzle scripts.

Suggested change
listBackups(project: Project, configPath?: string): string {
const dirPath = getDatabaseDirPath(project);
return `litestream ltx ${getLitestreamConfigOption(project)} ${dirPath}/prod.sqlite3`;
return `litestream ltx ${getLitestreamConfigOption(project, configPath)} ${dirPath}/prod.sqlite3`;
}
listBackups(project: Project, configPath?: string): string {
const dirPath = getDatabaseDirPath(project);
return `litestream ltx ${getLitestreamConfigOption(project, configPath)} "${dirPath}/prod.sqlite3"`;
}

Comment on lines +75 to 78
restore(project: Project, outputPath: string, configPath?: string): string {
const dirPath = getDatabaseDirPath(project);
return `rm -Rf ${outputPath}*; litestream restore ${getLitestreamConfigOption(project)} -o ${outputPath} ${dirPath}/prod.sqlite3`;
return `rm -Rf ${outputPath}*; litestream restore ${getLitestreamConfigOption(project, configPath)} -o ${outputPath} ${dirPath}/prod.sqlite3`;
}

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.

medium

Wrap outputPath and the SQLite database path in double quotes to ensure the command is robust against spaces or special characters in paths.

Suggested change
restore(project: Project, outputPath: string, configPath?: string): string {
const dirPath = getDatabaseDirPath(project);
return `rm -Rf ${outputPath}*; litestream restore ${getLitestreamConfigOption(project)} -o ${outputPath} ${dirPath}/prod.sqlite3`;
return `rm -Rf ${outputPath}*; litestream restore ${getLitestreamConfigOption(project, configPath)} -o ${outputPath} ${dirPath}/prod.sqlite3`;
}
restore(project: Project, outputPath: string, configPath?: string): string {
const dirPath = getDatabaseDirPath(project);
return `rm -Rf "${outputPath}"*; litestream restore ${getLitestreamConfigOption(project, configPath)} -o "${outputPath}" "${dirPath}/prod.sqlite3"`;
}

Comment on lines +116 to 119
function getLitestreamConfigOption(project: Project, configPath?: string): string {
if (configPath) return `-config "${configPath}"`;

const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME);

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.

medium

In a monorepo/workspace setup, the command is executed from the package directory (project.dirPath), but the user might specify a relative --config path from the workspace root (where they ran the command). Resolving configPath to an absolute path using path.resolve() ensures it is correctly located regardless of the execution directory.

Suggested change
function getLitestreamConfigOption(project: Project, configPath?: string): string {
if (configPath) return `-config "${configPath}"`;
const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME);
function getLitestreamConfigOption(project: Project, configPath?: string): string {
if (configPath) return `-config "${path.resolve(configPath)}"`;
const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME);

Comment on lines +118 to 121
function getLitestreamConfigOption(project: Project, configPath?: string): string {
if (configPath) return `-config "${configPath}"`;

const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME);

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.

medium

In a monorepo/workspace setup, the command is executed from the package directory (project.dirPath), but the user might specify a relative --config path from the workspace root (where they ran the command). Resolving configPath to an absolute path using path.resolve() ensures it is correctly located regardless of the execution directory.

Suggested change
function getLitestreamConfigOption(project: Project, configPath?: string): string {
if (configPath) return `-config "${configPath}"`;
const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME);
function getLitestreamConfigOption(project: Project, configPath?: string): string {
if (configPath) return `-config "${path.resolve(configPath)}"`;
const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME);

@exKAZUu exKAZUu merged commit 12a8779 into main Jun 15, 2026
7 checks passed
@exKAZUu exKAZUu deleted the fix/wb-litestream-config-option branch June 15, 2026 15:06
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