Commit db536802 authored by Dries's avatar Dries

- Patch #880132 by bojanz: hook_schema() doesn't support compound foreign...

- Patch #880132 by bojanz: hook_schema() doesn't support compound foreign keys; inconsistent implementations in core.
parent 39d67044
......@@ -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'),
* );
......
......@@ -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'),
),
),
);
......
......@@ -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',
),
),
),
);
......
......@@ -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);
......
......@@ -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'),
),
),
);
......
......@@ -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'),
......
......@@ -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'),
),
),
);
......
......@@ -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'),
......
......@@ -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'),
),
),
);
......
......@@ -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'),
);
......
......@@ -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'),
),
),
);
......
......@@ -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'),
),
),
);
......
......@@ -2566,6 +2566,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;
......
......@@ -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'),
),
),
);
......@@ -1508,7 +1511,10 @@ function system_schema() {
'ssid' => array('ssid'),
),
'foreign keys' => array(
'uid' => array('users' => 'uid'),
'session_user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
......
......@@ -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);
......
......@@ -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'),
),
),
);
......
......@@ -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;
......
......@@ -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'),
),
),
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment