function node_update_7000

Upgrade the node type table and fix node type 'module' attribute to avoid name-space conflicts.

Related topics

File

modules/node/node.install, line 512

Code

function node_update_7000() {
    // Rename the module column to base.
    db_change_field('node_type', 'module', 'base', array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
    ));
    db_add_field('node_type', 'module', array(
        'description' => 'The module defining this node type.',
        'type' => 'varchar',
        'default' => '',
        'length' => 255,
        'not null' => TRUE,
    ));
    db_add_field('node_type', 'disabled', array(
        'description' => 'A boolean indicating whether the node type is disabled.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
    ));
    $modules = db_select('system', 's')->fields('s', array(
        'name',
    ))
        ->condition('type', 'module');
    db_update('node_type')->expression('module', 'base')
        ->condition('base', $modules, 'IN')
        ->execute();
    db_update('node_type')->fields(array(
        'base' => 'node_content',
    ))
        ->condition('base', 'node')
        ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.