1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-06-17 00:07:36 +02:00

Implementing .saved_searches.pg2conf saving tests

This commit is contained in:
Patrik J. Braun
2021-05-30 15:09:47 +02:00
parent e26c60d67b
commit 404b82e12b
12 changed files with 78 additions and 18 deletions

View File

@ -22,6 +22,7 @@ import {DatabaseType, ServerDataBaseConfig, SQLLogLevel} from '../../../../commo
import {AlbumBaseEntity} from './enitites/album/AlbumBaseEntity';
import {SavedSearchEntity} from './enitites/album/SavedSearchEntity';
const LOG_TAG = '[SQLConnection]';
export class SQLConnection {
@ -53,7 +54,7 @@ export class SQLConnection {
if (Config.Server.Log.sqlLevel !== SQLLogLevel.none) {
options.logging = SQLLogLevel[Config.Server.Log.sqlLevel];
}
Logger.debug(LOG_TAG, 'Creating connection: ' + DatabaseType[Config.Server.Database.type]);
this.connection = await this.createConnection(options);
await SQLConnection.schemeSync(this.connection);
}
@ -131,7 +132,7 @@ export class SQLConnection {
return await createConnection(options);
} catch (e) {
if (e.sqlMessage === 'Unknown database \'' + options.database + '\'') {
Logger.debug('creating database: ' + options.database);
Logger.debug(LOG_TAG, 'creating database: ' + options.database);
const tmpOption = Utils.clone(options);
// @ts-ignore
delete tmpOption.database;
@ -153,7 +154,7 @@ export class SQLConnection {
if (version && version.version === DataStructureVersion) {
return;
}
Logger.info('Updating database scheme');
Logger.info(LOG_TAG, 'Updating database scheme');
if (!version) {
version = new VersionEntity();
}
@ -173,7 +174,7 @@ export class SQLConnection {
await connection.dropDatabase();
await connection.synchronize();
await connection.getRepository(VersionEntity).save(version);
Logger.warn('Could not move users to the new db scheme, deleting them. Details:' + e.toString());
Logger.warn(LOG_TAG, 'Could not move users to the new db scheme, deleting them. Details:' + e.toString());
}
}