Not possible to create a 2nd timestamp column that is null

OS info

  • Operating System : Windows 10.0.22621
  • Wappler Version : 6.0.0-beta.15
    PHP / 10.4.27-MariaDB

I am certain this was possible in previous versions.

Steps to reproduce

  1. Create a timestamp column date_created with default knex.fn.now() and not Allow Null.
  2. Create another timestamp column date_updated with no default and Allow Null.
  3. Apply database changes.

timestamp-null

MariaDB has specific behaviour if NULL is assigned to a column of TIMESTAMP data type. If the column is assigned the NULL value in an INSERT or UPDATE query (including via DEFAULT), then it automatically initializes the column value with the current date and time.

Each time when you try to assign NULL to TIMESTAMP column (explicitly or implicitly) it will be assigned to CURRENT_TIMESTAMP.

So specify columns as:

`date_created` timestamp DEFAULT CURRENT_TIMESTAMP

and

`date_updated` DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP