Error: Encoding not recognized: 'undefined' (searched as: 'undefined')
RuslanBurgun opened this issue · 3 comments
Error: Encoding not recognized: 'undefined' (searched as: 'undefined')
Current behavior
db-migrate up -v --env=prod
[INFO] Detected and using the projects local version of db-migrate. '/usr/src/app/node_modules/db-migrate/index.js'
[INFO] require: db-migrate-mysql
[INFO] connecting
Ignoring invalid configuration option passed to Connection: driver. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
[INFO] connected
[INFO] creating table: migrations
[SQL] CREATE TABLE IF NOT EXISTS `migrations` (`id` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL, `name` VARCHAR (255) NOT NULL, `run_on` DATETIME NOT NULL)
[INFO] migration table created
[INFO] loading migrations from dir /usr/src/app/packages/private-service/migrations
[INFO] loading migrations from database
[SQL] SELECT * FROM `migrations` ORDER BY run_on DESC, name DESC
[ERROR] Error: Encoding not recognized: 'undefined' (searched as: 'undefined')
at Object.getCodec (/usr/src/app/node_modules/mysql2/node_modules/iconv-lite/lib/index.js:104:23)
at Object.getEncoder (/usr/src/app/node_modules/mysql2/node_modules/iconv-lite/lib/index.js:115:23)
at Object.exports.encode (/usr/src/app/node_modules/mysql2/lib/parsers/string.js:23:25)
at Query.toPacket (/usr/src/app/node_modules/mysql2/lib/packets/query.js:16:30)
at Query.start (/usr/src/app/node_modules/mysql2/lib/commands/query.js:60:38)
at Query.execute (/usr/src/app/node_modules/mysql2/lib/commands/command.js:40:22)
at Connection.handlePacket (/usr/src/app/node_modules/mysql2/lib/connection.js:456:32)
at Connection.addCommand (/usr/src/app/node_modules/mysql2/lib/connection.js:478:12)
at Connection.query (/usr/src/app/node_modules/mysql2/lib/connection.js:546:17)
at Class.all (/usr/src/app/node_modules/db-migrate-mysql/index.js:479:34)
at Class.allLoadedMigrations (/usr/src/app/node_modules/db-migrate-base/index.js:726:17)
at Function.Migration.loadFromDatabase (/usr/src/app/node_modules/db-migrate/lib/migration.js:350:12)
at /usr/src/app/node_modules/db-migrate/lib/migrator.js:195:17
at /usr/src/app/node_modules/db-migrate/lib/migration.js:341:5
at FSReqCallback.oncomplete (fs.js:156:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Expected behavior
Migration should be applied
Minimal reproduction of the problem with instructions
when I run db-migrate up -v --env=prod
Environment
db-migrate 0.11.11
db-migrate-mysql: ^2.1.1
mysql version 8.0.23
did you resolve this issue?
Same error but in a different situation so the problem could be related.
When using mysql-import I was getting this error. In the imported SQL file I removed /*!40101 SET NAMES utf8 /; and it worked.
I kept /!40101 SET NAMES utf8mb4 */;
It's as if utf8 doesn't resolve anymore. I think the default for utf8 was utf8mb3
Edit: There it is https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html
convert your table into utf8mb4
"ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
Add this raw after running migrations