From 0ef87e87a3b66778ebf7ba31e595d9d077dfa561 Mon Sep 17 00:00:00 2001 From: Oscar Fernandez Date: Fri, 28 Aug 2020 17:34:52 -0300 Subject: [PATCH] Fix COLUMN_NAME and column_name --- .../Generators/FieldGenerator.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php b/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php index 58ed6d6..5a56e52 100644 --- a/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php +++ b/src/OscarAFDev/MigrationsGenerator/Generators/FieldGenerator.php @@ -71,14 +71,19 @@ protected function getEnum($table) * @param string $table * @return array */ - protected function setEnum(array $fields, $table) - { - foreach ($this->getEnum($table) as $column) { - $fields[$column->COLUMN_NAME]['type'] = 'enum'; - $fields[$column->COLUMN_NAME]['args'] = str_replace('enum(', 'array(', $column->COLUMN_TYPE); - } - return $fields; - } + protected function setEnum(array $fields, $table) + { + foreach ($this->getEnum($table) as $column) { + if (isset($column->COLUMN_NAME)) { + $fields[$column->COLUMN_NAME]['type'] = 'enum'; + $fields[$column->COLUMN_NAME]['args'] = str_replace('enum(', 'array(', $column->COLUMN_TYPE); + } elseif (isset($column->column_name)) { + $fields[$column->column_name]['type'] = 'enum'; + $fields[$column->column_name]['args'] = str_replace('enum(', 'array(', $column->column_type); + } + } + return $fields; + } /** * @param \Doctrine\DBAL\Schema\Column[] $columns