As a developer I want to have an example for createTable
The documentation specifies that createTable can be used in the change method, but there is no example. Only http://docs.phinx.org/en/latest/migrations.html#creating-a-table can be found. Could an example be added?
Hi @Mondane have a look here for a basic exmaple: http://docs.phinx.org/en/latest/migrations.html#the-change-method. I agree the docs could be improved a bit though.
Agree with @Mondane, I can't find how to create an unsigned primary key
See the documentation at https://book.cakephp.org/3.0/en/phinx/migrations.html#creating-a-table, namely a bit into it it talks about setting id versus primary_key and that MySQL supports setting the signed option on the table object.
So, you could either do:
$table = $this->table('example_table', ['signed' => false]);
$table->create();
or
$table = $this->table('example_table', ['id' => false, 'primary_key' => 'pid']);
$table->addColumn('pid', 'integer')
->create();
I think that what @Mondane means is that in docs and also on migration create appears this
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* [...]
And is a bit confusing that is not any reference elsewhere about how to use it. If is on ->create(), i think this createTable should be changed by only create, because otherwise seems like wrong.
That's exactly what I mean. I'm missing examples for those commands :
- createTable
- renameTable
- addColumn
- renameColumn
- addIndex
- addForeignKey
For instance, for createTable, should I use the function 'createTable' or something else. I know the function exists: https://github.com/cakephp/phinx/search?q=createTable&unscoped_q=createTable .
Confused me too. There is no "createTable" method.
docs PR welcome