<p>Per the <a href="https://docs.craftcms.com/v3/extend/#modules-vs-plugins" rel="noreferrer">Modules vs. Plugins</a> 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 <a href="https://docs.craftcms.com/v3/content-migrations.html" rel="noreferrer">content migrations</a>.</p>

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

CC BY-SA 4.0
2018-08-04T23:45:18.203Z
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
CC BY-SA 4.0
2020-06-03T20:19:28.303Z
For those who want to see the option to trigger migrations from modules, you can add your votes or follow here: https://github.com/craftcms/cms/issues/6172
Ben Parizek
CC BY-SA 4.0
2018-08-04T16:45:11.700Z
2018-08-04T16:45:11.700Z
Brandon Kelly
<p>I must be missing something or not understanding something.</p>

<p>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 <code>/modules/moduleName/migrations/Install.php</code>. </p>

<p>Nothing I run from the CLI seems to work:</p>

<pre><code>./craft migrate/up
</code></pre>

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

<pre><code>./craft migrate/up --plugin=everyVariationOfAPossibleHandleItMightFind
</code></pre>

<p>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).</p>

<pre><code>./craft migrate/up migrationPath=@app/modules/moduleName
</code></pre>

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

<p>What am I missing? How do others handle custom module migrations in Craft 3?</p>

<craft3><migration><modules>
Running module migrations
# Running module migrations

(Asked by: username_0 on 2018-08-04)

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?

**Tags:** craft3, migration, modules

---

## 1 answers

### Answer by username_1 on 2018-08-04. Score: 6 | Accepted answer

Per the [Modules vs. Plugins](https://docs.craftcms.com/v3/extend/#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](https://docs.craftcms.com/v3/content-migrations.html).

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.

> **Comments:**
> **username_0**: 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.  
> **username_2**: For those who want to see the option to trigger migrations from modules, you can add your votes or follow here: https://github.com/craftcms/cms/issues/6172  

---

