Commit 5f852465 by Klimov Paul

Docs about mongodb migration usage adjusted

parent 0da628ae
...@@ -7,7 +7,7 @@ Yii Framework 2 mongodb extension Change Log ...@@ -7,7 +7,7 @@ Yii Framework 2 mongodb extension Change Log
- Bug #3385: Fixed "The 'connected' property is deprecated" (samdark) - Bug #3385: Fixed "The 'connected' property is deprecated" (samdark)
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe) - Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
- Enh #3778: Gii generator for Active Record model added (klimov-paul) - Enh #3778: Gii generator for Active Record model added (klimov-paul)
- Enh: Migration support added (klimov-paul) - Enh #3947: Migration support added (klimov-paul)
2.0.0-beta April 13, 2014 2.0.0-beta April 13, 2014
......
...@@ -285,4 +285,38 @@ return [ ...@@ -285,4 +285,38 @@ return [
``` ```
> Note: since MongoDB is schemaless, there is not much information, which generated code may base on. So generated code > Note: since MongoDB is schemaless, there is not much information, which generated code may base on. So generated code
is very basic and definitely requires adjustments. is very basic and definitely requires adjustments.
\ No newline at end of file
Using Migrations
----------------
MongoDB is schemaless and will create any missing collection on the first demand. However there are many cases, when
you may need applying persistent changes to the MongoDB database. For example: you may need to create a collection with
some specific options or create indexes.
MongoDB migrations are managed via [[yii\mongodb\console\controllers\MigrateController]], which is an analog of regular
[[\yii\console\controllers\MigrateController]].
In order to enable this command you should adjust the configuration of your console application:
```php
return [
// ...
'controllerMap' => [
'mongodb-migrate' => 'yii\mongodb\console\controllers\MigrateController'
],
];
```
Below are some common usages of this command:
```
# creates a new migration named 'create_user_collection'
yii mongodb-migrate/create create_user_collection
# applies ALL new migrations
yii mongodb-migrate
# reverts the last applied migration
yii mongodb-migrate/down
```
\ No newline at end of file
...@@ -17,7 +17,7 @@ use yii\helpers\ArrayHelper; ...@@ -17,7 +17,7 @@ use yii\helpers\ArrayHelper;
/** /**
* Manages application MongoDB migrations. * Manages application MongoDB migrations.
* *
* This is an analog of [[\yii\console\controllers|MigrateController]] for MongoDB. * This is an analog of [[\yii\console\controllers\MigrateController]] for MongoDB.
* *
* This command provides support for tracking the migration history, upgrading * This command provides support for tracking the migration history, upgrading
* or downloading with migrations, and creating new migration skeletons. * or downloading with migrations, and creating new migration skeletons.
...@@ -40,8 +40,8 @@ use yii\helpers\ArrayHelper; ...@@ -40,8 +40,8 @@ use yii\helpers\ArrayHelper;
* Below are some common usages of this command: * Below are some common usages of this command:
* *
* ~~~ * ~~~
* # creates a new migration named 'create_user_table' * # creates a new migration named 'create_user_collection'
* yii mongodb-migrate/create create_user_table * yii mongodb-migrate/create create_user_collection
* *
* # applies ALL new migrations * # applies ALL new migrations
* yii mongodb-migrate * yii mongodb-migrate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment