We are migrating our application from MySQL 5.5
to 5.7
. As the default value 0000-00-00
is not allowed anymore for date fields in MySQL 5.7
in strict mode, I would like to change the default value to NULL
.
The concerned fields are defined as follows:
+------------------+----------------------+------+-----+------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+----------------------+------+-----+------------+----------------+
| event_start_date | date | YES | | 0000-00-00 | |
| event_end_date | date | YES | | 0000-00-00 | |
+------------------+----------------------+------+-----+------------+----------------+
When I try to execute the following ALTER
query:
ALTER TABLE events CHANGE event_start_date event_start_date date DEFAULT NULL;
ALTER TABLE events CHANGE event_end_date event_end_date date DEFAULT NULL;
I get the following error:
Invalid default value for 'event_end_date'
I know it would be possible to disable strict mode, but that is not the solution I am looking for. Strangely enough the same query worked for an other table.
Anyone has an idea what is going wrong?