I must be missing something or not understanding something.

I'm trying to build a module for an install, and I'd like to run the initial migration. So the module initial install migration for the DB lives in /modules/moduleName/migrations/Install.php.

Nothing I run from the CLI seems to work:

./craft migrate/up

Only sees what is in the root /migrations/ folder; seems counter-intuitive to have a migrations folder in my module if I have to manually move them.

./craft migrate/up --plugin=everyVariationOfAPossibleHandleItMightFind

Doesn't work ever, as the module is installed and works, but it isn't a plugin so I guess it doesn't see it somehow (looking in the wrong place in the file system I would bet).

./craft migrate/up migrationPath=@app/modules/moduleName

Craft CLI doesn't seem carry that Yii CLI param, so I can't specify a path.

What am I missing? How do others handle custom module migrations in Craft 3?

1 Answer 1


Per the Modules vs. Plugins docs, only plugins get their own migration track. Modules are considered part of the project (like templates and config files), so if there are any DB changes that need to be made for the module to run, those changes should be made via content migrations.

If the module is meant to be reused across multiple projects and does require DB migrations, then it will be better off as a plugin.

  • That makes sense. I just like the idea of keeping module specific migration files silo'd to my module, so to separate it from non-module specific migration files.
    – jrothafer
    Commented Aug 4, 2018 at 23:45
  • For those who want to see the option to trigger migrations from modules, you can add your votes or follow here: github.com/craftcms/cms/issues/6172 Commented Jun 3, 2020 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.