Fix migration sorting to use numeric comparison
Mirror to GitHub / mirror (push) Successful in 24s
Test and Lint / backend-test (push) Successful in 1m27s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m4s
Version and Release / version-bump (push) Failing after 39s
Version and Release / trigger-drone (push) Has been skipped
Mirror to GitHub / mirror (push) Successful in 24s
Test and Lint / backend-test (push) Successful in 1m27s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m4s
Version and Release / version-bump (push) Failing after 39s
Version and Release / trigger-drone (push) Has been skipped
- Changed from string sort to numeric sort for migration files - String sort was causing '029' to run before '001' - Now properly extracts and compares numeric prefixes - Applied fix to both run-migrations.js and run-migrations-safe.js This ensures 001_init.js runs first and creates all necessary tables before other migrations try to use them.
This commit is contained in:
@@ -134,7 +134,13 @@ async function runMigrations() {
|
||||
migrationFiles = coreFiles
|
||||
.filter(f => f.match(/^\d{3}_.*\.js$/))
|
||||
.map(f => path.join('core', f))
|
||||
.sort();
|
||||
.sort((a, b) => {
|
||||
const baseA = path.basename(a);
|
||||
const baseB = path.basename(b);
|
||||
const numA = parseInt(baseA.split('_')[0]);
|
||||
const numB = parseInt(baseB.split('_')[0]);
|
||||
return numA - numB;
|
||||
});
|
||||
} else {
|
||||
// For existing deployments, run all migrations (legacy + core)
|
||||
console.log('Existing deployment detected - checking all migrations');
|
||||
|
||||
@@ -68,7 +68,13 @@ async function runMigrations() {
|
||||
migrationFiles = coreFiles
|
||||
.filter(f => f.match(/^\d{3}_.*\.js$/))
|
||||
.map(f => path.join('core', f))
|
||||
.sort();
|
||||
.sort((a, b) => {
|
||||
const baseA = path.basename(a);
|
||||
const baseB = path.basename(b);
|
||||
const numA = parseInt(baseA.split('_')[0]);
|
||||
const numB = parseInt(baseB.split('_')[0]);
|
||||
return numA - numB;
|
||||
});
|
||||
} else {
|
||||
// For existing deployments, run all migrations (legacy + core)
|
||||
console.log('Existing deployment detected - checking all migrations');
|
||||
|
||||
Reference in New Issue
Block a user