cakephp / phinx

PHP Database Migrations for Everyone
https://phinx.org
MIT License
4.46k stars 890 forks source link

Provide Constants for Column Types and Options #697

Closed samizdam closed 4 years ago

samizdam commented 8 years ago

Create some classes or interfaces with enums of valid options and types for columns, like: https://github.com/yiisoft/yii2/blob/master/framework/db/Schema.php#L45 or https://github.com/zendframework/zend-db/blob/master/src/Adapter/ParameterContainer.php#L18 or https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/Type.php#L36

Goals:

robmorgan commented 8 years ago

@samizdam have you seen https://github.com/robmorgan/phinx/blob/0.5.x-dev/src/Phinx/Db/Adapter/AdapterInterface.php#L43?

samizdam commented 8 years ago

Hm...Thanks! It's looks like what I want. But it not very useful out of Adapter package.

What you think about extract this enum to separate class, for example Phinx\Db\Table\ColumnTypeEnum(Interface) or Phinx\Db\Adapter\DataType* and reuse it (via implement or simple import with use) in AdapterInterface and MigrationInterface? I think use self::TYPE_STRING in concrete migrations will be helpful for users, who work with Phinx first time, and make this code readable.

And what you think about Options as constants?

P.S. Yes, this issue make code is more verbose. But find all usages of some type (for refactoring, or code inspection) will be easier, and code will becomes more abstract with Enum, to my mind.

dereuromark commented 6 years ago

Are you able to provide a patch with your suggested changes as PR?

othercorey commented 4 years ago

Closing due to lack of activity or out of scope. If there is new interest, please open a PR.