Closed midorikocak closed 9 years ago
This works:
<?php
use Phinx\Migration\AbstractMigration;
class Initial extends AbstractMigration
{
public function change()
{
$articles = $this->table('articles');
$articles
->addColumn('category_id', 'integer', ['null' => true, 'default' => null])
->save();
$categories = $this->table('categories');
$categories->addColumn('parent_id', 'integer', ['null' => true, 'default' => null])
->addColumn('lft', 'integer', ['null' => true, 'default' => null])
->addColumn('rght', 'integer', ['null' => true, 'default' => null])
->addColumn('name', 'string', ['limit' => 255])
->addColumn('description', 'string', ['limit' => 255, 'null' => true, 'default' => null])
->addColumn('created', 'datetime')
->addColumn('modified', 'datetime', ['null' => true, 'default' => null])
->save();
}
}
Shouldn't it be possible to create those migrations by command line statements (circumventing any changes - except command line options - to cake3migrations / phinx?
that would be much more better I think.
Just above the migration create command is the following.
We will use the migrations plugin to create a table in our database. If you already have an articles table in your database, erase it.
I think the intent of this was that the reader would drop the table.
that's it. yes I got it.
On 15 August 2015 at 14:40, Mark Story notifications@github.com wrote:
Just above the migration create command is the following.
We will use the migrations plugin to create a table in our database. If you already have an articles table in your database, erase it.
I think the intent of this was that the reader would drop the table.
— Reply to this email directly or view it on GitHub https://github.com/cakephp/docs/issues/3107#issuecomment-131377008.
Maybe I can add that instead creating this migraton file manually, we can also build it with a command line (and write it just after). Would it be better ?
Building with the command line might be simpler for the tutorial and show more features of the migrations plugin too.
:+1:
Close this after PR #3124
Thank you very much. Should teach how to use migrations from the start!
I started initial migration file and added the example code inside:
This is my current database:
Then I run the "bin/cake migrations migrate" command, here is the result.