protected function confirmCompositePrimaryKey(array $newKeys): bool
    {
        if (count($this->table->primaryKey->columns) === 1 && count($newKeys) === 1) {
            /* @var $column TableColumn */
            foreach ($this->plan->addColumn as $name => $column) {
                if ($name === $newKeys[0] && $column->isColumnAppendPK()) {
                    return false;
                }
            }

            foreach ($this->plan->alterColumn as $name => $column) {
                if ($name === $newKeys[0] && $column->isColumnAppendPK()) {
                    return false;
                }
            }

            return true;
        }

        if (count($this->table->primaryKey->columns) > 1) {
            foreach ($newKeys as $key) {
                /* @var $column TableColumn */
                foreach ($this->plan->addColumn as $name => $column) {
                    if ($name === $key) {
                        $column->append = $column->removePKAppend();
                    }
                }

                foreach ($this->plan->alterColumn as $name => $column) {
                    if ($name === $key) {
                        $column->append = $column->removePKAppend();
                    }
                }
            }
        }

        return true;
    }
protected function confirmCompositePrimaryKey(array $newKeys): bool
    {
        if (count($this->table->primaryKey->columns) === 1 && count($newKeys) === 1) {
            /* @var $column TableColumn */
            foreach ($this->plan->addColumn as $name => $column) {
                if ($name === $newKeys[0] && $column->isColumnAppendPK()) {
                    return false;
                }
            }

            foreach ($this->plan->alterColumn as $name => $column) {
                if ($name === $newKeys[0] && $column->isColumnAppendPK()) {
                    return false;
                }
            }

            return true;
        }

        if (count($this->table->primaryKey->columns) > 1) {
            foreach ($newKeys as $key) {
                /* @var $column TableColumn */
                foreach ($this->plan->addColumn as $name => $column) {
                    if ($name === $key) {
                        $column->append = $column->removePKAppend();
                    }
                }

                foreach ($this->plan->alterColumn as $name => $column) {
                    if ($name === $key) {
                        $column->append = $column->removePKAppend();
                    }
                }
            }
        }

        return true;
    }
protected function confirmCompositePrimaryKey ( array $ newKeys ) : bool { if ( count ( $ this -> table -> primaryKey -> columns ) === 1 && count ( $ newKeys ) === 1 ) { /* @var $column TableColumn */ foreach ( $ this -> plan -> addColumn as $ name => $ column ) { if ( $ name === $ newKeys [ 0 ] && $ column -> isColumnAppendPK ( ) ) { return false ; } } foreach ( $ this -> plan -> alterColumn as $ name => $ column ) { if ( $ name === $ newKeys [ 0 ] && $ column -> isColumnAppendPK ( ) ) { return false ; } } return true ; } if ( count ( $ this -> table -> primaryKey -> columns ) > 1 ) { foreach ( $ newKeys as $ key ) { /* @var $column TableColumn */ foreach ( $ this -> plan -> addColumn as $ name => $ column ) { if ( $ name === $ key ) { $ column -> append = $ column -> removePKAppend ( ) ; } } foreach ( $ this -> plan -> alterColumn as $ name => $ column ) { if ( $ name === $ key ) { $ column -> append = $ column -> removePKAppend ( ) ; } } } } return true ; }
Confirms adding composite primary key and removes excessive PK statements.
@param array $newKeys
@return bool
@since 2.1.2
Confirms adding composite primary key and removes excessive PK statements .