1

I have written this schema for creating 2 tables in my custom module.install

    <?php
function my_registration_form_schema() {
    $schema = array();

 $schema['myuser'] = array
(
      'description' => t('The table containing users who have signed up for the chance to register.'),
      'fields' => array
        (
        'id' => array
        (
        'description' => t('Primary Key ID'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        ),
      'first_name' => array
        (
        'description' => t('User\'s First Name'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        ),
      'last_name' => array
        (
        'description' => t('User\'s Last Name'),
        'type' => 'varchar',
        'length' => 255,
        ),    
        'email_address' => array
        (
        'description' => t('User\'s Email Address'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        ),
        'user_country' => array
        (
        'description' => t('Country name of user'),
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        ),
        'user_city' => array
        (
        'description' => t('City name of user'),
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
        ),
      'address' => array
      (
        'description' => t('User address'),
        'type' => 'varchar',
        'length'=>600,
        'not null' => TRUE,
      ),
      'gender' => array
      (
        'description' => t('User gender'),
        'type' => 'varchar',
        'length'=>10,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array( 'id' ),
);



    $schema['userdata'] = array
    (
      'description' => t('The table containing additional data about user.'),
      'fields' => array
      (
        'id' => array
        (
        'description' => t('Primary Key ID'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        ),
      'subscribe' => array
      (
        'description' => t('User Subscription'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'dob' => array
      (
        'description' => t('User date of birth'),
        'type' => 'varchar',
        'length'=>15,
        'not null'=>TRUE,
      ),
      ),
        'primary key' => array( 'id' ),

    );

  // Return the Table Schema
  return $schema;
}

When I had only one table, myuser, it was working good. Now Its not.. What is wrong with code. Please Help

8
  • try without $schema = array(); in your line 3, to see what will happen...
    – mixerowsky
    Commented Oct 27, 2015 at 22:07
  • What exactly doesn't work? How it supposed to work? Commented Oct 27, 2015 at 22:36
  • @mixerowsky - Tried removing that.. but did not work Commented Oct 27, 2015 at 22:55
  • @ŁukaszZaroda - Actually when i install this module, only first table is getting created in my db. Second one not created Commented Oct 27, 2015 at 22:56
  • 1
    Try uninstalling the module (not just disabling) and installing it again?
    – argiepiano
    Commented Oct 27, 2015 at 23:26

0

Your Answer

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

Browse other questions tagged or ask your own question.