diff --git a/docs/guide/db-migrations.md b/docs/guide/db-migrations.md index 6f2e31dac7..9b9987d092 100644 --- a/docs/guide/db-migrations.md +++ b/docs/guide/db-migrations.md @@ -94,11 +94,12 @@ when you upgrade the database with this migration, while the `down()` method is The following code shows how you may implement the migration class to create a `news` table: ```php + Info: The mapping between abstract types and physical types is specified by the [[yii\db\QueryBuilder::$typeMap|$typeMap]] property in each concrete `QueryBuilder` class. -Since 2.0.5 schema builder which provides more convenient way defining column schema was introduced so migration above +Since version 2.0.5 schema builder which provides more convenient way defining column schema was introduced so migration above could be written like the following: ```php +createTable('news', [ - 'id' => Schema::primaryKey(), - 'title' => Schema::string()->notNull(), - 'content' => Schema::text(), + 'id' => $this->primaryKey(), + 'title' => $this->string()->notNull(), + 'content' => $this->text(), ]); } @@ -167,6 +169,8 @@ class m150101_185401_create_news_table extends \yii\db\Migration } ``` +A list of all available methods for defining the column types is available in the API documentation of [[yii\db\SchemaBuilderTrait]]. + ### Transactional Migrations