Hi Drupal Experts Greetings of the day!!!
I am relatively new to Drupal 7.
I am facing a strange issue. Want to create a table during install of my module. My install file looks as below. My custom module name is resmsubmt. I have tried several hours (with clearing cache etc..), only 1 time I saw the table was created. I deleted that table manually (using phpmyadmin and sql statement). After that I cleared cache, tried with different table names , always I find the table is not created after installing and enabling my module. Drupal shows module is installed successfully, I enable the module, I do not get any error, then why table is not getting created?
Did anybody face this problem anytime? Please let me know what could be the issue here?
--------------------- resmsubmt.install file --------------------------------
<?php function resmsubmt_schema() { $schema['res_sbmt'] = array( 'description' => 'The base tables for resume submission.', 'fields' => array( 'uid' => array( 'description' => 'Id of candidate.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'name' => array( 'description' => 'Name of candidate.', 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', ), ), 'primary key' => array('uid'), );
return $schema; }
function resmsubmt_uninstall() { drupal_uninstall_schema('resmsubmt'); db_query("DROP TABLE res_sbmt"); cache_clear_all('variables', 'cache'); }
Regards Kamal Necs
In Drupal 7, you need not to use the statement "db_query("DROP TABLE res_sbmt");" apart from this, if you are only using hook_install and hook_uninstall to remove schema, please dont implement that, in D7 it does of its own :).
On Wed, Aug 8, 2012 at 7:35 AM, Kamal Palei palei.kamal@gmail.com wrote:
Hi Drupal Experts Greetings of the day!!!
I am relatively new to Drupal 7.
I am facing a strange issue. Want to create a table during install of my module. My install file looks as below. My custom module name is resmsubmt. I have tried several hours (with clearing cache etc..), only 1 time I saw the table was created. I deleted that table manually (using phpmyadmin and sql statement). After that I cleared cache, tried with different table names , always I find the table is not created after installing and enabling my module. Drupal shows module is installed successfully, I enable the module, I do not get any error, then why table is not getting created?
Did anybody face this problem anytime? Please let me know what could be the issue here?
--------------------- resmsubmt.install file
<?php function resmsubmt_schema() { $schema['res_sbmt'] = array( 'description' => 'The base tables for resume submission.', 'fields' => array( 'uid' => array( 'description' => 'Id of candidate.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'name' => array( 'description' => 'Name of candidate.', 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', ), ), 'primary key' => array('uid'), );
return $schema; }
function resmsubmt_uninstall() { drupal_uninstall_schema('resmsubmt'); db_query("DROP TABLE res_sbmt"); cache_clear_all('variables', 'cache'); }
Regards Kamal Necs
-- [ Drupal support list | http://lists.drupal.org/ ]
If you don't UNinstall the module, it will not completely re-install. Also, uninstall will delete the table, you don't have to do it manually.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Kamal Palei
I am facing a strange issue. Want to create a table during install of my module. My install file looks as below. My custom module name is resmsubmt. I have tried several hours (with clearing cache etc..), only 1 time I saw the table was created. I deleted that table manually (using phpmyadmin and sql statement). After that I cleared cache, tried with different table names , always I find the table is not created after installing and enabling my module. Drupal shows module is installed successfully, I enable the module, I do not get any error, then why table is not getting created?
Thanks Nancy, Vaibhav I did uninstall and again installed the custom module, it created table as expected.
Regards Kamal NECS
On 8/8/12, Ms. Nancy Wichmann nan_wich@bellsouth.net wrote:
If you don't UNinstall the module, it will not completely re-install. Also, uninstall will delete the table, you don't have to do it manually.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Kamal Palei
I am facing a strange issue. Want to create a table during install of my module. My install file looks as below. My custom module name is resmsubmt. I have tried several hours (with clearing cache etc..), only 1 time I saw the table was created. I deleted that table manually (using phpmyadmin and sql statement). After that I cleared cache, tried with different table names , always I find the table is not created after installing and enabling my module. Drupal shows module is installed successfully, I enable the module, I do not get any error, then why table is not getting created?