/**
  * Migrate custom rules for the given field
  *
  * @param EditableFormField $field
  * @param string $stage
  */
 protected function migrateRules(EditableFormField $field, $stage)
 {
     $rulesData = $field->CustomRules ? unserialize($field->CustomRules) : array();
     // Skip blank rules or fields with custom rules already
     if (empty($rulesData) || $field->DisplayRules()->count()) {
         return;
     }
     // Check value of this condition
     foreach ($rulesData as $ruleDataItem) {
         if (empty($ruleDataItem['ConditionOption']) || empty($ruleDataItem['Display'])) {
             continue;
         }
         // Get data for this rule
         $conditionOption = $ruleDataItem['ConditionOption'];
         $display = $ruleDataItem['Display'];
         $conditionFieldName = empty($ruleDataItem['ConditionField']) ? null : $ruleDataItem['ConditionField'];
         $value = isset($ruleDataItem['Value']) ? $ruleDataItem['Value'] : null;
         // Create rule
         $rule = $this->findOrCreateRule($field, $stage, $conditionOption, $display, $conditionFieldName, $value);
         $this->log("Upgrading rule ID = " . $rule->ID);
     }
 }