protected function generateTableFromMetadata($schema, TableDefinition $tableMetadata)
    {
        $primaryKeys = [];
        $uniqueIndexes = [];
        $indexes = [];

        $table = $schema->createTable($this->connection->getTablePrefix().$tableMetadata['name']);

        foreach ($tableMetadata['columns'] as $columnMetadata) {
            $columnMetadata = $this->getDoctrineColumnAliases($columnMetadata);

            // add column
            $options = $this->getDoctrineColumnOptions($columnMetadata);
            $table->addColumn($columnMetadata['name'], $columnMetadata['type'], $options);

            // add primary keys, unique indexes and indexes
            if (! empty($columnMetadata['primary'])) {
                $primaryKeys[] = $columnMetadata['name'];
            }
            if (! empty($columnMetadata['unique'])) {
                $uniqueIndexes[] = $columnMetadata['name'];
            }
            if (! empty($columnMetadata['index'])) {
                $indexes[] = $columnMetadata['name'];
            }
        }

        // add primary keys, unique indexes and indexes
        if (! empty($primaryKeys)) {
            $table->setPrimaryKey($primaryKeys);
        }
        if (! empty($uniqueIndexes)) {
            $table->addUniqueIndex($uniqueIndexes);
        }
        if (! empty($indexes)) {
            $table->addIndex($indexes);
        }
    }
protected function generateTableFromMetadata($schema, TableDefinition $tableMetadata)
    {
        $primaryKeys = [];
        $uniqueIndexes = [];
        $indexes = [];

        $table = $schema->createTable($this->connection->getTablePrefix().$tableMetadata['name']);

        foreach ($tableMetadata['columns'] as $columnMetadata) {
            $columnMetadata = $this->getDoctrineColumnAliases($columnMetadata);

            // add column
            $options = $this->getDoctrineColumnOptions($columnMetadata);
            $table->addColumn($columnMetadata['name'], $columnMetadata['type'], $options);

            // add primary keys, unique indexes and indexes
            if (! empty($columnMetadata['primary'])) {
                $primaryKeys[] = $columnMetadata['name'];
            }
            if (! empty($columnMetadata['unique'])) {
                $uniqueIndexes[] = $columnMetadata['name'];
            }
            if (! empty($columnMetadata['index'])) {
                $indexes[] = $columnMetadata['name'];
            }
        }

        // add primary keys, unique indexes and indexes
        if (! empty($primaryKeys)) {
            $table->setPrimaryKey($primaryKeys);
        }
        if (! empty($uniqueIndexes)) {
            $table->addUniqueIndex($uniqueIndexes);
        }
        if (! empty($indexes)) {
            $table->addIndex($indexes);
        }
    }
protected function generateTableFromMetadata ( $ schema , TableDefinition $ tableMetadata ) { $ primaryKeys = [ ] ; $ uniqueIndexes = [ ] ; $ indexes = [ ] ; $ table = $ schema -> createTable ( $ this -> connection -> getTablePrefix ( ) . $ tableMetadata [ 'name' ] ) ; foreach ( $ tableMetadata [ 'columns' ] as $ columnMetadata ) { $ columnMetadata = $ this -> getDoctrineColumnAliases ( $ columnMetadata ) ; // add column $ options = $ this -> getDoctrineColumnOptions ( $ columnMetadata ) ; $ table -> addColumn ( $ columnMetadata [ 'name' ] , $ columnMetadata [ 'type' ] , $ options ) ; // add primary keys, unique indexes and indexes if ( ! empty ( $ columnMetadata [ 'primary' ] ) ) { $ primaryKeys [ ] = $ columnMetadata [ 'name' ] ; } if ( ! empty ( $ columnMetadata [ 'unique' ] ) ) { $ uniqueIndexes [ ] = $ columnMetadata [ 'name' ] ; } if ( ! empty ( $ columnMetadata [ 'index' ] ) ) { $ indexes [ ] = $ columnMetadata [ 'name' ] ; } } // add primary keys, unique indexes and indexes if ( ! empty ( $ primaryKeys ) ) { $ table -> setPrimaryKey ( $ primaryKeys ) ; } if ( ! empty ( $ uniqueIndexes ) ) { $ table -> addUniqueIndex ( $ uniqueIndexes ) ; } if ( ! empty ( $ indexes ) ) { $ table -> addIndex ( $ indexes ) ; } }
Generate a table from metadata.

@param table \Doctrine\DBAL\Schema\Schema
@param \ProAI\Datamapper\Metadata\Definitions\Table $tableMetadata
@return void
Generate a table from metadata .