diff --git a/core/modules/node/node.install b/core/modules/node/node.install index ac777f3..dfc8edf 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -139,6 +139,25 @@ function node_schema() { 'primary key' => array('nid'), ); + $schema['node_property_data'] = $schema['node']; + $schema['node_property_data']['description'] = 'Base table for node properties.'; + + $schema['node_property_data']['primary key'] = array('nid', 'vid', 'langcode'); + + $schema['node_property_data_revision'] = $schema['node_property_data']; + $schema['node_property_data_revision']['description'] = 'Revision table for node properties.'; + $schema['node_property_data_revision']['foreign keys'] = array( + 'versioned_node' => array( + 'table' => 'node', + 'columns' => array('nid' => 'nid'), + ), + 'version_author' => array( + 'table' => 'users', + 'columns' => array('uid' => 'uid'), + ), + ); + + $schema['node_access'] = array( 'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.', 'fields' => array( @@ -663,6 +682,35 @@ function node_update_8005() { ); } + /** + * Add dedicated tables for node properties. + */ +function node_update_8009() { + $schema = node_schema(); + // Create property table if necessary. + if (!db_table_exists('node_property_data')) { + db_create_table('node_property_data', $schema['node_property_data']); + } + // Create initial data set if necessary. + if (db_table_exists('node_property_data') && db_select('node_property_data')->countQuery()->execute()->fetchColumn() == 0) { + // Manually set fields as auto discover doesn't seem to work. + $source_query = db_select('node') + ->fields('node', array_keys($schema['node']['fields'])); + db_insert('node_property_data')->from($source_query)->execute(); + } + // Create property revision table if necessary. + if (!db_table_exists('node_property_data_revision')) { + db_create_table('node_property_data_revision', $schema['node_property_data_revision']); + } + // Create initial data set if necessary. + if (db_table_exists('node_property_data_revision') && db_select('node_property_data_revision')->countQuery()->execute()->fetchColumn() == 0) { + // Manually set fields as auto discover doesn't seem to work. + $source_query = db_select('node_property_data') + ->fields('node_property_data', array_keys($schema['node_property_data']['fields'])); + db_insert('node_property_data_revision')->from($source_query)->execute(); + } +} + /** * @} End of "addtogroup updates-7.x-to-8.x" * The next series of updates should start at 9000.