dancryer / PHPCI

PHPCI is a free and open source continuous integration tool specifically designed for PHP.
BSD 2-Clause "Simplified" License
2.42k stars 441 forks source link

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

Open Petah opened 9 years ago

Petah commented 9 years ago

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
ghost commented 8 years ago

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

jonnylor63 commented 8 years ago

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

ghost commented 8 years ago

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

It should then allow for timestamp default values.

Petah commented 8 years ago

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

PascalMinder commented 8 years ago

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
ghost commented 8 years ago

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

PascalMinder commented 8 years ago

Can you remember which file it was?

ghost commented 8 years ago

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 }
PascalMinder commented 8 years ago

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 commented 8 years ago

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

zot24 commented 8 years ago

It's there a PR for these fix already?

PascalMinder commented 8 years ago

Not yet. In which branch should I put it?

gnuget commented 8 years ago

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!