-
Notifications
You must be signed in to change notification settings - Fork 0
fix: allow explicit litestream config for restore #879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,9 +45,9 @@ class PrismaScripts { | |||||||||||||||||||
| && litestream restore ${litestreamConfigOption} -o ${dirPath}/prod.sqlite3 ${dirPath}/prod.sqlite3 && ls -ahl ${dirPath}/prod.sqlite3 && ALLOW_TO_SKIP_SEED=0 PRISMA migrate deploy`; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| listBackups(project: Project): string { | ||||||||||||||||||||
| 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`; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+48
to
51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| migrate(project: Project, additionalOptions = ''): string { | ||||||||||||||||||||
|
|
@@ -72,9 +72,9 @@ class PrismaScripts { | |||||||||||||||||||
| return steps.filter(Boolean).join(' && '); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| restore(project: Project, outputPath: string): string { | ||||||||||||||||||||
| 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`; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+75
to
78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrap
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| seed(project: Project, scriptPath?: string): string { | ||||||||||||||||||||
|
|
@@ -115,7 +115,9 @@ function getPrismaBaseDir(project: Project): string | undefined { | |||||||||||||||||||
| ?.dbPath; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function getLitestreamConfigOption(project: Project): string { | ||||||||||||||||||||
| function getLitestreamConfigOption(project: Project, configPath?: string): string { | ||||||||||||||||||||
| if (configPath) return `-config "${configPath}"`; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const localConfigPath = path.join(project.dirPath, LITESTREAM_CONFIG_FILE_NAME); | ||||||||||||||||||||
|
Comment on lines
+118
to
121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a monorepo/workspace setup, the command is executed from the package directory (
Suggested change
|
||||||||||||||||||||
| if (fs.existsSync(localConfigPath)) return `-config ./${LITESTREAM_CONFIG_FILE_NAME}`; | ||||||||||||||||||||
| if (fs.existsSync(DEFAULT_LITESTREAM_CONFIG_PATH)) return `-config ${DEFAULT_LITESTREAM_CONFIG_PATH}`; | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a monorepo/workspace setup, the command is executed from the package directory (
project.dirPath), but the user might specify a relative--configpath from the workspace root (where they ran the command). ResolvingconfigPathto an absolute path usingpath.resolve()ensures it is correctly located regardless of the execution directory.