Skip to content

Commit

Permalink
Merge pull request #11 from etchteam/fix/file-sorting
Browse files Browse the repository at this point in the history
Fix file sorting
  • Loading branch information
DanWebb authored Oct 6, 2023
2 parents 0567d34 + 824c426 commit 80a53d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cli/run-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ const addMigrationHistory = async (client: ClientAPI, filename: string) => {
const migrate = async (client: ClientAPI, enabledSpaces: string[]) => {
const history = await getMigrationHistory(client);
const files = fs.readdirSync(MIGRATION_DIR);
const newMigrations = difference(files, history);
const newMigrations = difference(files, history).sort((fileA, fileB) => {
const a = parseInt(fileA.split('-')[0], 10);
const b = parseInt(fileB.split('-')[0], 10);
return a - b;
});

if (newMigrations.length > 0) {
console.info('\n📝 Migrating:\n');
Expand Down

0 comments on commit 80a53d0

Please sign in to comment.