diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index edaf8ec..4a597cf 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -829,6 +829,9 @@ function install_base_system(&$install_state) { // Enable the user module so that sessions can be recorded during the // upcoming bootstrap step. + // A user module table references a filter module table, so it must be + // installed first. + module_enable(array('filter'), FALSE); module_enable(array('user'), FALSE); // Save the list of other modules to install for the upcoming tasks. diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index d88633f..4218ac0 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -278,6 +278,11 @@ class Schema extends DatabaseSchema { $keys[] = 'INDEX `' . $index . '` (' . $this->createKeysSqlHelper($fields) . ')'; } } + if (!empty($spec['foreign keys'])) { + foreach ($spec['foreign keys'] as $key => $definition) { + $keys[] = 'FOREIGN KEY (`' . implode('`, `', array_keys($definition['columns'])) . '`) REFERENCES ' . $definition['table'] . '(`' . implode('`, `', $definition['columns']) . '`)'; + } + } return $keys; } diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 12b720e..53efdd5 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -127,10 +127,12 @@ function node_schema() { 'uuid' => array('uuid'), ), 'foreign keys' => array( +/* node_revision table not yet created. Can't change the table creation order because they each refer to the other. 'node_revision' => array( 'table' => 'node_revision', 'columns' => array('vid' => 'vid'), ), +*/ 'node_author' => array( 'table' => 'users', 'columns' => array('uid' => 'uid'), @@ -190,10 +192,12 @@ function node_schema() { ), 'primary key' => array('nid', 'gid', 'realm'), 'foreign keys' => array( +/* node_install() creates a record with nid = 0, which cannot exist since nid is serial and must be > 0. https://drupal.org/node/1703222 'affected_node' => array( 'table' => 'node', 'columns' => array('nid' => 'nid'), ), +*/ ), ); diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index 9ee9fd3..43642cb 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -76,10 +76,12 @@ function shortcut_schema() { ), 'primary key' => array('set_name'), 'foreign keys' => array( +/* shortcut_set_save() creates shortcut_set records before menu_links records, violating this constraint. https://drupal.org/node/1703208 'menu_name' => array( 'table' => 'menu_links', 'columns' => array('set_name' => 'menu_name'), ), +*/ ), ); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 0e42214..e15113d 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -928,10 +928,12 @@ function system_schema() { ), 'primary key' => array('fid'), 'foreign keys' => array( +/* system module is installed first, before users table is created. 'file_owner' => array( 'table' => 'users', 'columns' => array('uid' => 'uid'), ), +*/ ), ); @@ -1574,10 +1576,12 @@ function system_schema() { 'ssid' => array('ssid'), ), 'foreign keys' => array( +/* system module is installed first, before users table is created. 'session_user' => array( 'table' => 'users', 'columns' => array('uid' => 'uid'), ), +*/ ), );