Strance
(Shahrulhadi)
March 24, 2025, 7:50am
1
I has set Yii::$app->db and Yii::$app->db2;
I add this code to the migration class
public $db = ‘db2’;
command yii migrate still apply the migration to default database connection which is db, not db2
then i add this to the migration class
protected function getDb()
{
return Yii::$app->db2;
}
still command yii migrate apply to db, not db2
so i need to do command yii migrate --db=db2 to make it work.
I want to just use command yii migrate and db selection determine by the migration class.
BartQ76
(Bartek)
March 24, 2025, 8:44am
2
Hi.
[…] command yii migrate still apply the migration to default database
This behaviour, with the solution ready to apply is described in the API.
Have a look:
Strance
(Shahrulhadi)
March 26, 2025, 6:17am
3
My bad, i should has check the doc properly instead of just rely on chat gpt.
Thanks for helping.
Wait, what…I am sorry, I felt a little cringe with the chatGPT thing, but I guess it’s the new way now.
Strance
(Shahrulhadi)
April 7, 2025, 3:53am
5
lol, i know the limitation of chat gpt, has been correcting that AI many time, but this time i just so lazy to double check in the yii2 doc or could also say feel too comfortable with chatgpt when it give correct solution many time before that, so it happen, a blunder on my part.
1 Like