Closed wallysonn closed 11 months ago
I solved it in my case just by changing it
table.timestamp('created_at', { useTz: true }).notNullable()
table.timestamp('updated_at', { useTz: true }).notNullable()
to
table.timestamps(true, true)
in the migration files. In any case, I would like to know if this behavior is expected or if it really is a bug that will be resolved in the future. Thank you for your great work.
This is weird, because the table.timestamp('created_at')
should not be adding current_timestamp() ON UPDATE current_timestamp()
.
Can you please share the complete migration file for this table?
This issue with dates is screwing me over. Now when I try to use a "merge" to update a record, I get this error:
update
sales
setcreated_at
= '2023-12-14T15:36:27.000-03:00',updated_at
= '2023-12 -14 15:52:22',status
= 'sale' whereid
= 2 - Incorrect datetime value: '2023-12-14T15:36:27.000-03:00' for columnbx
.sales
.created_at
at row 1
This is my code:
let saleModel = await Sale.findByOrFail('uuid', sale.uuid) saleModel.merge({ ...sale, status: state, }) await saleModel.save()
Isso é estranho, porque
table.timestamp('created_at')
não deveria adicionarcurrent_timestamp() ON UPDATE current_timestamp()
.Você pode compartilhar o arquivo de migração completo desta tabela?
Hello. The problem happens with all tables. Apparently those who use Postgre do not have this problem, but MySQL or MariaDB users are suffering.
import BaseSchema from '@ioc:Adonis/Lucid/Schema' export default class extends BaseSchema { protected tableName = 'attendances'
public async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id') table.uuid('uuid').notNullable().unique() table.timestamp('created_at', { useTz: true }).notNullable() table.timestamp('updated_at', { useTz: true }).notNullable() table.timestamp('deleted_at' ).nullable() table.timestamp('start_at').nullable() table.timestamp('status_at').nullable() table.timestamp('end_at' ).nullable() table.integer('duration').nullable() table.integer('await_time').nullable() table.string('platform_identification').notNullable() table.string('type').notNullable() table.string('platform').notNullable() table.string('channel').nullable() table.string('channel_alias').nullable() table.string('service_name').notNullable() table.string('input').notNullable() table.string('platform_status').nullable() table.string('platform_attendance_status').nullable() table .integer('status_id') .unsigned() .notNullable() .references('id') .inTable('attendance_statuses') //status do atendimento table .integer('kanban_phase_id') .unsigned() .nullable() .references('id') .inTable('kanban_phases') .onDelete('CASCADE') //fase do kanban table .integer('customer_id') .unsigned() .notNullable() .references('id') .inTable('customers') .onDelete('CASCADE') table .integer('store_id') .unsigned() .nullable() .references('id') .inTable('stores') .onDelete('CASCADE') table .integer('user_id') .unsigned() .notNullable() .references('id') .inTable('users') .onDelete('CASCADE') }) }
public async down() { this.schema.dropTable(this.tableName) } }
Duplicate of https://github.com/adonisjs/lucid/issues/924
I noticed that my records in the database all have their creation dates changed. I noticed that when executing a "save", as per the code example below, even if I am just editing a record, the creation date is also changed and it does not respect my timezone.
This is my table after migration:
Package version
"@adonisjs/core": "^5.8.0", "@adonisjs/lucid": "^18.4.0",
Node.js and npm version
18.17.0
Sample Code (to reproduce the issue)
In my migration, the timestamp columns are created like this: