Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-8849

civicrm_member_roles_rules table is not created when CiviMembers Roles Sync module is installed

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.5
    • Fix Version/s: 3.4.6
    • Component/s: CiviMember
    • Labels:
      None

      Description

      When accessing the CiviMember Roles Sync module or attempting to create an Association Rule, I get this error:

      user warning: Table 'civicrm-drupal.civicrm_member_roles_rules' doesn't exist query: SELECT * FROM civicrm_member_roles_rules ORDER BY rule_id ASC in /mnt/data-store/www/civcrm/wwwroot/sites/all/modules/civicrm/drupal/modules/civicrm_member_roles/civicrm_member_roles.module on line 133.

      Attempting to create the table manually from the schema defined in the module install file fails. The problem appears to be related to the definition of the rule_id field. Here's the schema:

      $schema['civicrm_member_roles_rules'] = array(
      'fields' => array(
      'rule_id' => array(
      'type' => 'serial',
      'unsigned' => TRUE,
      'not null' => TRUE,
      ),
      'rid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      ),
      'type_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      ),
      'status_codes' => array(
      'type' => 'text',
      'not null' => TRUE,
      ),
      ),
      'primary key' => array('rule_id'),
      );

      Here's the cause and suggested resolution:

      CREATE TABLE fails on the definition of rule_id field when type=serial and the attribute unsigned=true is defined. If I remove the unsigned=true attribute, the create table operation performs properly.

      According to MySQL website: SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE. (http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html [nofollow])

      So it appears that defining the unsigned attribute is redundant. It probably alos the case tha using an unsigned bigint value for this field is unnecessary, given what is being stored. I would recommend changing it to an INT UNSIGNED instead of SERIAL.

      $schema['civicrm_member_roles_rules'] = array(
      'fields' => array(
      'rule_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      ),
      'rid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      ),
      'type_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      ),
      'status_codes' => array(
      'type' => 'text',
      'not null' => TRUE,
      ),
      ),
      'primary key' => array('rule_id'),
      );

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              epmcl Ed McLaughlin
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 1 hour
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified