Пример #1
0
 protected function getTableSchema(TableInterface $table)
 {
     $columns = $table->getColumns();
     $builder = new SchemaBuilder($table->getDisplayName());
     foreach ($columns as $column => $type) {
         $type = ($type >> 20 & 0xff) << 20;
         switch ($type) {
             case TableInterface::TYPE_SMALLINT:
             case TableInterface::TYPE_INT:
                 $builder->integer($column);
                 break;
             case TableInterface::TYPE_BOOLEAN:
                 $builder->boolean($column);
                 break;
             case TableInterface::TYPE_DECIMAL:
             case TableInterface::TYPE_FLOAT:
                 $builder->float($column);
                 break;
             case TableInterface::TYPE_DATE:
                 $builder->date($column);
                 break;
             case TableInterface::TYPE_DATETIME:
                 $builder->dateTime($column);
                 break;
             case TableInterface::TYPE_TIME:
                 $builder->time($column);
                 break;
             case TableInterface::TYPE_BIGINT:
             case TableInterface::TYPE_VARCHAR:
             case TableInterface::TYPE_TEXT:
             case TableInterface::TYPE_BLOB:
                 $builder->string($column);
                 break;
         }
     }
     return new Schema($builder->getProperty());
 }