Why are my migrations not working?

I’ve applied a couple of minor changes to the database structure for my app, adding new columns to a table called Plots. This is one of the migrations -


use Migrations\AbstractMigration;

class AddGarageToPlots extends AbstractMigration
    public function change()
        $table = $this->table('plots');
        $table->addColumn('garage', 'string', [
            'default' => null,
            'limit' => 255,
            'null' => true,

When I apply the migration it seems to run fine: there are no errors and I can see the new column in the database if I connect directly to it but when I try to access data in the new field in a view using, for example, <?= $plot->garage ?> it consistently returns null even though I have populated the field via the direct connection.

Is there something else I need to do that I’m missing here or is there some way I can check that the migration has worked properly like a schema file somewhere?

Found the answer to my own question by reading slightly further in the documentation. I needed to run bin/cake schema_cache clear

Maybe the guys can create a Sticky post about clearing the cache - or perhaps a list of things to do before posting. I reckon everyone (including myself) has asked a question here where clearing the cache is the answer!

Or even a recommendation. CakePHP stores the table structure directly from the SQL and compares it to the last time it did that; of which the comparison could be executed periodically or on certain exceptions. Personally I have a hidden command within my webpage (not just hidden but also needs Sys Admin access) to run a clear cache.

1 Like