Skip to content

Commit 5f85246

Browse files
committed
Docs about mongodb migration usage adjusted
1 parent 0da628a commit 5f85246

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

extensions/mongodb/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Yii Framework 2 mongodb extension Change Log
77
- Bug #3385: Fixed "The 'connected' property is deprecated" (samdark)
88
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
99
- Enh #3778: Gii generator for Active Record model added (klimov-paul)
10-
- Enh: Migration support added (klimov-paul)
10+
- Enh #3947: Migration support added (klimov-paul)
1111

1212

1313
2.0.0-beta April 13, 2014

extensions/mongodb/README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,38 @@ return [
285285
```
286286

287287
> Note: since MongoDB is schemaless, there is not much information, which generated code may base on. So generated code
288-
is very basic and definitely requires adjustments.
288+
is very basic and definitely requires adjustments.
289+
290+
291+
Using Migrations
292+
----------------
293+
294+
MongoDB is schemaless and will create any missing collection on the first demand. However there are many cases, when
295+
you may need applying persistent changes to the MongoDB database. For example: you may need to create a collection with
296+
some specific options or create indexes.
297+
MongoDB migrations are managed via [[yii\mongodb\console\controllers\MigrateController]], which is an analog of regular
298+
[[\yii\console\controllers\MigrateController]].
299+
300+
In order to enable this command you should adjust the configuration of your console application:
301+
302+
```php
303+
return [
304+
// ...
305+
'controllerMap' => [
306+
'mongodb-migrate' => 'yii\mongodb\console\controllers\MigrateController'
307+
],
308+
];
309+
```
310+
311+
Below are some common usages of this command:
312+
313+
```
314+
# creates a new migration named 'create_user_collection'
315+
yii mongodb-migrate/create create_user_collection
316+
317+
# applies ALL new migrations
318+
yii mongodb-migrate
319+
320+
# reverts the last applied migration
321+
yii mongodb-migrate/down
322+
```

extensions/mongodb/console/controllers/MigrateController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Manages application MongoDB migrations.
1919
*
20-
* This is an analog of [[\yii\console\controllers|MigrateController]] for MongoDB.
20+
* This is an analog of [[\yii\console\controllers\MigrateController]] for MongoDB.
2121
*
2222
* This command provides support for tracking the migration history, upgrading
2323
* or downloading with migrations, and creating new migration skeletons.
@@ -40,8 +40,8 @@
4040
* Below are some common usages of this command:
4141
*
4242
* ~~~
43-
* # creates a new migration named 'create_user_table'
44-
* yii mongodb-migrate/create create_user_table
43+
* # creates a new migration named 'create_user_collection'
44+
* yii mongodb-migrate/create create_user_collection
4545
*
4646
* # applies ALL new migrations
4747
* yii mongodb-migrate

0 commit comments

Comments
 (0)