'blog', 'name' => st('Blog entry'), 'base' => 'node_content', 'description' => st("Use for multi-user blogs. Every user gets a personal blog."), 'custom' => 1, 'modified' => 1, 'locked' => 0, ); $type = node_type_set_defaults($type); node_type_save($type); } /** * Implement hook_schema(). */ function blog_schema() { $schema['blog'] = array( 'description' => 'Stores the relationship of nodes to a user\'s blog.', 'fields' => array( 'nid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The ID of a node to be listed in the blog.', ), 'created' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'When the blog post was created.', ), ), 'indexes' => array( 'nid' => array('nid'), 'created' => array('created'), ), 'primary key' => array('nid'), 'foreign keys' => array( 'nid' => array('node' => 'nid'), 'created' => array('node' => 'created'), ), ); return $schema; } /** * Update function to upate the schema when upgrading to Drupal 7. */ function blog_update_7000() { $schema['blog'] = array( 'description' => 'Stores the relationship of nodes to a user\'s blog.', 'fields' => array( 'nid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The ID of a node to be listed in the blog.', ), 'created' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'When the blog post was created.', ), ), 'indexes' => array( 'nid' => array('nid'), 'created' => array('created'), ), 'primary key' => array('nid'), 'foreign keys' => array( 'nid' => array('node' => 'nid'), 'created' => array('node' => 'created'), ), ); // Create blog table db_create_table($ret, 'blog', $schema['blog']); // insert the blog data into the newly created blog table. $posts = db_query("SELECT nid, created FROM {node} n WHERE n.type = :type", array( ':type' => 'blog', )); foreach ($posts as $post) { db_insert('blog') ->fields(array( 'nid' => $post->nid, 'created' => $post->created, )) ->execute(); } // Change the module type of blogs from "blog" to "node". db_update('node_type') ->fields(array( 'module' => 'node', )) ->condition('module', 'blog') ->execute(); }