Yii Framework Forum: Strange error with migrations - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Strange error with migrations

#1 User is offline   parasporin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 09-October 13

Posted 13 October 2017 - 06:41 AM

I built a DB using yii’s migration classes, which worked fine. Then I dropped the tables, and when i re-ran the migrations I got the following error for migration class m170728_170811_colony:

*** applying m170728_170811_colony
Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: m170728_170811_colony::int()'
in C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\base\Component.php:290

The Stack trace is:
#0 C:\xampp\htdocs\jrweb\migrations\m170728_170811_colony.php(11): yii\base\Component->__call('int', Array)
#1 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(671): m170728_170811_colony->Up()
#2 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(183): yii\console\controllers\BaseMigrateController->migrateUp('m170728_170811_...')
#3 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#4 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#5 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\base\Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#6 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\console\Controller.php(128): yii\base\Controller->runAction('', Array)
#7 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\base\Module.php(523): yii\console\Controller->runAction('', Array)
#8 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate', Array)
#9 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate', Array)
#10 C:\xampp\htdocs\jrweb\vendor\yiisoft\yii2\base\Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request))
#11 C:\xampp\htdocs\jrweb\yii(20): yii\base\Application->run()
#12 {main}

C:\xampp\htdocs\jrweb>


When I tried to run one of the other previously working migration classes, I also got the same error for that class- does anyone have any idea why it would suddenly throw this error?

thanks
0

#2 User is offline   alrazi 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,316
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 13 October 2017 - 11:49 AM

yii is complaining about a unknown method as it says in the exception, can you post your migration file here?
0

#3 User is offline   parasporin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 09-October 13

Posted 13 October 2017 - 12:26 PM

View Postalrazi, on 13 October 2017 - 11:49 AM, said:

yii is complaining about a unknown method as it says in the exception, can you post your migration file here?



here is one of the migration files- again, they were all working and then the error just showed up after i dumped the tables and then tried to re-migrate them. I also did a pull to the test server and it is throwing the same error. I checked my version control log and since the migration file was last working, i don't see any accidental file change with yii's api, etc. ........ Thanks!

use yii\db\Migration;

class m170728_170811_colony extends Migration
{
public function Up()
{
$this->createTable('colony', [
'id' => $this->primaryKey(),
'owner' => $this->int(11),
'date_inserted' => $this->dateTime(),
'date_expired' => $this->dateTime(),
'note' => $this->string(2000),
'source_company' => $this->smallInteger(3),
'source_hive' => $this->smallInteger(3),
'source_hive_type' => $this->smallInteger(3), // split/ swarm, mix, etc.
'queen_breed' => $this->smallInteger(3),

]);
}

public function Down()
{
$this->dropTable('colony');

return false;
}


}
0

#4 User is offline   alrazi 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,316
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 13 October 2017 - 12:53 PM

I see maybe you changed something or updated yii, make the following changes and it should work
'owner' => $this->int(11), 
// to
'owner' => $this->integer(11), 

1

#5 User is offline   parasporin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 09-October 13

Posted 13 October 2017 - 01:33 PM

View Postalrazi, on 13 October 2017 - 12:53 PM, said:

I see maybe you changed something or updated yii, make the following changes and it should work
'owner' => $this->int(11), 
// to
'owner' => $this->integer(11), 



You nailed it!! Now that i see the problem it is obvious, but I was so convinced that it was some major yii api issue that i just could not see it. Thanks again, you really helped me!!!!
0

#6 User is offline   alrazi 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,316
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 13 October 2017 - 01:53 PM

no worries glad could help
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users