I started adding a few migration files. If a MySQL error is thrown, it would be nice to see the file name - or at least the timestamp of the file that was being processed. I'd also like the option to hide the stack trace of the error.
npm run up
> node --env-file=.env ./scripts/migration.js up
Run: true Type: UP:
-- Add new temporary column
ALTER TABLE push_subscriptions
ADD COLUMN id_new VARCHAR(64) UNIQUE NOT NULL;
/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
^
Error: ER_DUP_ENTRY: Duplicate entry '' for key 'id_new'
at Sequence._packetToError (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
at Protocol._parsePacket (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/Connection.js:88:28)
at Socket.<anonymous> (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (node:events:520:28)
at addChunk (node:internal/streams/readable:559:12)
--------------------
at Protocol._enqueue (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at PoolConnection.query (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/Connection.js:198:25)
at /Users/lewismoten/dev/test_db/node_modules/mysql-migrations/query.js:16:18
at Ping.onOperationComplete (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/Pool.js:110:5)
at Ping.<anonymous> (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/Connection.js:526:10)
at Ping._callback (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/Connection.js:488:16)
at Sequence.end (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Sequence.OkPacket (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/sequences/Sequence.js:92:8)
at Protocol._parsePacket (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/Users/lewismoten/dev/test_db/node_modules/mysql/lib/protocol/Parser.js:433:10) {
code: 'ER_DUP_ENTRY',
errno: 1062,
sqlMessage: "Duplicate entry '' for key 'id_new'",
sqlState: '23000',
index: 0,
sql: '\n' +
' -- Add new temporary column\n' +
' ALTER TABLE push_subscriptions\n' +
' ADD COLUMN id_new VARCHAR(64) UNIQUE NOT NULL;\n' +
' '
}
Node.js v22.2.0
I started adding a few migration files. If a MySQL error is thrown, it would be nice to see the file name - or at least the timestamp of the file that was being processed. I'd also like the option to hide the stack trace of the error.