cakephp / cakephp/phinx

Rollback doesn't remove tables created via `change()`

Open
#1,307 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

Just wasted half-hour because of this bug. The title is quite self-explanatory.

Make some migration which creates a table:

<?php

use Phinx\Migration\AbstractMigration;

class CreateTestTable extends AbstractMigration
{
    public function change()
    {
        $this->table('test')
            ->addColumn('name', 'string')
            ->save();
    }
}

Then do migrate and rollback. At rollback it will simply delete all columns but id and keep the table.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the migration shown in AbstractMigration::change(), using table('test')->addColumn(...)->save(), then run migrate followed by rollback. Trace how the change() operation handles the table during rollback. Done means the rollback removes the test table rather than leaving an empty table with only its id column.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.