Skip to content

Commit 4e3f47c

Browse files
fix: migration files not sorted by timestamp when using glob (#1299)
Co-authored-by: Shinigami <[email protected]>
1 parent d824817 commit 4e3f47c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/migration.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,16 @@ export async function getMigrationFilePaths(
128128
const globMatches = await glob(dir, {
129129
ignore: ignorePattern,
130130
nodir: true,
131-
absolute: true,
131+
withFileTypes: true,
132132
});
133-
return globMatches.sort(localeCompareStringsNumerically);
133+
134+
return globMatches
135+
.sort(
136+
(a, b) =>
137+
compareFileNamesByTimestamp(a.name, b.name, logger) ||
138+
localeCompareStringsNumerically(a.name, b.name)
139+
)
140+
.map((pathScurry) => pathScurry.fullpath());
134141
}
135142

136143
if (Array.isArray(dir) || Array.isArray(ignorePattern)) {

0 commit comments

Comments
 (0)