src/DataStore/src/TableGateway/TableManagerMysql.php
protected function createCreateTable(string $tableName, array $tableConfig): CreateTable
    {
        $createTable = new CreateTable($tableName);
        $primaryKeys = [];

        foreach ($tableConfig as $fieldName => $fieldData) {
            if (isset($fieldData[static::PRIMARY_KEY])) {
                $primaryKeys[] = $fieldName;
            }

            $column = $this->createColumn($fieldData, $fieldName);
            $createTable->addColumn($column);

            if (isset($fieldData[self::UNIQUE_KEY])) {
                $constrain = $this->createUniqueKeyConstraint($fieldData[self::UNIQUE_KEY], $fieldName, $tableName);
                $createTable->addConstraint($constrain);
            }

            if (isset($fieldData[self::FOREIGN_KEY])) {
                $constrain = $this->createForeignKeyConstraint($fieldData[self::FOREIGN_KEY], $fieldName, $tableName);
                $createTable->addConstraint($constrain);
            }
        }

        if (count($primaryKeys)) {
            $createTable->addConstraint(new Constraint\PrimaryKey(...$primaryKeys));
        } else {
            $createTable->addConstraint(new Constraint\PrimaryKey('id'));
        }

        return $createTable;
    }
protected function createCreateTable(string $tableName, array $tableConfig): CreateTable
    {
        $createTable = new CreateTable($tableName);
        $primaryKeys = [];

        foreach ($tableConfig as $fieldName => $fieldData) {
            if (isset($fieldData[static::PRIMARY_KEY])) {
                $primaryKeys[] = $fieldName;
            }

            $column = $this->createColumn($fieldData, $fieldName);
            $createTable->addColumn($column);

            if (isset($fieldData[self::UNIQUE_KEY])) {
                $constrain = $this->createUniqueKeyConstraint($fieldData[self::UNIQUE_KEY], $fieldName, $tableName);
                $createTable->addConstraint($constrain);
            }

            if (isset($fieldData[self::FOREIGN_KEY])) {
                $constrain = $this->createForeignKeyConstraint($fieldData[self::FOREIGN_KEY], $fieldName, $tableName);
                $createTable->addConstraint($constrain);
            }
        }

        if (count($primaryKeys)) {
            $createTable->addConstraint(new Constraint\PrimaryKey(...$primaryKeys));
        } else {
            $createTable->addConstraint(new Constraint\PrimaryKey('id'));
        }

        return $createTable;
    }
protected function createCreateTable ( string $ tableName , array $ tableConfig ) : CreateTable { $ createTable = new CreateTable ( $ tableName ) ; $ primaryKeys = [ ] ; foreach ( $ tableConfig as $ fieldName => $ fieldData ) { if ( isset ( $ fieldData [ static :: PRIMARY_KEY ] ) ) { $ primaryKeys [ ] = $ fieldName ; } $ column = $ this -> createColumn ( $ fieldData , $ fieldName ) ; $ createTable -> addColumn ( $ column ) ; if ( isset ( $ fieldData [ self :: UNIQUE_KEY ] ) ) { $ constrain = $ this -> createUniqueKeyConstraint ( $ fieldData [ self :: UNIQUE_KEY ] , $ fieldName , $ tableName ) ; $ createTable -> addConstraint ( $ constrain ) ; } if ( isset ( $ fieldData [ self :: FOREIGN_KEY ] ) ) { $ constrain = $ this -> createForeignKeyConstraint ( $ fieldData [ self :: FOREIGN_KEY ] , $ fieldName , $ tableName ) ; $ createTable -> addConstraint ( $ constrain ) ; } } if ( count ( $ primaryKeys ) ) { $ createTable -> addConstraint ( new Constraint \ PrimaryKey ( ... $ primaryKeys ) ) ; } else { $ createTable -> addConstraint ( new Constraint \ PrimaryKey ( 'id' ) ) ; } return $ createTable ; }
Create and return instance of CreateTable

@param $tableName
@param $tableConfig
@return CreateTable
Create and return instance of CreateTable