phinx icon indicating copy to clipboard operation
phinx copied to clipboard

Postgre types

Open ricksanchez opened this issue 9 years ago • 3 comments

How is it possible to set a column type in postgre from this list https://www.postgresql.org/docs/9.5/static/datatype.html ? In the documentation, it is only information about "smallint, json, jsonb and uuid" but there is much more types in postgresql, for example: daterange is a valid column type. Also, what about custom types? https://www.postgresql.org/docs/9.5/static/sql-createtype.html Is it already possible to use them in phinx? If not, it would be really useful to have. Don't you think so?

ricksanchez avatar Aug 17 '16 14:08 ricksanchez

Just start coding and provide a PR per feature.

mvrhov avatar Aug 24 '16 15:08 mvrhov

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

dereuromark avatar Mar 01 '18 20:03 dereuromark

PR welcome.

dereuromark avatar Apr 11 '20 06:04 dereuromark

For reference, if you want to use a type that phinx does not support, you can do it by using a Phinx\Util\Literal, like so:

        $this->table('users')
              ->addColumn('username', Literal::from('daterange'))
              ->create();

See https://book.cakephp.org/phinx/0/en/migrations.html#custom-column-types-default-values for more information.

MasterOdin avatar Feb 09 '23 13:02 MasterOdin