src/RocknRoot/StrayFw/Database/Postgres/Schema.php
private function buildEnum(string $enumName, array $enumDefinition)
    {
        $mapping = Mapping::get($this->mapping);
        $definition = $this->getDefinition();
        $database = GlobalDatabase::get($mapping['config']['database']);

        $enumRealName = null;
        if (isset($enumDefinition['name']) === true) {
            $enumRealName = $enumDefinition['name'];
        } else {
            $enumRealName = Helper::codifyName($this->mapping) . '_' . Helper::codifyName($enumName);
        }

        if (isset($enumDefinition['values']) === false) {
            throw new InvalidSchemaDefinition('enum "' . $enumName . '" has no value');
        }

        $values = array();
        foreach ($enumDefinition['values'] as $valueName => $valueAlias) {
            $valueRealName = null;
            if (is_string($valueName) === true) {
                $valueRealName = $valueName;
            } else {
                $valueRealName = Helper::codifyName($enumName) . '_' . Helper::codifyName($valueAlias);
            }
            $values[] = $valueRealName;
        }

        $statement = Mutation\AddEnum::statement($database, $enumRealName, $values);
        if ($statement->execute() == false) {
            throw new DatabaseError('db/build : ' . print_r($statement->errorInfo(), true));
        }

        echo $enumName . ' - Done' . PHP_EOL;
    }
private function buildEnum(string $enumName, array $enumDefinition)
    {
        $mapping = Mapping::get($this->mapping);
        $definition = $this->getDefinition();
        $database = GlobalDatabase::get($mapping['config']['database']);

        $enumRealName = null;
        if (isset($enumDefinition['name']) === true) {
            $enumRealName = $enumDefinition['name'];
        } else {
            $enumRealName = Helper::codifyName($this->mapping) . '_' . Helper::codifyName($enumName);
        }

        if (isset($enumDefinition['values']) === false) {
            throw new InvalidSchemaDefinition('enum "' . $enumName . '" has no value');
        }

        $values = array();
        foreach ($enumDefinition['values'] as $valueName => $valueAlias) {
            $valueRealName = null;
            if (is_string($valueName) === true) {
                $valueRealName = $valueName;
            } else {
                $valueRealName = Helper::codifyName($enumName) . '_' . Helper::codifyName($valueAlias);
            }
            $values[] = $valueRealName;
        }

        $statement = Mutation\AddEnum::statement($database, $enumRealName, $values);
        if ($statement->execute() == false) {
            throw new DatabaseError('db/build : ' . print_r($statement->errorInfo(), true));
        }

        echo $enumName . ' - Done' . PHP_EOL;
    }
Build an enum.

@param string $enumName enum alias
@param array $enumDefinition enum definition from a schema file
@throws DatabaseError           if a SQL query fails
@throws InvalidSchemaDefinition if an enum has no value