Hi,
I have a Mysql column: DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP.
Directus locks the field (greyed out in the UI) for some reason I do not understand. I should be able to update the field.
If I set On Update to Save Current Date/Time in the schema section of the collection to “kind of” workaround the problem. I’m still not able to update the column using flow Update node.
Does anyone know how I can handle this ? Can I possibly change Directus underlying schema definition so that it does not lock this column ?
When you create a new collectiom, you get a tab for “optional fields”, so I assume you want to achieve the date_updated or I’m mistaken?
Note: this grays out the user from editing this field, since it will override anyway, so if you want to let the user the ability to edit this field, I would suggest using a flow to update that field depending on your custom logic.
I’m not completely sure I understand your point.
A field is not necessarily created through the Directus interface. For example, consider the following schema defined directly in MySQL:
CREATE TABLE whatever (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`status_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
);
In this case, Directus marks the “status_date” field as read-only (greyed out in the UI), which isn’t logically justified. This database definition does not prevent updating the column, so I would expect Directus to allow edits.
The second issue I’m pointing out is that, beyond the UI restriction, the field also cannot be updated via a Flow “Update Data” node. This remains true whether or not the “On Update: Save Current Date/Time” option is configured.
So the problem is twofold:
-
The field is incorrectly locked in the UI.
-
The Flow update operation also refuses to modify it.