Change / Increase the node title length I want to increase the node title length on Drupal 7, and as I guess I need to do just two things (theoretically).


Change the title column in the node table to acept more than 255 characters.
Alter the node creating/editing form to let the title field accept more than 255 characters.


I've done, #2 and trying to get #1 using this code:

/**
 * Implements hook_schema_alter().
 */
function my_module_schema_alter(&amp;$schema){
    if(isset($schema['node'])){
        dsm($schema['node']);
        $schema['node']['fields']['title'] = array(
            'type' =&gt; 'varchar',
            'length' =&gt; 555,
            'not null' =&gt; TRUE,
            'default' =&gt; '',
        );
        dsm($schema['node']);
    }
}


If I check dsm() before and after, I can see a change, but I don't see the title column in the node table affected. Am I missing something or using the bad hook?

I also use this code to change the form on creating/editing nodes (this works well):

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&amp;$form, &amp;$form_state, $form_id){
    if($form['#id'] == 'norma-node-form'){
        $form['title']['#type'] = 'textarea';
        $form['title']['#maxlength'] = 555;
    }
}
When you are implementing hook_schema_alter(), the table's schema is not changed.
You are informing the modules calling drupal_get_schema() (which is then called by functions such as drupal_write_record()) what the actual schema is. If you altered a database table without implementing hook_schema_alter(), the functions/modules using drupal_get_schema() would get the schema implemented by the module using that database table, which is not anymore the one describing the database table.

You need to first alter the existing database table using db_change_field(), taking in consideration the following note:


  IMPORTANT NOTE: To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field.