0

I have a simple 'form_example' module and I want to add a database table when instaling module. I created this form_example.install file:

<?php

function form_example_schema() {
    $schema['form_example_table'] = array(
        'description' => 'Table for form_pokus module',
        'fields' => array(
            'id'        => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
            'name'      => array('type' => 'varchar','length' => 30,     'not null' => TRUE, 'default' => ''),
            'gender'    => array('type' => 'varchar','length' => 30,     'not null' => TRUE, 'default' => ''),
            'message'   => array('type' => 'text', 'not null' => TRUE,   'default'  => ''),
            'status'    => array('type' => 'text', 'not null' => FALSE ),
            'created'   => array('type' => 'int',  'not null' => TRUE,   'default'  => 0),          
        ),

        'primary key' => array('id'),

    );

    return $schema;
}

I disabled this module, then deleted it from directory, flushed all chaches and then installed and enabled again this module, now with .install file. But new table is not appearing in database. Im using PostgresSQL. What I am missing?

4
  • Drupal 7? Did you uninstall module after disabling it?
    – sanzante
    Commented Apr 8, 2015 at 8:19
  • Yes, I did uninstall module after disabling by deleting module folder and flushing cache and yes, it is Drupal 7.
    – Axel Stone
    Commented Apr 8, 2015 at 8:24
  • 1
    But you need to explicitly unisntall module using Drupal GUI, not disbling and deleting module folder but disabling and uninstalling the module. Have you donde that?
    – sanzante
    Commented Apr 8, 2015 at 8:30
  • You are right, this solved my problem. Btw. after uninstalling module by Drupal GUI module is not disappearing from module list and module folder is still there. This is expected behavior?
    – Axel Stone
    Commented Apr 8, 2015 at 8:36

1 Answer 1

0

Follow the standard procedure to unisntall a module.

In short, once the module is disabled it may appear in the Uninstall tab of the modules page. Select the module in that tab and click 'Uninstall'.

When you disable a module its configuration and tables are kept, so if you enable again all data and configuration remains the same. When you uninstall a module you tell Drupal to wipe out any configuration and data by that module. When enabling it again Drupal detects that there's no configuration nor tables of that module and creates them again. If you only disable the module and enable it Drupal doesn't create configuration and tables because they should be in the database,m as Drupal knows module was enabled once.

In module list you have the available modules, some them enabled and some them disabled. If oyu want to comnpletely remove a module you have to disable, uninstall and delete the folder manually.

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.