From 98ef39b17c2d03ee8fb988fd30b0cf812379030d Mon Sep 17 00:00:00 2001 From: forehalo Date: Mon, 18 Mar 2024 11:30:04 +0800 Subject: [PATCH] fix(server): ensure selfhost admin created after all data migrated --- packages/backend/server/src/data/commands/run.ts | 2 ++ ...053000403-self-host-admin.ts => 99999999-self-host-admin.ts} | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) rename packages/backend/server/src/data/migrations/{1605053000403-self-host-admin.ts => 99999999-self-host-admin.ts} (96%) diff --git a/packages/backend/server/src/data/commands/run.ts b/packages/backend/server/src/data/commands/run.ts index 7d4df391f57df..33b4482b02c15 100644 --- a/packages/backend/server/src/data/commands/run.ts +++ b/packages/backend/server/src/data/commands/run.ts @@ -23,6 +23,8 @@ export async function collectMigrations(): Promise { ) .map(desc => join(folder, desc)); + migrationFiles.sort((a, b) => a.localeCompare(b)); + const migrations: Migration[] = await Promise.all( migrationFiles.map(async file => { return import(pathToFileURL(file).href).then(mod => { diff --git a/packages/backend/server/src/data/migrations/1605053000403-self-host-admin.ts b/packages/backend/server/src/data/migrations/99999999-self-host-admin.ts similarity index 96% rename from packages/backend/server/src/data/migrations/1605053000403-self-host-admin.ts rename to packages/backend/server/src/data/migrations/99999999-self-host-admin.ts index 0d13b0724d831..11c791f2fd880 100644 --- a/packages/backend/server/src/data/migrations/1605053000403-self-host-admin.ts +++ b/packages/backend/server/src/data/migrations/99999999-self-host-admin.ts @@ -4,7 +4,7 @@ import { PrismaClient } from '@prisma/client'; import { UserService } from '../../core/user'; import { Config, CryptoHelper } from '../../fundamentals'; -export class SelfHostAdmin1605053000403 { +export class SelfHostAdmin99999999 { // do the migration static async up(_db: PrismaClient, ref: ModuleRef) { const config = ref.get(Config, { strict: false });