Skip to content

Commit f14578b

Browse files
atrandafirsamdark
authored andcommitted
Docs: Migration config for more than one DB engine (#288) [skip ci]
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.
1 parent 1bcc6d4 commit f14578b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/guide/topics-migrations.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ yii mongodb-migrate
3030
# reverts the last applied migration
3131
yii mongodb-migrate/down
3232
```
33+
## Special configuration for an application that uses more than one DB engine
34+
35+
In case your application uses multiple databases, example:
36+
37+
- MySQL + MongoDB
38+
39+
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.
40+
41+
**Problem: MongoDB will try to run MySQL's migration files and the other way around.**
42+
43+
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:
44+
45+
```php
46+
return [
47+
// ...
48+
'controllerMap' => [
49+
'mongodb-migrate' => [
50+
'class' => 'yii\mongodb\console\controllers\MigrateController',
51+
'migrationPath' => '@app/migrations/mongodb',
52+
],
53+
],
54+
];
55+
```

0 commit comments

Comments
 (0)