From 218950739d062d183045b0a3040e1bff90e77a75 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Fri, 1 Apr 2022 08:57:48 +0100 Subject: [PATCH] Improved readability of log messages during migrations - this commit removes the colons from the log messages to make each line flow easier when you're reading it - also removes a couple of superfluous words that aren't needed --- core/server/data/schema/commands.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/server/data/schema/commands.js b/core/server/data/schema/commands.js index 2df2b2ab64..bdd1a28462 100644 --- a/core/server/data/schema/commands.js +++ b/core/server/data/schema/commands.js @@ -80,18 +80,18 @@ function dropColumn(tableName, column, transaction = db.knex) { */ async function addUnique(tableName, columns, transaction = db.knex) { try { - logging.info(`Adding unique constraint for: ${columns} in table ${tableName}`); + logging.info(`Adding unique constraint for '${columns}' in table '${tableName}'`); return await transaction.schema.table(tableName, function (table) { table.unique(columns); }); } catch (err) { if (err.code === 'SQLITE_ERROR') { - logging.warn(`Constraint for: ${columns} already exists for table: ${tableName}`); + logging.warn(`Constraint for '${columns}' already exists for table '${tableName}'`); return; } if (err.code === 'ER_DUP_KEYNAME') { - logging.warn(`Constraint for: ${columns} already exists for table: ${tableName}`); + logging.warn(`Constraint for '${columns}' already exists for table '${tableName}'`); return; } throw err; @@ -107,18 +107,18 @@ async function addUnique(tableName, columns, transaction = db.knex) { */ async function dropUnique(tableName, columns, transaction = db.knex) { try { - logging.info(`Dropping unique constraint for: ${columns} in table: ${tableName}`); + logging.info(`Dropping unique constraint for '${columns}' in table '${tableName}'`); return await transaction.schema.table(tableName, function (table) { table.dropUnique(columns); }); } catch (err) { if (err.code === 'SQLITE_ERROR') { - logging.warn(`Constraint for: ${columns} does not exist for table: ${tableName}`); + logging.warn(`Constraint for '${columns}' does not exist for table '${tableName}'`); return; } if (err.code === 'ER_CANT_DROP_FIELD_OR_KEY') { - logging.warn(`Constraint for: ${columns} does not exist for table: ${tableName}`); + logging.warn(`Constraint for '${columns}' does not exist for table '${tableName}'`); return; } throw err; @@ -164,7 +164,7 @@ async function addForeign({fromTable, fromColumn, toTable, toColumn, cascadeDele if (DatabaseInfo.isSQLite(transaction)) { const foreignKeyExists = await hasForeignSQLite({fromTable, fromColumn, toTable, toColumn, transaction}); if (foreignKeyExists) { - logging.warn(`Skipped adding foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - foreign key already exists`); + logging.warn(`Skipped adding foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - already exists`); return; } } @@ -195,7 +195,7 @@ async function addForeign({fromTable, fromColumn, toTable, toColumn, cascadeDele } } catch (err) { if (err.code === 'ER_DUP_KEY' || err.code === 'ER_FK_DUP_KEY' || err.code === 'ER_FK_DUP_NAME') { - logging.warn(`Skipped adding foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - foreign key already exists`); + logging.warn(`Skipped adding foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - already exists`); return; } throw err; @@ -216,7 +216,7 @@ async function dropForeign({fromTable, fromColumn, toTable, toColumn, transactio if (DatabaseInfo.isSQLite(transaction)) { const foreignKeyExists = await hasForeignSQLite({fromTable, fromColumn, toTable, toColumn, transaction}); if (!foreignKeyExists) { - logging.warn(`Skipped dropping foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - foreign key does not exist`); + logging.warn(`Skipped dropping foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - does not exist`); return; } } @@ -243,7 +243,7 @@ async function dropForeign({fromTable, fromColumn, toTable, toColumn, transactio } } catch (err) { if (err.code === 'ER_CANT_DROP_FIELD_OR_KEY') { - logging.warn(`Skipped dropping foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - foreign key does not exist`); + logging.warn(`Skipped dropping foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - does not exist`); return; } throw err; @@ -280,18 +280,18 @@ async function addPrimaryKey(tableName, columns, transaction = db.knex) { if (DatabaseInfo.isSQLite(transaction)) { const primaryKeyExists = await hasPrimaryKeySQLite(tableName, transaction); if (primaryKeyExists) { - logging.warn(`Primary key constraint for: ${columns} already exists for table: ${tableName}`); + logging.warn(`Primary key constraint for '${columns}' already exists for table '${tableName}'`); return; } } try { - logging.info(`Adding primary key constraint for: ${columns} in table ${tableName}`); + logging.info(`Adding primary key constraint for '${columns}' in table '${tableName}'`); return await transaction.schema.table(tableName, function (table) { table.primary(columns); }); } catch (err) { if (err.code === 'ER_MULTIPLE_PRI_KEY') { - logging.warn(`Primary key constraint for: ${columns} already exists for table: ${tableName}`); + logging.warn(`Primary key constraint for '${columns}' already exists for table '${tableName}'`); return; } throw err;