Edit: Jump to Knex migration adds "on update CURRENT_TIMESTAMP" to created_at column
Wappler Version : 4.4.5
Operating System : MacOS Monterey
Server Model: NodeJS
Database Type: MariaDB 10.5
Hosting Type: Docker
How to reproduce
Create a table people:
- name, primary key
- created_at, timestamp
- present_at, timestamp
Migration file for your convenience:
exports.up = function(knex) {
return knex.schema
.createTable('people', function (table) {
table.string('name').primary();
table.timestamp('created_at');
table.timestamp('present_at');
})
};
exports.down = function(knex) {
return knex.schema
.dropTable('people')
};
Custom Query in Server Action:
INSERT INTO people (name, present_at) VALUES (:P1, :P2) ON DUPLICATE KEY UPDATE present_at=:P2;
:P1 is a random name, :P2 is {{NOW}}
Insert, and then insert again with the same data, it should update due to “ON DUPLICATE KEY”. The problem is, the created_at column is updated as well. I’ve tested this with MariaDB alone (made outside Wappler) and it doesn’t happen, it only happens within Wappler, so either Wappler or Knex is doing some trickery…
Community Page
Last updated:
Last updated: