3

When exactly are migrations run? I wrote a migration that runs and does its job properly if I run it via the command line: yiic migrate up Seomatic but despite the version number and schema number being bumped, Craft doesn’t run the migration automatically`

Instead, my code dies because of a column that doesn’t exist in the db. Shouldn't the migration be found and run before my plugin's code is?

Here's the version numbers returned by my plugin:

public function getVersion() { return '1.0.5'; } public function getSchemaVersion() { return '1.0.1'; } 

The previous installed version was '1.0.4' and '1.0.0', respectively. Shouldn't this be enough for Craft to find and run the migration?

The migration is named:

m151225_000000_seomatic_addHumansField.php 

...with a class of the same name, and again, it's found and runs properly if manually run it via yiic -- what am I missing?

1 Answer 1

4

Actually, everything was working fine with the migration. The issue was that I had code inside of a Twig extension and inside of a rendering hook that was being executed before the migration tried to take place.

I wrapped it in if (!craft()->request->isCpRequest()) to only do its thing when it's a non-CP request (which is how it probably should have been anyway), and all is well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.