'knex migration - 'ER_INVALID_DEFAULT: Invalid default value for 'timestamp'

I have a knex chema migration to create a table, with the line -

exports.up = async function(knex) {
return knex.schema.createTable("newTable", table => {
table.timestamp("timestamp").notNullable();
})
}

I am getting an error ER_INVALID_DEFAULT: Invalid default value for 'timestamp'

I've tried to give a default of null and remove the notNullable() or a default of CURRENT_TIMESTAMP but nothing seems to work (maybe I have a wrong syntax?)

I'd appreciate any help!



Solution 1:[1]

If you have access to my.ini (mysql conf file) remove the NO_ZERO_DATE from sql-mode and restart the server.

You can check it with SHOW VARIABLES LIKE 'sql_mode'

For the complete answer, follow the link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bruno Brasolin