fix: allow explicit litestream config for restore#879
Conversation
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
There was a problem hiding this comment.
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.
| 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`; | ||
| } |
There was a problem hiding this comment.
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.
| 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"`; | |
| } |
| 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`; | ||
| } |
There was a problem hiding this comment.
Wrap outputPath and the SQLite database path in double quotes to ensure the command is robust against spaces or special characters in paths.
| 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"`; | |
| } |
| function getLitestreamConfigOption(project: Project, configPath?: string): string { | ||
| if (configPath) return `-config "${configPath}"`; | ||
|
|
||
| const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME); |
There was a problem hiding this comment.
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.
| 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); |
| function getLitestreamConfigOption(project: Project, configPath?: string): string { | ||
| if (configPath) return `-config "${configPath}"`; | ||
|
|
||
| const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME); |
There was a problem hiding this comment.
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.
| 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); |
Customer Summary
wb.wb dboperational workflow.Technical Summary
--configtowb db list-backupsandwb db restore.Why
wb db list-backupsandwb db restoreexecute from the database package directory, so a config generated in the root or/tmpis not discovered automatically.--configlets operators generate sensitive config into/tmpand 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.tsyarn workspace @willbooster/wb typecheckyarn verify