src/Builder/AssociationsBuilder.php
public function prepareHasOneConstraintStatement(TypeInterface $type, HasOneAssociation $association)
    {
        $result = [];

        $result[] = 'ALTER TABLE ' . $this->getConnection()->escapeTableName($type->getName());
        $result[] = '    ADD CONSTRAINT ' . $this->getConnection()->escapeFieldName($association->getConstraintName());
        $result[] = '    FOREIGN KEY (' . $this->getConnection()->escapeFieldName($association->getFieldName()) . ') REFERENCES ' . $this->getConnection()->escapeTableName($association->getTargetTypeName()) . '(`id`)';

        if ($association->isRequired()) {
            $result[] = '    ON UPDATE CASCADE ON DELETE CASCADE;';
        } else {
            $result[] = '    ON UPDATE SET NULL ON DELETE SET NULL;';
        }

        return implode("\n", $result);
    }
public function prepareHasOneConstraintStatement(TypeInterface $type, HasOneAssociation $association)
    {
        $result = [];

        $result[] = 'ALTER TABLE ' . $this->getConnection()->escapeTableName($type->getName());
        $result[] = '    ADD CONSTRAINT ' . $this->getConnection()->escapeFieldName($association->getConstraintName());
        $result[] = '    FOREIGN KEY (' . $this->getConnection()->escapeFieldName($association->getFieldName()) . ') REFERENCES ' . $this->getConnection()->escapeTableName($association->getTargetTypeName()) . '(`id`)';

        if ($association->isRequired()) {
            $result[] = '    ON UPDATE CASCADE ON DELETE CASCADE;';
        } else {
            $result[] = '    ON UPDATE SET NULL ON DELETE SET NULL;';
        }

        return implode("\n", $result);
    }
public function prepareHasOneConstraintStatement ( TypeInterface $ type , HasOneAssociation $ association ) { $ result = [ ] ; $ result [ ] = 'ALTER TABLE ' . $ this -> getConnection ( ) -> escapeTableName ( $ type -> getName ( ) ) ; $ result [ ] = '    ADD CONSTRAINT ' . $ this -> getConnection ( ) -> escapeFieldName ( $ association -> getConstraintName ( ) ) ; $ result [ ] = '    FOREIGN KEY (' . $ this -> getConnection ( ) -> escapeFieldName ( $ association -> getFieldName ( ) ) . ') REFERENCES ' . $ this -> getConnection ( ) -> escapeTableName ( $ association -> getTargetTypeName ( ) ) . '(`id`)' ; if ( $ association -> isRequired ( ) ) { $ result [ ] = '    ON UPDATE CASCADE ON DELETE CASCADE;' ; } else { $ result [ ] = '    ON UPDATE SET NULL ON DELETE SET NULL;' ; } return implode ( "\n" , $ result ) ; }
Prepare has one constraint statement.

@param  TypeInterface     $type
@param  HasOneAssociation $association
@return string
Prepare has one constraint statement .