according documentation
i can use code below create migration creates new table. wondering missing use new feature? new feature mean line in documentation.
many thanks!
"since 2.0.5 schema builder provides more convenient way defining column schema introduced migration above written following:"
use yii\db\schema; use yii\db\migration; class m150101_185401_create_news_table extends \yii\db\migration { public function up() { $this->createtable('news', [ 'id' => schema::primarykey(), 'title' => schema::string()->notnull(), 'content' => schema::text(), ]); } public function down() { $this->droptable('news'); } } but when try error message.
yii migration tool (based on yii v2.0.5) total 1 new migration applied: m150717_020723_create_news_table apply above migration? (yes|no) [no]:yes *** applying m150717_020723_create_news_table php fatal error: call undefined method yii\db\schema::primarykey() in
1) check composer.json containing valid yii2 version, example:
"yiisoft/yii2": ">=2.0.6", also check used application type, see this issue , samdark's answer:
current advanced using new migrations style available in 2.0.6 only. basic not.
2) update framework latest version running:
composer update
Comments
Post a Comment