Phinx table already exists? Want to add 1 extra table

535 Views Asked by At

I'm pretty new to phinx, I made a number of migrations and ran the migration which created the tables as it should have.

However I made a new migration to add an extra table, now If i run migrate -c phinx.php it tries to re-add the tables that are already there.

Is there any way to just add the one migration? As i don't want to delete my database and insert them all again

Here is the migration I want to add

<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CustomerCompanyTable extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
      $table = $this->table('customer_company');
      $table
            ->addColumn('customer_id', 'integer', ['limit' => 11, 'null' => true])
            ->addColumn('company_id', 'integer', ['limit' => 11, 'null' => true])
            ->create();
    }
}
0

There are 0 best solutions below