knex migration - 'ER_INVALID_DEFAULT: Invalid default value for 'timestamp'
P粉269847997
P粉269847997 2023-08-28 18:57:04
0
1
426
<p>I have a knex chema migration to create a table where one of the rows is -</p> <pre class="brush:php;toolbar:false;">exports.up = async function(knex) { return knex.schema.createTable("newTable", table => { table.timestamp("timestamp").notNullable(); }) }</pre> <p>I encountered an error<code>ER_INVALID_DEFAULT: Invalid default value for 'timestamp'</code></p> <p>I've tried giving a default value of null and removing notNullable(), or giving a default value of CURRENT_TIMESTAMP, but neither seems to work (maybe there's something wrong with my syntax?)</p> <p>I would appreciate any help! </p>
P粉269847997
P粉269847997

reply all(1)
P粉191323236

If you can access my.ini (mysql configuration file), please remove NO_ZERO_DATE from sql-mode and restart the server.

You can use SHOW VARIABLES LIKE 'sql_mode' command to check.

For the complete answer, please click on the link

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template