yii - Not able to create Table through YIIC Migreate create -
i started learning yii framework , facing issue while trying create table through yiic migrate. below code of table.
class m140627_072906_create_test_table extends cdbmigration { public function up() { $this->create('tbl_locations', array( 'id'=>'pk', 'location_name'=>'string not null', 'create_time'=>'datetime not null', 'create_user_id'=>'int(11) not null', 'update_time'=>'datetime not null', 'update_user_id'=>'int(11) not null', ), 'engine=innodb' ); } } public function down() { echo "m140627_072906_create_test_table not support migration down.\n"; return false; } }
my project under c:\wamp\www\bookmyroom\ , below folder structure
c:\wamp\www\bookmyroom>dir volume in drive c has no label. volume serial number 5291-fe18 directory of c:\wamp\www\bookmyroom
06/25/2014 08:58 pm <dir> . 06/25/2014 08:58 pm <dir> .. 06/27/2014 12:32 pm <dir> assets 06/25/2014 07:05 pm <dir> css 06/25/2014 09:04 pm <dir> framework 06/25/2014 07:05 pm <dir> images 06/25/2014 07:05 pm 466 index-test.php 06/25/2014 09:10 pm 456 index.php 06/25/2014 07:08 pm <dir> nbproject 06/25/2014 07:05 pm <dir> protected 06/25/2014 07:05 pm <dir> themes 2 file(s) 922 bytes 9 dir(s) 8,986,624,000 bytes free
i runned yiic migrate command inside protected folder. getting below error while running migrate command.
c:\wamp\www\bookmyroom\protected>yiic migrate yii migration tool v1.0 (based on yii v1.1.14) total 1 new migration applied: m140627_074906_create_table_locations apply above migration? (yes|no) [no]:y *** applying m140627_074906_create_table_locations exception 'cexception' message 'm140627_074906_create_table_locations , behaviors not have method or closure named "create".' in c:\wamp\www\yii\framework\base\ccomponent.php:266 stack trace: #0 c:\wamp\www\bookmyroom\protected\migrations\m140627_074906_create_table_locations.php (16): ccomponent->__call('create', array) #1 c:\wamp\www\bookmyroom\protected\migrations\m140627_074906_create_table_locations.php (16): m140627_074906_create_table_locations->create('tbl_locat ions', array, 'engine=innodb') #2 c:\wamp\www\yii\framework\cli\commands\migratecommand.php(385): m140627_074906_create_table_locations->up() #3 c:\wamp\www\yii\framework\cli\commands\migratecommand.php(109): migratecommand->migrateup('m140627_074906_...') #4 [internal function]: migratecommand->actionup(array) #5 c:\wamp\www\yii\framework\console\cconsolecommand.php(172): reflectionmethod->invokeargs(object(migratecommand), array) #6 c:\wamp\www\yii\framework\console\cconsolecommandrunner.php(71): cconsolecommand->run(array) #7 c:\wamp\www\yii\framework\console\cconsoleapplication.php(92): cconsolecommandrunner->run(array) #8 c:\wamp\www\yii\framework\base\capplication.php(180): cconsoleapplication->processrequest() #9 c:\wamp\www\yii\framework\yiic.php(33): capplication->run() #10 c:\wamp\www\bookmyroom\protected\yiic.php(7): require_once('c:\wamp\www\yii...') #11 {main}
can please check , let me know error facing. if there rectification require kindly let me know.
thank in advance kind support.
thanks! robindra singha
try using execute
$this->execute("create table `tbl_locations` ( 'location_name'=>'string not null', 'create_time'=>'datetime not null', 'create_user_id'=>'int(11) not null', 'update_time'=>'datetime not null', 'update_user_id'=>'int(11) not null' primary key (`id`), ) engine=innodb");
Comments
Post a Comment