Skip to content

Commit

Permalink
Upgrade Migration Management
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed May 30, 2022
1 parent a670f29 commit beca166
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/database/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,28 @@ export const migrate = async (
}
)) ?? {
instance_id: '1',
current_version: 0,
current_version: '0',
};

log.database('Current Migration: ' + current_version);
log.database(
'Current Migration: #' +
(-1 + Number.parseInt(current_version)).toString()
);

let index = +current_version;
let migrations_run = 0;

while (index + 1 < migrations.length) {
index += 1;
while (index < migrations.length) {
log.database('Running Migration ' + index);
await migrations[index](database, (log_text) =>
log.database('M-' + index + ': ' + log_text)
);
migrations_run += 1;
index += 1;
await database.insertInto('migrations', {
instance_id: '1',
current_version: index.toString(),
});
migrations_run += 1;
}

if (migrations_run == 0) {
Expand Down

0 comments on commit beca166

Please sign in to comment.