make sure migrations always run from 0 to n
This commit is contained in:
parent
89d9dc3cbe
commit
8906d8f7f7
1 changed files with 6 additions and 1 deletions
7
index.ts
7
index.ts
|
@ -63,7 +63,12 @@ const relays = [
|
||||||
];
|
];
|
||||||
|
|
||||||
export function runMigrations(db: Database, latestVersion: number) {
|
export function runMigrations(db: Database, latestVersion: number) {
|
||||||
const migrations = Deno.readDirSync(`${import.meta.dirname}/migrations`);
|
const migrations = [...Deno.readDirSync(`${import.meta.dirname}/migrations`)];
|
||||||
|
migrations.sort((a, b) => {
|
||||||
|
const aVersion = Number.parseInt(a.name.split('-')[0], 10);
|
||||||
|
const bVersion = Number.parseInt(b.name.split('-')[0], 10);
|
||||||
|
return aVersion - bVersion;
|
||||||
|
});
|
||||||
for (const migrationFile of migrations) {
|
for (const migrationFile of migrations) {
|
||||||
const migrationVersion = Number.parseInt(
|
const migrationVersion = Number.parseInt(
|
||||||
migrationFile.name.split('-')[0],
|
migrationFile.name.split('-')[0],
|
||||||
|
|
Loading…
Add table
Reference in a new issue