Пример #1
0
 public function inline(MidataIndex $index)
 {
     // CREATE TABLE `books` (
     //   `book_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
     //   `name` varchar(250) COLLATE utf8_polish_ci DEFAULT 'no name',
     //   `format_id` int(10) unsigned DEFAULT NULL,
     //   `release_date` date DEFAULT NULL,
     //   PRIMARY KEY (`book_id`),
     //   UNIQUE KEY `unique_books_name` (`name`),
     //   KEY `books_format` (`format_id`),
     //   KEY `key_books_name` (`name`,`format_id`),
     //   CONSTRAINT `books_format` FOREIGN KEY (`format_id`) REFERENCES `dictionary_values` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
     // ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci
     $indexName = $index->name();
     $columns = $this->implode($index->columns());
     $type = $index->type();
     $sql = "{$type} `{$indexName}` ({$columns})";
     return $sql;
 }
Пример #2
0
 /**
  * Generate subpart of raport for indexes of table.
  *
  * @param string $table
  * @return array
  */
 private function diffIndexes($table)
 {
     $sourceTable = $this->adapter('source')->table($table);
     $targetTable = $this->adapter('target')->table($table);
     $sourceIndexes = $sourceTable->indexes();
     $targetIndexes = $targetTable->indexes();
     $baseDiff = $this->baseDiff($sourceIndexes, $targetIndexes);
     $diff = $baseDiff['diff'];
     $status = $baseDiff['status'];
     foreach ($diff as $index => &$diffIndex) {
         if ($diffIndex['status'] != self::NO_CHANGE) {
             continue;
         }
         $sourceIndex = $sourceTable->index($index);
         $targetIndex = $targetTable->index($index);
         foreach (Index::allAttributes() as $attribute) {
             $sourceAttribute = $sourceIndex->{$attribute}();
             $targetAttribute = $targetIndex->{$attribute}();
             if ($sourceAttribute == Column::NOT_SUPPORTED || $targetAttribute == Column::NOT_SUPPORTED) {
                 continue;
             }
             if ($sourceAttribute !== $targetAttribute) {
                 $diffIndex['status'] = $status = self::CHANGED;
                 $diffIndex['diff'][$attribute] = array('source' => $sourceAttribute, 'target' => $targetAttribute);
             }
         }
     }
     return array('diff' => $diff, 'status' => $status);
 }