Project

General

Profile

Bug #8337

Version table should not use version field as primary key

Added by Yannick Warnier about 5 years ago. Updated about 5 years ago.

Status:
Bug resolved
Priority:
Normal
Category:
Installation / Migration
Target version:
Start date:
14/07/2016
Due date:
% Done:

100%

Estimated time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

When installing 1.11.0-alpha on PHP 7, I get the following errors:

[Thu Jul 14 12:07:29.360028 2016] [:error] [pid 25544] [client 190.117.112.110:48694] PHP Fatal error:  Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes in /var/www/chamilo/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104\nStack trace:\n#0 /var/www/chamilo/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(104): PDO->query('CREATE TABLE ve...')\n#1 /var/www/chamilo/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(833): Doctrine\\DBAL\\Driver\\PDOConnection->query('CREATE TABLE ve...')\n#2 /var/www/chamilo/www/main/install/index.php(949): Doctrine\\DBAL\\Connection->executeQuery('CREATE TABLE ve...')\n#3 {main}\n\nNext Doctrine\\DBAL\\Driver\\PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes in /var/www/chamilo/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:106\nStack trace:\n#0 /var/www/chamilo/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(833): Doctrine\\DBAL\\Driver\\PDOConnection->query(' in /var/www/chamilo/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 115, referer: http://test.chamilo.net/main/install/index.php?running=1&installType=new&updateFromConfigFile=

To fix this one, I then update main/install/index.php from

        $connection->executeQuery('CREATE TABLE version (version varchar(255), PRIMARY KEY(version));');

to
        $connection->executeQuery('CREATE TABLE version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(255), PRIMARY KEY(id));');

but then I get the following error:

[Thu Jul 14 12:10:57.079516 2016] [:error] [pid 25594] [client 190.117.112.110:48774] An exception occurred while executing 'INSERT INTO version VALUES ('20160418113000')':\n\nSQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1, referer: http://test.chamilo.net/main/install/index.php?running=1&installType=new&updateFromConfigFile=

(because the field is not explicitely defined).

This is solved by updating the query to INSERT INTO version (version) VALUES (...), but I wanted to know if there is any possible issue this will create with the orm:schema:update command afterwards...

Associated revisions

Revision 1fe2caca (diff)
Added by Julio about 5 years ago

Fix issue #8337 wars

History

#1

Updated by Julio Montoya about 5 years ago

  • Assignee changed from Julio Montoya to Yannick Warnier

I just undo the version.id field.

#2

Updated by Yannick Warnier about 5 years ago

  • Assignee changed from Yannick Warnier to Julio Montoya

OK, but please explain. I'm not going to be able to know if this is OK or not, and how to do it right, until you explain.

#3

Updated by Julio Montoya about 5 years ago

  • Assignee changed from Julio Montoya to Yannick Warnier

Yannick Warnier wrote:

OK, but please explain. I'm not going to be able to know if this is OK or not, and how to do it right, until you explain.

I replicated the table creation from doctrine migrations, there can't be 2 same versions in that table. That table is never handled but doctrine (entity) so it doesn't need any complexity.

#4

Updated by Yannick Warnier about 5 years ago

  • Assignee changed from Yannick Warnier to Julio Montoya

And is there any problem with adding an ID field to the table? (I can't see why there would be an issue, but you removed the field, so I need to know why)

#5

Updated by Julio Montoya about 5 years ago

  • Assignee changed from Julio Montoya to Yannick Warnier

Yannick Warnier wrote:

And is there any problem with adding an ID field to the table? (I can't see why there would be an issue, but you removed the field, so I need to know why)

I added the id + the unique here, as it was before.

https://github.com/chamilo/chamilo-lms/commit/af7f65b1710a2f362a38aa132e275fff9bbf5a6e

#6

Updated by Yannick Warnier about 5 years ago

  • Status changed from Needs more info to Bug resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF