? 880132.patch
Index: includes/database/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/schema.inc,v
retrieving revision 1.38
diff -u -p -r1.38 schema.inc
--- includes/database/schema.inc	2 Aug 2010 18:55:17 -0000	1.38
+++ includes/database/schema.inc	19 Aug 2010 17:36:24 -0000
@@ -75,10 +75,11 @@
  *  - 'unique keys': An associative array of unique keys ('keyname' =>
  *    specification). Each specification is an array of one or more
  *    key column specifiers (see below) that form a unique key on the table.
- *  - 'foreign keys': An associative array, each key references a column
- *    of the local table, each value is an array with a single key pair as
- *    'tablename' => 'column' where 'column' is the foreign column to
- *    reference.
+ *  - 'foreign keys': An associative array of relations ('my_relation' =>
+ *    specification). Each specification is an array containing the name of
+ *    the referenced table ('table'), and an array of column mappings
+ *    ('columns'). Column mappings are defined by key pairs ('source_column' =>
+ *    'referenced_column').
  *  - 'indexes':  An associative array of indexes ('indexname' =>
  *    specification). Each specification is an array of one or more
  *    key column specifiers (see below) that form an index on the
@@ -131,8 +132,14 @@
  *     'vid' => array('vid'),
  *   ),
  *   'foreign keys' => array(
- *      'vid' => array('node_revision' => 'vid'),
- *      'uid' => array('users' => 'uid'),
+ *     'node_revision' => array(
+ *       'table' => 'node_revision',
+ *       'columns' => array('vid' => 'vid'),
+ *      ),
+ *     'node_author' => array(
+ *       'table' => 'users',
+ *       'columns' => array('uid' => 'uid'),
+ *      ),
  *    ),
  *   'primary key' => array('nid'),
  * );
Index: modules/aggregator/aggregator.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v
retrieving revision 1.30
diff -u -p -r1.30 aggregator.install
--- modules/aggregator/aggregator.install	1 May 2010 08:12:22 -0000	1.30
+++ modules/aggregator/aggregator.install	19 Aug 2010 17:36:24 -0000
@@ -80,7 +80,10 @@ function aggregator_schema() {
       'fid' => array('fid'),
     ),
     'foreign keys' => array(
-      'cid' => array('aggregator_category' => 'cid'),
+      'aggregator_category' => array(
+        'table' => 'aggregator_category',
+        'columns' => array('cid' => 'cid'),
+      ),
     ),
   );
 
@@ -105,7 +108,10 @@ function aggregator_schema() {
       'iid' => array('iid'),
     ),
     'foreign keys' => array(
-      'cid' => array('aggregator_category' => 'cid'),
+      'aggregator_category' => array(
+        'table' => 'aggregator_category',
+        'columns' => array('cid' => 'cid'),
+      ),
     ),
   );
 
@@ -264,7 +270,10 @@ function aggregator_schema() {
       'fid' => array('fid'),
     ),
     'foreign keys' => array(
-      'fid' => array('aggregator_feed' => 'fid'),
+      'aggregator_feed' => array(
+        'table' => 'aggregator_feed',
+        'columns' => array('fid' => 'fid'),
+      ),
     ),
   );
 
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.67
diff -u -p -r1.67 comment.install
--- modules/comment/comment.install	23 May 2010 19:10:22 -0000	1.67
+++ modules/comment/comment.install	19 Aug 2010 17:36:25 -0000
@@ -456,8 +456,14 @@ function comment_schema() {
     ),
     'primary key' => array('cid'),
     'foreign keys' => array(
-      'nid' => array('node' => 'nid'),
-      'uid' => array('users' => 'uid'),
+      'comment_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'comment_author' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
@@ -510,8 +516,16 @@ function comment_schema() {
       'last_comment_uid' => array('last_comment_uid'),
     ),
     'foreign keys' => array(
-      'nid' => array('node' => 'nid'),
-      'last_comment_uid' => array('users' => 'uid'),
+      'statistics_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'last_comment_author' => array(
+        'table' => 'users',
+        'columns' => array(
+          'last_comment_uid' => 'uid',
+        ),
+      ),
     ),
   );
 
Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.49
diff -u -p -r1.49 forum.install
--- modules/forum/forum.install	17 Aug 2010 21:44:37 -0000	1.49
+++ modules/forum/forum.install	19 Aug 2010 17:36:26 -0000
@@ -153,8 +153,13 @@ function forum_schema() {
     ),
     'primary key' => array('vid'),
     'foreign keys' => array(
-      'nid' => array('node' => 'nid'),
-      'vid' => array('node' => 'vid'),
+      'forum_node' => array(
+        'table' => 'node',
+        'columns' => array(
+          'nid' => 'nid',
+          'vid' => 'vid',
+        ),
+      ),
     ),
   );
 
@@ -214,8 +219,16 @@ function forum_schema() {
       'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'),
     ),
     'foreign keys' => array(
-      'node' => 'nid',
-      'taxonomy_term_data' => 'tid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'term' => array(
+        'table' => 'taxonomy_term_data',
+        'columns' => array(
+          'tid' => 'tid',
+        ),
+      ),
     ),
   );
 
@@ -291,8 +304,16 @@ function forum_update_7001() {
       'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'),
     ),
     'foreign keys' => array(
-      'node' => 'nid',
-      'taxonomy_term_data' => 'tid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'term' => array(
+        'table' => 'taxonomy_term_data',
+        'columns' => array(
+          'tid' => 'tid',
+        ),
+      ),
     ),
   );
   db_create_table('forum_index', $forum_index);
Index: modules/image/image.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/image/image.install,v
retrieving revision 1.10
diff -u -p -r1.10 image.install
--- modules/image/image.install	25 Jun 2010 17:47:22 -0000	1.10
+++ modules/image/image.install	19 Aug 2010 17:36:26 -0000
@@ -98,7 +98,10 @@ function image_schema() {
       'weight' => array('weight'),
     ),
     'foreign keys' => array(
-      'isid' => array('image_styles' => 'isid'),
+      'image_style' => array(
+        'table' => 'image_styles',
+        'columns' => array('isid' => 'isid'),
+      ),
     ),
   );
 
@@ -180,7 +183,10 @@ function image_update_7000() {
         'weight' => array('weight'),
       ),
       'foreign keys' => array(
-        'isid' => array('image_styles' => 'isid'),
+        'image_style' => array(
+          'table' => 'image_styles',
+          'columns' => array('isid' => 'isid'),
+        ),
       ),
     );
 
Index: modules/locale/locale.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v
retrieving revision 1.63
diff -u -p -r1.63 locale.install
--- modules/locale/locale.install	17 Aug 2010 22:05:22 -0000	1.63
+++ modules/locale/locale.install	19 Aug 2010 17:36:27 -0000
@@ -335,7 +335,10 @@ function locale_schema() {
     ),
     'primary key' => array('language', 'lid', 'plural'),
     'foreign keys' => array(
-      'lid' => array('locales_source' => 'lid'),
+      'locales_source' => array(
+        'table' => 'locales_source',
+        'columns' => array('lid' => 'lid'),
+      ),
     ),
     'indexes' => array(
       'lid'      => array('lid'),
Index: modules/node/node.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.install,v
retrieving revision 1.52
diff -u -p -r1.52 node.install
--- modules/node/node.install	8 Aug 2010 13:02:37 -0000	1.52
+++ modules/node/node.install	19 Aug 2010 17:36:28 -0000
@@ -118,8 +118,14 @@ function node_schema() {
       'vid' => array('vid'),
     ),
     'foreign keys' => array(
-      'vid' => array('node_revision' => 'vid'),
-      'uid' => array('users' => 'uid'),
+      'node_revision' => array(
+        'table' => 'node_revision',
+        'columns' => array('vid' => 'vid'),
+      ),
+      'node_author' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
     'primary key' => array('nid'),
   );
@@ -174,7 +180,12 @@ function node_schema() {
       ),
     ),
     'primary key' => array('nid', 'gid', 'realm'),
-    'foreign keys' => array('node' => 'nid'),
+    'foreign keys' => array(
+      'affected_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+     ),
   );
 
   $schema['node_revision'] = array(
@@ -249,8 +260,14 @@ function node_schema() {
     ),
     'primary key' => array('vid'),
     'foreign keys' => array(
-      'node' => 'nid',
-      'users' => 'uid'
+      'versioned_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'version_author' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
Index: modules/poll/poll.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.install,v
retrieving revision 1.32
diff -u -p -r1.32 poll.install
--- modules/poll/poll.install	1 Jul 2010 15:09:11 -0000	1.32
+++ modules/poll/poll.install	19 Aug 2010 17:36:28 -0000
@@ -36,7 +36,10 @@ function poll_schema() {
     ),
     'primary key' => array('nid'),
     'foreign keys' => array(
-      'nid' => array('node' => 'nid'),
+      'poll_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
     ),
   );
 
@@ -82,7 +85,10 @@ function poll_schema() {
     ),
     'primary key' => array('chid'),
     'foreign keys' => array(
-      'nid' => array('node' => 'nid'),
+      'choice_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
     ),
   );
 
@@ -124,8 +130,14 @@ function poll_schema() {
     ),
     'primary key' => array('nid', 'uid', 'hostname'),
     'foreign keys' => array(
-      'nid' => array('node' => 'nid'),
-      'uid' => array('users' => 'uid'),
+      'poll_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'voter' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
     'indexes' => array(
       'chid'     => array('chid'),
Index: modules/profile/profile.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.install,v
retrieving revision 1.25
diff -u -p -r1.25 profile.install
--- modules/profile/profile.install	3 Feb 2010 18:16:23 -0000	1.25
+++ modules/profile/profile.install	19 Aug 2010 17:36:28 -0000
@@ -138,8 +138,14 @@ function profile_schema() {
       'fid' => array('fid'),
     ),
     'foreign keys' => array(
-      'fid' => array('profile_field' => 'fid'),
-      'uid' => array('users' => 'uid'),
+      'profile_field' => array(
+        'table' => 'profile_field',
+        'columns' => array('fid' => 'fid'),
+      ),
+      'profile_user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
Index: modules/search/search.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.install,v
retrieving revision 1.28
diff -u -p -r1.28 search.install
--- modules/search/search.install	11 Aug 2010 02:14:23 -0000	1.28
+++ modules/search/search.install	19 Aug 2010 17:36:28 -0000
@@ -85,8 +85,13 @@ function search_schema() {
       'sid_type' => array('sid', 'type'),
     ),
     'foreign keys' => array(
-      'sid' => array('search_dataset' => 'sid'),
-      'type' => array('search_dataset' => 'type'),
+      'search_dataset' => array(
+        'table' => 'search_dataset',
+        'columns' => array(
+          'sid' => 'sid',
+          'type' => 'type',
+        ),
+      ),
     ),
     'primary key' => array('word', 'sid', 'type'),
   );
Index: modules/shortcut/shortcut.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.install,v
retrieving revision 1.5
diff -u -p -r1.5 shortcut.install
--- modules/shortcut/shortcut.install	17 Jun 2010 13:16:57 -0000	1.5
+++ modules/shortcut/shortcut.install	19 Aug 2010 17:36:29 -0000
@@ -63,7 +63,10 @@ function shortcut_schema() {
     ),
     'primary key' => array('set_name'),
     'foreign keys' => array(
-      'set_name' => array('menu_links' => 'menu_name'),
+      'menu_name' => array(
+        'table' => 'menu_links',
+        'columns' => array('set_name' => 'menu_name'),
+      ),
     ),
   );
 
@@ -90,8 +93,14 @@ function shortcut_schema() {
       'set_name' => array('set_name'),
     ),
     'foreign keys' => array(
-      'uid' => array('users' => 'uid'),
-      'set_name' => array('shortcut_set' => 'set_name'),
+      'set_user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
+      'set_name' => array(
+        'table' => 'shortcut_set',
+        'columns' => array('set_name' => 'set_name'),
+      ),
     ),
   );
 
Index: modules/statistics/statistics.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.install,v
retrieving revision 1.26
diff -u -p -r1.26 statistics.install
--- modules/statistics/statistics.install	28 Apr 2010 05:29:55 -0000	1.26
+++ modules/statistics/statistics.install	19 Aug 2010 17:36:29 -0000
@@ -90,7 +90,10 @@ function statistics_schema() {
     ),
     'primary key' => array('aid'),
     'foreign keys' => array(
-      'uid' => array('users' => 'uid'),
+      'visitor' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.185
diff -u -p -r1.185 system.api.php
--- modules/system/system.api.php	17 Aug 2010 13:52:31 -0000	1.185
+++ modules/system/system.api.php	19 Aug 2010 17:36:35 -0000
@@ -2591,6 +2591,16 @@ function hook_schema() {
       'nid_vid' => array('nid', 'vid'),
       'vid'     => array('vid')
       ),
+    'foreign keys' => array(
+      'node_revision' => array(
+        'table' => 'node_revision',
+        'columns' => array('vid' => 'vid'),
+        ),
+      'node_author' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid')
+        ),
+       ),
     'primary key' => array('nid'),
   );
   return $schema;
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.495
diff -u -p -r1.495 system.install
--- modules/system/system.install	17 Aug 2010 22:05:22 -0000	1.495
+++ modules/system/system.install	19 Aug 2010 17:36:39 -0000
@@ -831,7 +831,10 @@ function system_schema() {
     ),
     'primary key' => array('fid'),
     'foreign keys' => array(
-      'uid' => array('users' => 'uid'),
+      'file_owner' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
@@ -1462,7 +1465,10 @@ function system_schema() {
       'ssid' => array('ssid'),
     ),
     'foreign keys' => array(
-      'uid' => array('users' => 'uid'),
+      'session_user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
Index: modules/taxonomy/taxonomy.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.install,v
retrieving revision 1.43
diff -u -p -r1.43 taxonomy.install
--- modules/taxonomy/taxonomy.install	23 May 2010 19:10:23 -0000	1.43
+++ modules/taxonomy/taxonomy.install	19 Aug 2010 17:36:40 -0000
@@ -66,7 +66,10 @@ function taxonomy_schema() {
     ),
     'primary key' => array('tid'),
     'foreign keys' => array(
-      'vid' => array('taxonomy_vocabulary' => 'vid'),
+      'vocabulary' => array(
+        'table' => 'taxonomy_vocabulary',
+        'columns' => array('vid' => 'vid'),
+      ),
     ),
     'indexes' => array(
       'taxonomy_tree' => array('vid', 'weight', 'name'),
@@ -97,7 +100,10 @@ function taxonomy_schema() {
       'parent' => array('parent'),
     ),
     'foreign keys' => array(
-      'tid' => array('taxonomy_term_data' => 'tid'),
+      'taxonomy_term_data' => array(
+        'table' => 'taxonomy_term_data',
+        'columns' => array('tid' => 'tid'),
+      ),
     ),
     'primary key' => array('tid', 'parent'),
   );
@@ -201,8 +207,14 @@ function taxonomy_schema() {
       'nid' => array('nid'),
     ),
     'foreign keys' => array(
-      'node' => 'nid',
-      'taxonomy_term_data' => 'tid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'term' => array(
+        'table' => 'taxonomy_term_data',
+        'columns' => array('tid' => 'tid'),
+      ),
     ),
   );
 
@@ -328,8 +340,14 @@ function taxonomy_update_7004() {
       'nid' => array('nid'),
     ),
     'foreign keys' => array(
-      'node' => 'nid',
-      'taxonomy_term_data' => 'tid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'term' => array(
+        'table' => 'taxonomy_term_data',
+        'columns' => array('tid' => 'tid'),
+      ),
     ),
   );
   db_create_table('taxonomy_index', $taxonomy_index);
Index: modules/tracker/tracker.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/tracker/tracker.install,v
retrieving revision 1.4
diff -u -p -r1.4 tracker.install
--- modules/tracker/tracker.install	20 Mar 2010 15:06:51 -0000	1.4
+++ modules/tracker/tracker.install	19 Aug 2010 17:36:41 -0000
@@ -56,7 +56,10 @@ function tracker_schema() {
     ),
     'primary key' => array('nid'),
     'foreign keys' => array(
-      'node' => 'nid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
     ),
   );
 
@@ -96,8 +99,14 @@ function tracker_schema() {
     ),
     'primary key' => array('nid', 'uid'),
     'foreign keys' => array(
-      'node' => 'nid',
-      'users' => 'uid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'tracked_user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
@@ -143,7 +152,10 @@ function tracker_update_7000() {
     ),
     'primary key' => array('nid'),
     'foreign keys' => array(
-      'node' => 'nid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
     ),
   );
 
@@ -183,8 +195,14 @@ function tracker_update_7000() {
     ),
     'primary key' => array('nid', 'uid'),
     'foreign keys' => array(
-      'node' => 'nid',
-      'users' => 'uid',
+      'tracked_node' => array(
+        'table' => 'node',
+        'columns' => array('nid' => 'nid'),
+      ),
+      'tracked_user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
Index: modules/trigger/trigger.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.install,v
retrieving revision 1.16
diff -u -p -r1.16 trigger.install
--- modules/trigger/trigger.install	4 Dec 2009 16:49:47 -0000	1.16
+++ modules/trigger/trigger.install	19 Aug 2010 17:36:41 -0000
@@ -36,7 +36,10 @@ function trigger_schema() {
     ),
     'primary key' => array('hook', 'aid'),
     'foreign keys' => array(
-      'aid' => array('actions' => 'aid'),
+      'action' => array(
+        'table' => 'actions',
+        'columns' => array('aid' => 'aid'),
+      ),
     ),
   );
   return $schema;
Index: modules/user/user.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.install,v
retrieving revision 1.56
diff -u -p -r1.56 user.install
--- modules/user/user.install	11 Aug 2010 01:49:41 -0000	1.56
+++ modules/user/user.install	19 Aug 2010 17:36:41 -0000
@@ -45,7 +45,10 @@ function user_schema() {
     ),
     'primary key' => array('aid'),
     'foreign keys' => array(
-      'uid' => array('users' => 'uid'),
+      'user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
     ),
   );
 
@@ -78,7 +81,10 @@ function user_schema() {
       'permission' => array('permission'),
     ),
     'foreign keys' => array(
-      'rid' => array('role' => 'rid'),
+      'role' => array(
+        'table' => 'roles',
+        'columns' => array('rid' => 'rid'),
+      ),
     ),
   );
 
@@ -236,7 +242,10 @@ function user_schema() {
     ),
     'primary key' => array('uid'),
     'foreign keys' => array(
-      'signature_format' => array('filter_format' => 'format'),
+      'signature_format' => array(
+        'table' => 'filter_format',
+        'columns' => array('signature_format' => 'format'),
+      ),
     ),
   );
 
@@ -263,8 +272,14 @@ function user_schema() {
       'rid' => array('rid'),
     ),
     'foreign keys' => array(
-      'uid' => array('users' => 'uid'),
-      'rid' => array('role' => 'rid'),
+      'user' => array(
+        'table' => 'users',
+        'columns' => array('uid' => 'uid'),
+      ),
+      'role' => array(
+        'table' => 'roles',
+        'columns' => array('rid' => 'rid'),
+      ),
     ),
   );
 
