0

I am new to drupal, working on custom module, here is my .install file code, but its not creating table in database when I install module. can anyone please tell me where I am wrong

<?php
    function make_application_schema()
    {
        $schema['make_master'] = array(

     'description' => 'Make master table',
     'fields' => array(
       'make_id' => array(
        'description' => 'make id primary key auto increment',
        'type' => 'serial',
        'not null' => TRUE,
       ),
      'make_name' => array(
        'description' => 'Make name',
        'type' => 'varchar',
        'length' => '100',
        'not null' => TRUE,
     ),
    'make_status' => array(
      'description' => 'check make status',
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
    ),
  ),
  'primary key' => array('make_id'),
);
return $schema;
}

  function make_application_install()
  {

  }

  function make_application_uninstall()
  {

  }
1
  • I have find and fix issue I change name of functions where I am using "make_application" remove "application" from all 3 functions Commented Jul 14, 2015 at 6:18

3 Answers 3

1

What is the name of your module? When you are installing and you use hook_schema, you should name your function like this:

my_module.module

In my_module.install

function my_module_schema () ....

And... after that, this should be work :)

Sign up to request clarification or add additional context in comments.

Comments

1

In order to install your database 'make_master' you have to call drupal_install_schema with your module name:

drupal_install_schema('make_application');

1 Comment

This is now a discouraged practice in Drupal 7 (see api.drupal.org/api/drupal/includes%21common.inc/function/…)
0

according to your question I think you have forgot to call drupal_install_schema function. Here are updated make_application_install and make_application_uninstall of your make_application.install.

function make_application_install() {
// Use schema API to create database table.
   drupal_install_schema('make_master');
}


function make_application_uninstall() {
// Remove tables.
   drupal_uninstall_schema('make_master');
}

NOTE
The tables won't install on module enable, they will only install on first-time install. First, disable the module, then click the 'uninstall' tab, select the module, and uninstall it (note: if your module doesn't have a hook_uninstall() function, it won't appear here - make sure you have added this function). Then, click the list tab, and re-enable your module. This is a first-time install, and the tables will install.

Either that or use the devel module, enable the development block and then use the 'reinstall modules' link in the block.

You can refer this link for more info : https://www.drupal.org/node/811594

1 Comment

Thank you, I have add that 2 lines in install & uninstall function and follow the same way for disabled and uninstall module. But still its not working

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.