1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Server: Display latest migration name after auto-migration

This commit is contained in:
Laurent Cozic 2021-11-03 15:18:20 +00:00
parent ce5c5d6042
commit 7ad73df170
2 changed files with 4 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import * as Koa from 'koa';
import * as fs from 'fs-extra';
import Logger, { LoggerWrapper, TargetType } from '@joplin/lib/Logger';
import config, { initConfig, runningInDocker } from './config';
import { migrateLatest, waitForConnection, sqliteDefaultDir } from './db';
import { migrateLatest, waitForConnection, sqliteDefaultDir, latestMigration } from './db';
import { AppContext, Env, KoaNext } from './utils/types';
import FsDriverNode from '@joplin/lib/fs-driver-node';
import routeHandler from './middleware/routeHandler';
@ -269,6 +269,7 @@ async function main() {
if (config().database.autoMigration) {
appLogger().info('Auto-migrating database...');
await migrateLatest(ctx.joplinBase.db);
appLogger().info('Latest migration:', (await latestMigration(ctx.joplinBase.db)).name);
} else {
appLogger().info('Skipped database auto-migration.');
}

View File

@ -347,10 +347,10 @@ export function isUniqueConstraintError(error: any): boolean {
return false;
}
export async function latestMigration(db: DbConnection): Promise<any> {
export async function latestMigration(db: DbConnection): Promise<Migration> {
try {
const result = await db('knex_migrations').select('name').orderBy('id', 'desc').first();
return result;
return { name: result.name, done: true };
} catch (error) {
// If the database has never been initialized, we return null, so
// for this we need to check the error code, which will be