Framework version 5.0.0-preview-rc-1.11
Node v12.16.1
Npm 6.13.7
Using node ace make:migration event
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class Events extends BaseSchema {
protected tableName = 'event'
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.timestamps(true)
})
}
public async down () {
this.schema.dropTable(this.tableName)
}
}
The default value "table.timestamps(true)" do that error :
fatal Error: ER_INVALID_DEFAULT: Invalid default value for 'updated_at'
Removing true : table.timestamps() , solve the problem.
Thanks !
Against which database you are running the migration?
Hey @Reptiluka! :wave:
If you are using MySQL, you need to use table.timestamps(true, true) to correctly set the default value of updated_at field.
@thetutlage it's MySQL
@RomainLanz ok I will try that ! Maybe it was written in Knex.js doc, but in Adonisjs doc I don't find this, so it was confusing haha.
Thank you !
@Reptiluka So how did you resolved the problem?
Thanks!
Hi @ezehlivinus !
I followed the reply from @RomainLanz , so .timestamps(true, true) instead of .timestamps(true)
Most helpful comment
Hey @Reptiluka! :wave:
If you are using MySQL, you need to use
table.timestamps(true, true)to correctly set the default value ofupdated_atfield.