Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-04T23:45:18.203Z
Answers.Text: 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.
Answers.UserDisplayName: jrothafer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-03T20:19:28.303Z
Answers.Text: 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
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-04T16:45:11.700Z
Answers.LastActivityDate: 2018-08-04T16:45:11.700Z
Answers.UserDisplayName: Brandon Kelly
Body: <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>
  
Tags: <craft3><migration><modules>
Title: Running module migrations
ThreadText: # 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  
  
  ---
  
  