phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 631 forks source link

Devtools Migrations Column type ENUM #1469

Closed flaussinot closed 3 years ago

flaussinot commented 4 years ago

Questions should go to https://forum.phalconphp.com Documentation issues should go to https://github.com/phalcon/docs/issues

Expected and Actual Behavior

Describe what you are trying to achieve and what goes wrong. I tried to implement migrations and I noticed that enum column type is generated as Column::TYPE_VARCHAR with size 1 and there is no option to change to set/enum.

Provide output if related

ERROR: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'test'

Provide minimal script to reproduce the issue

CREATE TABLE `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `test` enum('on','off') DEFAULT 'off',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The model generated by webtools.php:

...
new Column(
    'test',
    [
        'type' => Column::TYPE_CHAR,
        'default' => "off",
        'size' => 1,
        'after' => 'id'
    ]
)
...

Details

Jeckerson commented 4 years ago

ENUM type support was added since v2 phalcon/migrations. If possible, please use as separate package inside your composer.json file.

https://github.com/phalcon/migrations

Jeckerson commented 3 years ago

Related #1464

Jeckerson commented 3 years ago

Closing if favor of #1464