Commit cee45fdf by Carsten Brandt

added docs description of abstract db types in migration

replaces #618
parent b427b5fb
......@@ -84,7 +84,7 @@ class m101129_185401_create_news_table extends \yii\db\Migration
{
$this->db->createCommand()->createTable('tbl_news, array(
'id' => 'pk',
'title' => 'string NOT NULL',
'title' => 'string(128) NOT NULL',
'content' => 'text',
))->execute();
}
......@@ -99,6 +99,16 @@ class m101129_185401_create_news_table extends \yii\db\Migration
The base class [\yii\db\Migration] exposes a database connection via `db`
property. You can use it for manipulating data and schema of a database.
The column types used in this example are abstract types that will be replaced
by Yii with the corresponding types depended on your database management system.
You can use them to write database independent migrations.
For example `pk` will be replaced by `int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY`
for MySQL and `integer PRIMARY KEY AUTOINCREMENT NOT NULL` for sqlite.
See documentation of [[QueryBuilder::getColumnType()]] for more details and a list
of available types. You may also use the constants defined in [[\yii\db\Schema]] to
create column types.
Transactional Migrations
------------------------
......
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