Too long key for MySQL
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I want to start CodiMD using a MySQL (MariaDB) database. This produces the following error:
```
$ npm run start
> CodiMD@1.2.1 start /home/t/codimd
> sequelize db:migrate && node app.js
Sequelize [Node: 10.15.2, CLI: 2.8.0, ORM: 3.34.0]
Parsed url mysql://codimd:*****@localhost:3306/codimddb
== 20150504155329-create-users: migrating =======
{ SequelizeDatabaseError: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes
at Query.formatError (/home/t/codimd/node_modules/sequelize/lib/dialects/mysql/query.js:175:14)
at Query. (/home/t/codimd/node_modules/sequelize/lib/dialects/mysql/query.js:49:21)
at Query. (/home/t/codimd/node_modules/mysql/lib/Connection.js:502:10)
at Query._callback (/home/t/codimd/node_modules/mysql/lib/Connection.js:468:16)
at Query.Sequence.end (/home/t/codimd/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query.ErrorPacket (/home/t/codimd/node_modules/mysql/lib/protocol/sequences/Query.js:90:8)
at Protocol._parsePacket (/home/t/codimd/node_modules/mysql/lib/protocol/Protocol.js:278:23)
at Parser.write (/home/t/codimd/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/home/t/codimd/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/home/t/codimd/node_modules/mysql/lib/Connection.js:91:28)
at Socket. (/home/t/codimd/node_modules/mysql/lib/Connection.js:502:10)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: 'SequelizeDatabaseError',
message:
'ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes'
```
According to my research this happens because the keyword `UNIQUE` creates an index. However, `VARCHAR(255)` exceeds the 767 bytes limit specified [here](https://dev.mysql.com/doc/refman/8.0/en/innodb-restrictions.html). There are other columns having the same problem, e.g. in Temp.
Possible fix: Lower the maximum length of the corresponding columns or move away from InnoDB.
Workaround: Use a different database.
I'm using the latest master.
Contributor guide
Assessment
This issue has not been assessed yet.