Skip to content

Commit

Permalink
Docs: Migration config for more than one DB engine (#288) [skip ci]
Browse files Browse the repository at this point in the history
Special configuration for an application that uses more than one DB engine to avoid mixing migrations from both systems.

The problem it solves:  

- If you run both MySQL and MongoDB and have migrations for both, with the default configuration if you create a mongodb migration and try to run it, it will tell you that you have a lot of other pending migrations, that are actually MySQL migrations.
  • Loading branch information
atrandafir authored and samdark committed Nov 22, 2019
1 parent 1bcc6d4 commit f14578b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/guide/topics-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,26 @@ yii mongodb-migrate
# reverts the last applied migration
yii mongodb-migrate/down
```
## Special configuration for an application that uses more than one DB engine

In case your application uses multiple databases, example:

- MySQL + MongoDB

If you run the migration commands, it will evaluate both MySQL and MongoDB migration files at the same time since both by default share the same folder.

**Problem: MongoDB will try to run MySQL's migration files and the other way around.**

In order to avoid that behavior, you can create a new folder called `mongodb` under your `migrations` folder, and then setup your console application like this:

```php
return [
// ...
'controllerMap' => [
'mongodb-migrate' => [
'class' => 'yii\mongodb\console\controllers\MigrateController',
'migrationPath' => '@app/migrations/mongodb',
],
],
];
```

0 comments on commit f14578b

Please sign in to comment.