I am going to learn bake migration command in cake php,
so I created a table named product
by
bin/cake bake migration CreateProduct
and bin/cake migration migrate
To make this again as training, I dropped this table by drop table product
and deleted the Migration php file, and
bin/cake bake migration CreateTableName
name:string description:text created modified
worked and migration file was made successfully
<?php
use Migrations\AbstractMigration;
class CreateProducts extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
* @return void
*/
public function change()
{
$table = $this->table('products');
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('des', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('text', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('created', 'datetime', [
'default' => null,
'null' => false,
]);
$table->addColumn('modified', 'datetime', [
'default' => null,
'null' => false,
]);
$table->create();
}
}
and also migrated file was made
<?php
use Migrations\AbstractMigration;
class Migrate extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
* @return void
*/
public function change()
{
}
}
but the table cannot found!
How I can make a table which name is same as dropped table?
I made the table by bake command, and deleted by drop, sql command, that was mistake. So I made drop migration file by bin/cake bake migration DropTableName
Then Migrated, and new product
table was made.