PHPCI icon indicating copy to clipboard operation
PHPCI copied to clipboard

Error on install: Syntax error or access violation: 1067 Invalid default value for 'end_time'

Open Petah opened this issue 9 years ago • 13 comments

PHP 5.6.9RC1 mysql Ver 14.14 Distrib 5.7.7-rc, for Win64 (x86_64)

C:\work\phpci>php console phpci:install

******************
 Welcome to PHPCI
******************

Checking requirements... OK

Please answer the following questions:
-------------------------------------

Please enter your MySQL host [localhost]:
Please enter your MySQL database name [phpci]:
Please enter your MySQL username [phpci]: root
Please enter your MySQL password:
PHPCI could not connect to MySQL with the details provided. Please try again.
SQLSTATE[HY000] [1049] Unknown database 'phpci'
Please enter your MySQL host [localhost]: 127.0.0.1
Please enter your MySQL database name [phpci]:
Please enter your MySQL username [phpci]: root
Please enter your MySQL password:

Your PHPCI URL ("http://phpci.local" for example): http://localhost:85
Setting up your database...


  [InvalidArgumentException]
  There was a problem creating the schema table: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'end_time'



migrate [-c|--configuration="..."] [-p|--parser="..."] [-e|--environment="..."] [-t|--target="..."]


OK

Petah avatar Jul 28 '15 20:07 Petah

Try running mysqld with --explicit_defaults_for_timestamp=TRUE

As per the error message:

TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

See MySQL docs reference: https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp

ghost avatar Dec 23 '15 09:12 ghost

I have the same problem. I try to run "sudo /usr/local/mysql/bin/mysqld --explicit_defaults_for_timestamp=FALSE" on my mac but the error is the same

jonnylor63 avatar Jan 12 '16 16:01 jonnylor63

Try running mysqld with just --explicit_defaults_for_timestamp. (remove =TRUE or =FALSE)

It should then allow for timestamp default values.

ghost avatar Jan 12 '16 19:01 ghost

Or it would be great if the migrations just catered for this.

Petah avatar Jan 13 '16 00:01 Petah

If I run mysqld with just --explicit_defaults_for_timestamp I get the following message

SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB, TEXT, GEOMETRY or JSON   
  column 'log' can't have a default value

PascalMinder avatar Jan 14 '16 10:01 PascalMinder

To fix that I had to edit a migrations file, and alter how the log field was being added.

ghost avatar Jan 14 '16 11:01 ghost

Can you remember which file it was?

PascalMinder avatar Jan 14 '16 11:01 PascalMinder

Change PHPCI/Migrations/20150203105015_fix_column_types.php to

  1 <?php
  2 
  3 use Phinx\Migration\AbstractMigration;
  4 use Phinx\Db\Adapter\MysqlAdapter;
  5 
  6 class FixColumnTypes extends AbstractMigration
  7 {
  8     /*
  9      * Migrate Up.
 10      */
 11     public function up()
 12     {
 13         // Update the build log column to MEDIUMTEXT:
 14         $build = $this->table('build');
 15         $build->changeColumn('log', 'text', array(
 16             'null' => true,
 17             'limit' => MysqlAdapter::TEXT_MEDIUM,
 18         ));
 19 
 20         // Update the build meta value column to MEDIUMTEXT:
 21         $buildMeta = $this->table('build_meta');
 22         $buildMeta->changeColumn('meta_value', 'text', array(
 23             'null' => false,
 24             'limit' => MysqlAdapter::TEXT_MEDIUM,
 25         ));
 26     }
 27 }

ghost avatar Jan 14 '16 11:01 ghost

still the same error: SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB, TEXT, GEOMETRY or JSON column 'log' can't have a default value

PascalMinder avatar Jan 14 '16 16:01 PascalMinder

I had to change the file 20140730143702_fix_database_columns.php and on line 23: $build->changeColumn('log', 'text', array('null' => true));

Now it works

PascalMinder avatar Jan 14 '16 16:01 PascalMinder

It's there a PR for these fix already?

zot24 avatar Jan 18 '16 23:01 zot24

Not yet. In which branch should I put it?

PascalMinder avatar Jan 19 '16 07:01 PascalMinder

Not sure why the PascalMinder commit 14f4e58 hasn't been merged yet but just in case I created a PR

https://github.com/Block8/PHPCI/pull/1205

Thanks!

gnuget avatar Apr 13 '16 04:04 gnuget