Action/BuildAction.php
protected function prepareUniqueConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable)
    {
        $uniqueTags = $xpath->query(sprintf('/database/table[@name="%s"]/unique', $table->getAttribute('name')));

        /** @var DOMElement $uniqueTag */
        foreach ($uniqueTags as $uniqueTag) {
            $uniqueColumns = $uniqueTag->getElementsByTagName('unique-column');
            $constraintName = $uniqueTag->getAttribute('name');

            $tmpUniqueColumn = [];
            /** @var DOMElement $uniqueColumn */
            foreach ($uniqueColumns as $uniqueColumn) {
                $tmpUniqueColumn[] = $uniqueColumn->getAttribute('name');
            }

            if (empty(trim($constraintName))) {
                $constraintName = sprintf(
                    '%s_%s_%s',
                    $table->getAttribute('name'),
                    implode('_', $tmpUniqueColumn),
                    'unique'
                );
            }

            $schemaTable->addConstraint(
                $constraintName,
                [
                    'type' => 'unique',
                    'columns' => $tmpUniqueColumn
                ]
            );
        }
    }
protected function prepareUniqueConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable)
    {
        $uniqueTags = $xpath->query(sprintf('/database/table[@name="%s"]/unique', $table->getAttribute('name')));

        /** @var DOMElement $uniqueTag */
        foreach ($uniqueTags as $uniqueTag) {
            $uniqueColumns = $uniqueTag->getElementsByTagName('unique-column');
            $constraintName = $uniqueTag->getAttribute('name');

            $tmpUniqueColumn = [];
            /** @var DOMElement $uniqueColumn */
            foreach ($uniqueColumns as $uniqueColumn) {
                $tmpUniqueColumn[] = $uniqueColumn->getAttribute('name');
            }

            if (empty(trim($constraintName))) {
                $constraintName = sprintf(
                    '%s_%s_%s',
                    $table->getAttribute('name'),
                    implode('_', $tmpUniqueColumn),
                    'unique'
                );
            }

            $schemaTable->addConstraint(
                $constraintName,
                [
                    'type' => 'unique',
                    'columns' => $tmpUniqueColumn
                ]
            );
        }
    }
protected function prepareUniqueConstraint ( DOMElement $ table , DOMXPath $ xpath , Table $ schemaTable ) { $ uniqueTags = $ xpath -> query ( sprintf ( '/database/table[@name="%s"]/unique' , $ table -> getAttribute ( 'name' ) ) ) ; /** @var DOMElement $uniqueTag */ foreach ( $ uniqueTags as $ uniqueTag ) { $ uniqueColumns = $ uniqueTag -> getElementsByTagName ( 'unique-column' ) ; $ constraintName = $ uniqueTag -> getAttribute ( 'name' ) ; $ tmpUniqueColumn = [ ] ; /** @var DOMElement $uniqueColumn */ foreach ( $ uniqueColumns as $ uniqueColumn ) { $ tmpUniqueColumn [ ] = $ uniqueColumn -> getAttribute ( 'name' ) ; } if ( empty ( trim ( $ constraintName ) ) ) { $ constraintName = sprintf ( '%s_%s_%s' , $ table -> getAttribute ( 'name' ) , implode ( '_' , $ tmpUniqueColumn ) , 'unique' ) ; } $ schemaTable -> addConstraint ( $ constraintName , [ 'type' => 'unique' , 'columns' => $ tmpUniqueColumn ] ) ; } }
Prepare unique constraint

@param DOMElement $table
@param DOMXPath   $xpath
@param Table      $schemaTable
Prepare unique constraint