I am working on a pre-created Drupal 8 project that has a custom module called CCA(named out of project title). I have done the below update in the .install file to add a new column to the backend via Drupal.

function cca_update_8902 (&$sandbox) {
  db_add_field('cca_findings', 'cca_topic_id', array(
    'type' => 'float',
    'not null' => FALSE,
    'description' => 'interim fields addition',

How do I update the module in Drupal after this change has been made? Can someone guide on next steps to update my custom module in Drupal so that this change will be implemented? Thanks!

1 Answer 1


Visit /update.php on your site when logged in as admin, or use drush updatedb

Note that in addition to changing the table in the hook_update_N(), you must also change the schema of the cca_findings table in hook_schema() so that new installs of your module will have the proper table structure. Update functions are not used on new installs of your module.

  • Thanks a lot. Any example of changing hook_schema() please?
    – Rick
    Commented Nov 29, 2020 at 22:26
  • 1
    The table is already defined in hook_schema(), right? It would have to be if this is a custom table for your custom module. If you look at the existing schema then it should be obvious how to define the new column - something like: 'cca_topic_id' => array( 'type' => 'float', 'not null' => FALSE, 'description' => 'interim fields addition', );
    – anonymous
    Commented Nov 29, 2020 at 22:33
  • Yeah, the table is already defined in the schema. I am just adding additional column to it. In that case can I just skip this step?
    – Rick
    Commented Nov 30, 2020 at 12:35
  • Thanks! The accepted solutin worked perfecttly for me.
    – Rick
    Commented Nov 30, 2020 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.