Esempio n. 1
0
 public static function import($table)
 {
     $colums = new StructureBag();
     $indexs = new StructureBag();
     foreach ($table['columns'] as $colum) {
         $colums->append(Column::import($colum));
     }
     foreach ($table['indexs'] as $index) {
         $indexs->append(Index::import($index));
     }
     return new static($table['name'], $colums, $indexs, $table['options']);
 }
Esempio n. 2
0
 public static function create(DatabaseInterface $database, $name)
 {
     $colums = new StructureBag();
     $indexs = new StructureBag();
     $options = array();
     foreach ($database->getRawColumns($name) as $rawColumn) {
         $colums->append(Column::createUsingRawData($rawColumn));
     }
     foreach (Index::mergeRawIndexs($database->getRawIndexs($name)) as $rawIndex) {
         $indexs->append(Index::createUsingRawData($rawIndex));
     }
     foreach ($database->getRawOptions($name) as $rawOptionName => $rawOptionValue) {
         switch ($rawOptionName) {
             case 'Engine':
             case 'Collation':
                 $options[lcfirst(Str::convertCamel($rawOptionName))] = $rawOptionValue;
                 break;
             default:
                 // Ignore other options
         }
     }
     return new static($name, $colums, $indexs, $options);
 }