I have created a stub/template file I'd like to use for creating migrations
<?php
use Phinx\Migration\AbstractMigration;
class DummyTableMigration extends AbstractMigration
{
public function up()
{
// Create the table
$table = $this->table('table_name');
$table->addColumn('column_name', 'string', ['limit' => 255])
->create();
}
public function down()
{
$this->table('table_name')->drop()->save();
}
}
This is the code in I use to create migrations via Symfony Console component. I'm passing -t
option as I want to generate a migration using the custom template I've created, but not sure how I can replace the DummyTableMigration
with the class name I want to use. Do I need to pass it as an extra option within the ArrayInput
?
$phinx = new PhinxApplication();
$input = new ArrayInput([
'command' => 'create',
'name' => $input->getArgument('name'),
'-c' => './config/phinx.php',
'-t' => '../../Console/stubs/migrations/customTemplateMigration.stub'),
]);
return $phinx->find('create')->run($input, $output);