-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix sync server migrations #6346
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
Merged
matt-fidd
merged 14 commits into
actualbudget:master
from
jgranick:fix-sync-server-migrations
Feb 4, 2026
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cf86fdc
Fix sync-server migrations to use ESM loader
jgranick 5fbe29f
Add release notes
jgranick df52ad3
Merge branch 'master' into fix-sync-server-migrations
jgranick 9630fc0
Apply CodeRabbit suggestions
jgranick d648b60
[autofix.ci] apply automated fixes
autofix-ci[bot] c65dd07
Merge branch 'master' into fix-sync-server-migrations
MatissJanis 84986cb
Add file extension filter to sync-server migrations import
jgranick 9e3b2a8
[autofix.ci] apply automated fixes
autofix-ci[bot] 25b92d4
Merge branch 'master' into fix-sync-server-migrations
MatissJanis 19f9784
Ensure migrations occur synchronously
jgranick e804840
Merge branch 'master' into fix-sync-server-migrations
jgranick 775e108
[autofix.ci] apply automated fixes
autofix-ci[bot] 4c36c84
Minor cleanup
jgranick 5966e48
Merge branch 'master' into fix-sync-server-migrations
matt-fidd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import path, { dirname } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { readdir } from 'node:fs/promises'; | ||
|
|
||
| import migrate from 'migrate'; | ||
|
|
||
| import { config } from './load-config.js'; | ||
|
|
||
| export async function run(direction: 'up' | 'down' = 'up'): Promise<void> { | ||
| console.log( | ||
| `Checking if there are any migrations to run for direction "${direction}"...`, | ||
| ); | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); // this directory | ||
| const migrationsDir = path.join(__dirname, '../migrations'); | ||
|
|
||
| try { | ||
| // Load all script files in the migrations directory | ||
| const files = await readdir(migrationsDir); | ||
| const migrationsModules: { [key: string]: { up: Function, down: Function } } = {}; | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| await Promise.all( | ||
| files | ||
| .sort() | ||
| .map(async (f) => { | ||
| migrationsModules[f] = await import(path.join(migrationsDir, f)); | ||
| }) | ||
| ); | ||
|
jgranick marked this conversation as resolved.
Outdated
|
||
|
|
||
| return new Promise<void>((resolve, reject) => { | ||
| migrate.load( | ||
| { | ||
| stateStore: `${path.join(config.get('dataDir'), '.migrate')}${config.get('mode') === 'test' ? '-test' : ''}`, | ||
| migrations: migrationsModules, | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| }, | ||
| (err, set) => { | ||
| if (err) return reject(err); | ||
|
|
||
| set[direction](err => { | ||
| if (err) return reject(err); | ||
|
|
||
| console.log('Migrations: DONE'); | ||
| resolve(); | ||
| }); | ||
| } | ||
| ); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| }); | ||
| } catch (err) { | ||
| console.error('Error during migration process:', err); | ||
| throw err; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| category: Bugfix | ||
| authors: [jgranick] | ||
| --- | ||
|
|
||
| Fix sync-server migrations to use ESM loader |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.