Using "Point"-Datatype in Phinx-Migration (in CakePhp)

250 Views Asked by At

I'm creating an API for POIs and use the POINT-Type to store the coordinates.

As my company uses CakePHP I have to write a migration-script with Phinx.

But I don't have any Idea how to correctly create a column with the POINT-Type.

Sure, I just could make an "ALTER TABLE ..." in a handwritten Query, but maybe there is a better way?


Versions:

  • Cake: 3.4.7
  • Phinx: 0.6.5
  • MySQL: 5.7.18
2

There are 2 best solutions below

0
Dennis Richter On BEST ANSWER

Just use "point" as you would use any other datatype as the second parameter of addColumn(). It's just not documented yet.


Credits for this solution are going to @ndm; I just think it's worth putting this as answer instead as a comment.

Looks like Phinx supports point types for quite some time now (the docs are not up to date)... try to use \Phinx\Db\Adapter\AdapterInterface::PHINX_TYPE_POINT as the type

3
Rayann Nayran On

Phinx Does not provide an adapter for POINT yet.

You should create your query manually.

See also Unable to seed data with POINT datatype #999