sequelize / cli

The Sequelize CLI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add DETAIL to migration error output

snewcomer opened this issue · comments

Ref code:

console.error(`${clc.red('ERROR:')} ${message}`);

Currently an error logs the message property of the "ERROR".

    console.error(`${_cliColor2.default.red('ERROR:')} ${message}`);

In the case of an error, you get something like

SequelizeForeignKeyConstraintError: insert or update on table "my_table" violates foreign key constraint "...."

We could log the "DETAIL" similar to Postgres log_error_verbosity configuration.

    console.error(`${_cliColor2.default.red('ERROR:')} ${message}`);
    console.error(`${_cliColor2.default.red('DETAIL:')} ${error.original.detail}`);

This would greatly help with debugging migration issues with sequelize.

Logging more detailed output could expose security implications in the normal course of operations for an application. However, for migrations, I don't know if we have this concern. Thoughts?

What do you expect to happen?

ERROR: SequelizeForeignKeyConstraintError: insert or update on table "my_table" violates foreign key constraint "...."
DETAIL: Key (my_column)=(1) is not present in table "my_table"

What is actually happening?

ERROR: SequelizeForeignKeyConstraintError: insert or update on table "my_table" violates foreign key constraint "...."

Dialect:__ postgres (and others)
Database version: N/A
Sequelize CLI version: most recent
Sequelize version: N/A

Since migrations should not be executed from a production server and the CLI should be installed as a devDependency this should not be a security issue, but maybe a 'debug' flag or some thing similar is smart.

Either way; would you be willing to make a PR for this? This can just be the basic implementation with a test, no need to implement the 'debug' flag for that at this stage.