Moss/Storage/Schema/Schema.php
protected function createTable(SchemaAsset $schema, ModelInterface $model)
    {
        $table = $schema->createTable($this->quoteIdentifier($model->table()));

        foreach ($model->fields() as $field) {
            $table->addColumn(
                $this->quoteIdentifier($field->mappedName()),
                $field->type(),
                $field->attributes()
            );
        }

        foreach ($model->indexes() as $index) {
            switch ($index->type()) {
                case 'primary':
                    $table->setPrimaryKey(
                        $this->quoteIdentifier($index->fields()),
                        $this->quoteIdentifier($index->name())
                    );
                    break;
                case 'unique':
                    $table->addUniqueIndex(
                        $this->quoteIdentifier($index->fields()),
                        $this->quoteIdentifier($index->name())
                    );
                    break;
                case 'foreign':
                    $table->addForeignKeyConstraint(
                        $index->table(),
                        $this->quoteIdentifier(array_keys($index->fields())),
                        $this->quoteIdentifier(array_values($index->fields())),
                        ['onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT'],
                        $this->quoteIdentifier($index->name())
                    );
                    break;
                case 'index':
                default:
                    $table->addIndex(
                        $this->quoteIdentifier($index->fields()),
                        $this->quoteIdentifier($index->name())
                    );
            }
        }
    }
protected function createTable(SchemaAsset $schema, ModelInterface $model)
    {
        $table = $schema->createTable($this->quoteIdentifier($model->table()));

        foreach ($model->fields() as $field) {
            $table->addColumn(
                $this->quoteIdentifier($field->mappedName()),
                $field->type(),
                $field->attributes()
            );
        }

        foreach ($model->indexes() as $index) {
            switch ($index->type()) {
                case 'primary':
                    $table->setPrimaryKey(
                        $this->quoteIdentifier($index->fields()),
                        $this->quoteIdentifier($index->name())
                    );
                    break;
                case 'unique':
                    $table->addUniqueIndex(
                        $this->quoteIdentifier($index->fields()),
                        $this->quoteIdentifier($index->name())
                    );
                    break;
                case 'foreign':
                    $table->addForeignKeyConstraint(
                        $index->table(),
                        $this->quoteIdentifier(array_keys($index->fields())),
                        $this->quoteIdentifier(array_values($index->fields())),
                        ['onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT'],
                        $this->quoteIdentifier($index->name())
                    );
                    break;
                case 'index':
                default:
                    $table->addIndex(
                        $this->quoteIdentifier($index->fields()),
                        $this->quoteIdentifier($index->name())
                    );
            }
        }
    }
protected function createTable ( SchemaAsset $ schema , ModelInterface $ model ) { $ table = $ schema -> createTable ( $ this -> quoteIdentifier ( $ model -> table ( ) ) ) ; foreach ( $ model -> fields ( ) as $ field ) { $ table -> addColumn ( $ this -> quoteIdentifier ( $ field -> mappedName ( ) ) , $ field -> type ( ) , $ field -> attributes ( ) ) ; } foreach ( $ model -> indexes ( ) as $ index ) { switch ( $ index -> type ( ) ) { case 'primary' : $ table -> setPrimaryKey ( $ this -> quoteIdentifier ( $ index -> fields ( ) ) , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; break ; case 'unique' : $ table -> addUniqueIndex ( $ this -> quoteIdentifier ( $ index -> fields ( ) ) , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; break ; case 'foreign' : $ table -> addForeignKeyConstraint ( $ index -> table ( ) , $ this -> quoteIdentifier ( array_keys ( $ index -> fields ( ) ) ) , $ this -> quoteIdentifier ( array_values ( $ index -> fields ( ) ) ) , [ 'onUpdate' => 'CASCADE' , 'onDelete' => 'RESTRICT' ] , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; break ; case 'index' : default : $ table -> addIndex ( $ this -> quoteIdentifier ( $ index -> fields ( ) ) , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; } } }
Creates table from model into schema

@param SchemaAsset    $schema
@param ModelInterface $model
Creates table from model into schema