Author Topic: [SOLVED] Installation failed due to PRIMARY KEY issue  (Read 613 times)

bmoreitdan

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
[SOLVED] Installation failed due to PRIMARY KEY issue
« on: March 22, 2018, 10:22:05 AM »
fengOffice 3.5.1.5
MySQL 5.7.17

Issue: fengOffice installation failed because of the error "MySQL said: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead".

Background: Starting in MySQL 5.7.3, PRIMARY KEYs must not be NULL, but instead NOT NULL.

Fix: find primary key in /public/install/installation/templates/sql/mysql_schema.php which is set to only NULL instead of NOT NULL and change to NOT NULL
Original Code
Quote
CREATE TABLE `<?php echo $table_prefix ?>contact_config_option_values` (
  `option_id` int(10) unsigned NOT NULL default '0',
  `contact_id` int(10) unsigned NOT NULL default '0',
  `value` text <?php echo $default_collation ?>,
  `member_id` INT( 10 ) UNSIGNED NULL DEFAULT '0',
  PRIMARY KEY  ( `option_id` , `contact_id` , `member_id` )
) ENGINE=<?php echo $engine ?> <?php echo $default_charset ?>;


Add `NOT` in front of NULL for `member_id`

Fixed Code
Quote
CREATE TABLE `<?php echo $table_prefix ?>contact_config_option_values` (
  `option_id` int(10) unsigned NOT NULL default '0',
  `contact_id` int(10) unsigned NOT NULL default '0',
  `value` text <?php echo $default_collation ?>,
  `member_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY  ( `option_id` , `contact_id` , `member_id` )
) ENGINE=<?php echo $engine ?> <?php echo $default_charset ?>;

Save and attempt installation again.