@aurawindsurfing : that seems to work, but would it be a different date for each day I add a new record? Or will it always use the same value?
EDIT: oh as I thought it'll be a fixed date, yeah as @tykus said I need to emulate the CURDATE() function of MySQL. I thought Expression was the way to go, but maybe I misunderstood what it does...
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'data' (SQL: ALTER TABLE selezioni_stampa CHANGE data data DATE DEFAULT 'CURRENT_TIMESTAMP' NOT NULL)
I think it's because the type is date and not datetime? That's why I wanted to use the CURDATE() function, but I still get the same error
PS: I'm using a ->change() function that's why it's an ALTER TABLE and not a CREATE
Anyway I don't this can be achieved, since I can't change the type to Datetime...
I've done some tests from PHPMyAdmin and it's not possible to set it as CURDATE() or CURRENT_TIMESTAMP
What is your mysql version? For <8.0.13, your default is not able to take an expression
With one exception, the default value specified in a DEFAULT clause must be a literal constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that, for TIMESTAMP and DATETIME columns, you can specify CURRENT_TIMESTAMP as the default.
Well actually I'm using an older version in my local machine, so I wouldn't change the version since they always keep it up to date... Having troubles upgrading the version in my machine but that's not the topic so I'll ask somewhere else :)
->useCurrent() Set TIMESTAMP columns to use
CURRENT_TIMESTAMP as default value.
->useCurrentOnUpdate() Set TIMESTAMP columns to use
CURRENT_TIMESTAMP when a record is updated.