nielsgl / sequelize-paper-trail

Sequelize plugin for tracking revision history of model instances.
MIT License
95 stars 69 forks source link

Syntax error on MySQL for the JSONB data type #87

Closed mrstebo closed 5 years ago

mrstebo commented 5 years ago

When performing a migration I get the following error, which seems to be due to the JSONB data type not being supported by MySQL (8.0.15)

Executing (default): CREATE TABLE IF NOT EXISTS `revisions` (`id` INTEGER NOT NULL auto_increment , `model` TEXT NOT NULL, `document` JSONB NOT NULL, `operation` VARCHAR(7), `document_id` INTEGER NOT NULL, `revision` INTEGER NOT NULL, `created_at` DATETIME NOT NULL, `updated_at` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
{
    "errorMessage": "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JSONB NOT NULL, `operation` VARCHAR(7), `document_id` INTEGER NOT NULL, `revisio' at line 1",
    "errorType": "DatabaseError",
    "stackTrace": [
         "SequelizeDatabaseError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JSONB NOT NULL, `operation` VARCHAR(7), `document_id` INTEGER NOT NULL, `revisio' at line 1",
        "    at Query.formatError (/usr/src/app/node_modules/sequelize/lib/dialects/mysql/query.js:244:16)",
        "    at Query.handler [as onResult] (/usr/src/app/node_modules/sequelize/lib/dialects/mysql/query.js:51:23)",
        "    at Query.execute (/usr/src/app/node_modules/mysql2/lib/commands/command.js:30:14)",
        "    at Connection.handlePacket (/usr/src/app/node_modules/mysql2/lib/connection.js:408:32)",
        "    at PacketParser.Connection.packetParser.p [as onPacket] (/usr/src/app/node_modules/mysql2/lib/connection.js:70:12)",
        "    at PacketParser.executeStart (/usr/src/app/node_modules/mysql2/lib/packet_parser.js:75:16)",
        "    at Socket.Connection.stream.on.data (/usr/src/app/node_modules/mysql2/lib/connection.js:77:25)",
        "    at emitOne (events.js:116:13)",
        "    at Socket.emit (events.js:211:7)",
        "    at addChunk (_stream_readable.js:263:12)",
        "    at readableAddChunk (_stream_readable.js:250:11)",
        "    at Socket.Readable.push (_stream_readable.js:208:10)",
        "    at TCP.onread (net.js:601:20)"
    ]
}
mrstebo commented 5 years ago

Ah, I missed the mysql option, sorry! 🙈

EdByrnee commented 4 years ago

Ah, I missed the mysql option, sorry! 🙈

Hi, I'm having the same issue! Where is this option?

mrstebo commented 4 years ago

@EdByrnee it is here.

Although that option doesn't appear to be documented.

hadimojak commented 3 years ago

@EdByrnee it is here.

Although that option doesn't appear to be documented.

thank you very much