mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-17 18:44:45 +02:00
Server: Display latest migration name after auto-migration
This commit is contained in:
parent
ce5c5d6042
commit
7ad73df170
@ -5,7 +5,7 @@ import * as Koa from 'koa';
|
|||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import Logger, { LoggerWrapper, TargetType } from '@joplin/lib/Logger';
|
import Logger, { LoggerWrapper, TargetType } from '@joplin/lib/Logger';
|
||||||
import config, { initConfig, runningInDocker } from './config';
|
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 { AppContext, Env, KoaNext } from './utils/types';
|
||||||
import FsDriverNode from '@joplin/lib/fs-driver-node';
|
import FsDriverNode from '@joplin/lib/fs-driver-node';
|
||||||
import routeHandler from './middleware/routeHandler';
|
import routeHandler from './middleware/routeHandler';
|
||||||
@ -269,6 +269,7 @@ async function main() {
|
|||||||
if (config().database.autoMigration) {
|
if (config().database.autoMigration) {
|
||||||
appLogger().info('Auto-migrating database...');
|
appLogger().info('Auto-migrating database...');
|
||||||
await migrateLatest(ctx.joplinBase.db);
|
await migrateLatest(ctx.joplinBase.db);
|
||||||
|
appLogger().info('Latest migration:', (await latestMigration(ctx.joplinBase.db)).name);
|
||||||
} else {
|
} else {
|
||||||
appLogger().info('Skipped database auto-migration.');
|
appLogger().info('Skipped database auto-migration.');
|
||||||
}
|
}
|
||||||
|
@ -347,10 +347,10 @@ export function isUniqueConstraintError(error: any): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function latestMigration(db: DbConnection): Promise<any> {
|
export async function latestMigration(db: DbConnection): Promise<Migration> {
|
||||||
try {
|
try {
|
||||||
const result = await db('knex_migrations').select('name').orderBy('id', 'desc').first();
|
const result = await db('knex_migrations').select('name').orderBy('id', 'desc').first();
|
||||||
return result;
|
return { name: result.name, done: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If the database has never been initialized, we return null, so
|
// If the database has never been initialized, we return null, so
|
||||||
// for this we need to check the error code, which will be
|
// for this we need to check the error code, which will be
|
||||||
|
Loading…
x
Reference in New Issue
Block a user