Answers.Body: <p>Resolved. I found the code that was inserting the sample data. It was first pulling from option_group where name=case_type. For some reason my database did not have this row - so the subsequent line inserting into option_value with the retrieved id of the option_group row failed.</p>
  
  <p>I manually inserted a row into option_group with name of case_type. (I used "Case Type" for both title and description and set the is_active column and is_reserved column to 1 and is_locked to 0.</p>
  
  <p>This got rid of the error.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-16T18:45:16.223Z
Answers.LastActivityDate: 2015-11-16T18:45:16.223Z
Answers.UserDisplayName: Jay
Body: <p>I'm running civicrm 4.4.20 on the latest Joomla 3.4.5. When I try to enable CiviCase I get an database constraint error (see below). </p>
  
  <pre><code>[code] =&gt; -3
      [message] =&gt; DB Error: constraint violation
      [mode] =&gt; 16
      [debug_info] =&gt; 
        INSERT INTO `CIVICRM_OPTION_VALUE` (
          `option_group_id`, `label`, `value`, `name`,
          `grouping`, `filter`, `is_default`, `weight`,
          `description`, `is_optgroup`, `is_reserved`, `is_active`
        ) (
          SELECT 
            @option_group_id_case_type, 'Housing Support', @max_val + 1, 'housing_support', 
            NULL, 0, 0, @max_wt + 1, 
            'Help homeless individuals obtain temporary and long-term housing', 0, 0, 1
           FROM   DUAL
           WHERE  NOT EXISTS (SELECT command.plist infoShowed
                              FROM   `CIVICRM_OPTION_VALUE`
                              WHERE  `name` = 'housing_support')
        )
      [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`xxx_joomla`.`civicrm_option_value`, CONSTRAINT `FK_civicrm_option_value_option_group_id` FOREIGN KEY (`option_group_id`) REFERENCES `civicrm_option_group` (`id`) ON DELETE CASCADE)]
      [type] =&gt; DB_Error
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-16T17:28:30.890Z
Comments.Text: Apparently when you enable civicase sample data is inserted. For some reason its failing on my install. The foreign key set up seems ok. It almost seems like the install is inserting into option_value before it inserts into option_group?
Comments.UserDisplayName: Jay
Tags: <civicase><database>
Title: Database constraint error on enabling CiviCase
ThreadText: # Database constraint error on enabling CiviCase
  
  (Asked by: username_0 on 2015-11-16)
  
  I'm running civicrm 4.4.20 on the latest Joomla 3.4.5. When I try to enable CiviCase I get an database constraint error (see below).
  
  ```
  [code] => -3
      [message] => DB Error: constraint violation
      [mode] => 16
      [debug_info] => 
        INSERT INTO `CIVICRM_OPTION_VALUE` (
          `option_group_id`, `label`, `value`, `name`,
          `grouping`, `filter`, `is_default`, `weight`,
          `description`, `is_optgroup`, `is_reserved`, `is_active`
        ) (
          SELECT 
            @option_group_id_case_type, 'Housing Support', @max_val + 1, 'housing_support', 
            NULL, 0, 0, @max_wt + 1, 
            'Help homeless individuals obtain temporary and long-term housing', 0, 0, 1
           FROM   DUAL
           WHERE  NOT EXISTS (SELECT command.plist infoShowed
                              FROM   `CIVICRM_OPTION_VALUE`
                              WHERE  `name` = 'housing_support')
        )
      [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`xxx_joomla`.`civicrm_option_value`, CONSTRAINT `FK_civicrm_option_value_option_group_id` FOREIGN KEY (`option_group_id`) REFERENCES `civicrm_option_group` (`id`) ON DELETE CASCADE)]
      [type] => DB_Error
  
  ```
  
  **Tags:** civicase, database
  
  > **Comments:**
  > **username_0**: Apparently when you enable civicase sample data is inserted. For some reason its failing on my install. The foreign key set up seems ok. It almost seems like the install is inserting into option_value before it inserts into option_group?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-11-16. Score: 1
  
  Resolved. I found the code that was inserting the sample data. It was first pulling from option\_group where name=case\_type. For some reason my database did not have this row - so the subsequent line inserting into option\_value with the retrieved id of the option\_group row failed.
  
  I manually inserted a row into option\_group with name of case\_type. (I used "Case Type" for both title and description and set the is\_active column and is\_reserved column to 1 and is\_locked to 0.
  
  This got rid of the error.
  
  
  ---
  
  