/**
  * create a list of tables and fields that need to be checked
  * see class comments
  */
 function requireDefaultRecords()
 {
     self::$file_classes = ClassInfo::subclassesFor("File");
     parent::requireDefaultRecords();
     //start again
     DB::query("DELETE FROM \"MetaTagCMSControlFileUse\";");
     //get all classes
     $allClasses = ClassInfo::subclassesFor("DataObject");
     //classes from sitetree are linked through image tracker
     $siteTreeSubclasses = ClassInfo::subclassesFor("SiteTree");
     // files can have files attached to them so we have commented out the line below
     //$allClassesExceptFiles = array_diff($allClasses, $fileClasses);
     //lets go through class
     foreach ($allClasses as $class) {
         if (!in_array($class, $siteTreeSubclasses)) {
             //DB
             $dbArray = null;
             //get the has_one fields
             $newItems = (array) Config::inst()->get($class, 'db');
             // Validate the data
             //do we need this?
             $dbArray = $newItems;
             //isset($hasOneArray) ? array_merge($newItems, (array)$hasOneArray) : $newItems;
             //lets inspect
             if ($dbArray && count($dbArray)) {
                 foreach ($dbArray as $fieldName => $fieldType) {
                     if ($fieldType == "HTMLText") {
                         $this->createNewRecord($class, $fieldName, "", "DB");
                     }
                 }
             }
         }
         //HAS_ONE
         $hasOneArray = null;
         //get the has_one fields
         $newItems = (array) Config::inst()->get($class, 'has_one');
         // Validate the data
         //do we need this?
         $hasOneArray = $newItems;
         //isset($hasOneArray) ? array_merge($newItems, (array)$hasOneArray) : $newItems;
         //lets inspect
         if ($hasOneArray && count($hasOneArray)) {
             foreach ($hasOneArray as $fieldName => $hasOneClass) {
                 $this->createNewRecord($class, $fieldName, $hasOneClass, "HAS_ONE");
             }
         }
         //HAS_MANY
         $hasManyArray = null;
         $newItems = (array) Config::inst()->get($class, 'has_many');
         // Validate the data
         $hasManyArray = $newItems;
         //isset($hasManyArray) ? array_merge($newItems, (array)$hasManyArray) : $newItems;
         if ($hasManyArray && count($hasManyArray)) {
             foreach ($hasManyArray as $fieldName => $hasManyClass) {
                 //NOTE - We are referencing HAS_ONE here on purpose!!!!
                 $hasManyCheckItems = (array) Config::inst()->get($class, 'has_one');
                 $hasManyFound = false;
                 foreach ($hasManyCheckItems as $hasManyfieldName => $hasManyForeignClass) {
                     if ($hasManyForeignClass == $class) {
                         $this->createNewRecord($hasManyClass, $hasManyfieldName, $hasManyForeignClass, "HAS_ONE");
                         $hasManyFound = true;
                     }
                 }
                 //now we have to guess!
                 if (!$hasManyFound) {
                     $this->createNewRecord($hasManyClass, $class, $class, "HAS_ONE");
                     $hasManyFound = true;
                 }
             }
         }
         //many many
         $manyManyArray = null;
         $newItems = (array) Config::inst()->get($class, 'many_many');
         $manyManyArray = $newItems;
         //belongs many many
         $newItems = (array) Config::inst()->get($class, 'belongs_many_many');
         $manyManyArray = isset($manyManyArray) ? array_merge($newItems, $manyManyArray) : $newItems;
         //do both
         if ($manyManyArray && count($manyManyArray)) {
             foreach ($manyManyArray as $fieldName => $manyManyClass) {
                 $this->createNewRecord($class, $fieldName, $manyManyClass, "MANY_MANY");
                 $this->createNewRecord($manyManyClass, $fieldName, $class, "BELONGS_MANY_MANY");
             }
         }
     }
 }