Using phinx 0.3.4.
With a MySQL 5.7.4 server running in STRICT_TRANS_TABLE mode, phinx is unable to create the log table (phinxlog) and exits with an error about an invalid default value for end_time.
The problem is that phinx is trying to make the default value '0000-00-00 00:00:00' on a column with the TIMESTAMP data type.
STRICT_TRANS_TABLE enabled the NO_ZERO_DATE server mode so that is an invalid date.
The correct minimum value for a TIMESTAMP column is '1970-01-01 00:00:01'. When I manually created the table with that default value for end_time, phinx was able to proceed with no problems.
:+1:
Using MySQL, I fixed this issue by monkey patching PdoAdapter:
$table = new Table($this->getSchemaTableName(), $options, $this);
$table->addColumn('version', 'biginteger', array('limit' => 14))
// Fix "SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'start_time'"
->addColumn('start_time', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
->addColumn('end_time', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
->save();
Have you located where the default value of 0000-00-00 00:00:00 comes from? I can't find anything in the code that suggests it should act this way... no default is set in createSchemaTable.
I just got this issue with v0.4.2.1 and MySQL v5.7.5-m15.
I tried downgrading (as I just upgraded), and I got the same issue with v0.3.7 and v0.3.8.
The above fix worked for me.
Of course it's been quite some time since I had to look at this but I'm pretty sure that 0 date value is coming from PHP or PDO itself.
I'm having the same issue. @willdurand solution seems fine to me, why is this issue not closed yet?
It can be closed, can't take @willdurand solution at the moment due to the MySQL version on Travis.
p.s we have now merged in a fix for this in fe920ae96a8a31d28f9397e8cc9f1ae4ee9f3f68
@robmorgan, @Awnage What about mysql version < 5.6 with strict mode?
Most helpful comment
Using MySQL, I fixed this issue by monkey patching
PdoAdapter: