private function checkIndexes($dbColumnName, array $desc, Table &$table) {
        // if column is not primary key
        if ($table->getPrimaryKey() !== $dbColumnName) {
            // drop index if column is indexed
            if (array_key_exists($dbColumnName, $table->getIndexes())) {
                // drop reference if column is referenced
                if (array_key_exists($dbColumnName, $table->getReferences())) {
                    $table->dropReference($dbColumnName);
                }
                $table->dropIndex($dbColumnName);
            }

            // add index to column if described as such
            if (isset($desc['attrs']['index'])) {
                $table->addIndex($dbColumnName, Table::INDEX_REGULAR);
            }
            else if (isset($desc['attrs']['unique'])) {
                $table->addIndex($dbColumnName, Table::INDEX_UNIQUE);
            }
            else if (isset($desc['attrs']['fulltext'])) {
                $table->addIndex($dbColumnName, Table::INDEX_FULLTEXT);
            }
            else {
                return null;
            }

            $ref = $table->getReferences();
            if (array_key_exists($dbColumnName, $ref) && !empty($ref[$dbColumnName]['refTable'])) {
                $table->addReference($dbColumnName, $ref[$dbColumnName]['refTable'], $ref[$dbColumnName]['refColumn'], $ref[$dbColumnName]['onDelete'], $ref[$dbColumnName]['onUpdate']);
            }
        }
    }
private function checkIndexes($dbColumnName, array $desc, Table &$table) {
        // if column is not primary key
        if ($table->getPrimaryKey() !== $dbColumnName) {
            // drop index if column is indexed
            if (array_key_exists($dbColumnName, $table->getIndexes())) {
                // drop reference if column is referenced
                if (array_key_exists($dbColumnName, $table->getReferences())) {
                    $table->dropReference($dbColumnName);
                }
                $table->dropIndex($dbColumnName);
            }

            // add index to column if described as such
            if (isset($desc['attrs']['index'])) {
                $table->addIndex($dbColumnName, Table::INDEX_REGULAR);
            }
            else if (isset($desc['attrs']['unique'])) {
                $table->addIndex($dbColumnName, Table::INDEX_UNIQUE);
            }
            else if (isset($desc['attrs']['fulltext'])) {
                $table->addIndex($dbColumnName, Table::INDEX_FULLTEXT);
            }
            else {
                return null;
            }

            $ref = $table->getReferences();
            if (array_key_exists($dbColumnName, $ref) && !empty($ref[$dbColumnName]['refTable'])) {
                $table->addReference($dbColumnName, $ref[$dbColumnName]['refTable'], $ref[$dbColumnName]['refColumn'], $ref[$dbColumnName]['onDelete'], $ref[$dbColumnName]['onUpdate']);
            }
        }
    }
private function checkIndexes ( $ dbColumnName , array $ desc , Table & $ table ) { // if column is not primary key if ( $ table -> getPrimaryKey ( ) !== $ dbColumnName ) { // drop index if column is indexed if ( array_key_exists ( $ dbColumnName , $ table -> getIndexes ( ) ) ) { // drop reference if column is referenced if ( array_key_exists ( $ dbColumnName , $ table -> getReferences ( ) ) ) { $ table -> dropReference ( $ dbColumnName ) ; } $ table -> dropIndex ( $ dbColumnName ) ; } // add index to column if described as such if ( isset ( $ desc [ 'attrs' ] [ 'index' ] ) ) { $ table -> addIndex ( $ dbColumnName , Table :: INDEX_REGULAR ) ; } else if ( isset ( $ desc [ 'attrs' ] [ 'unique' ] ) ) { $ table -> addIndex ( $ dbColumnName , Table :: INDEX_UNIQUE ) ; } else if ( isset ( $ desc [ 'attrs' ] [ 'fulltext' ] ) ) { $ table -> addIndex ( $ dbColumnName , Table :: INDEX_FULLTEXT ) ; } else { return null ; } $ ref = $ table -> getReferences ( ) ; if ( array_key_exists ( $ dbColumnName , $ ref ) && ! empty ( $ ref [ $ dbColumnName ] [ 'refTable' ] ) ) { $ table -> addReference ( $ dbColumnName , $ ref [ $ dbColumnName ] [ 'refTable' ] , $ ref [ $ dbColumnName ] [ 'refColumn' ] , $ ref [ $ dbColumnName ] [ 'onDelete' ] , $ ref [ $ dbColumnName ] [ 'onUpdate' ] ) ; } } }
Checks if a column should be indexed, removing old index and adding new
@param string $dbColumnName
@param array $desc
@param Table $table
@return void
Checks if a column should be indexed removing old index and adding new