A
A
Alexander David2014-08-19 14:48:43
Yii
Alexander David, 2014-08-19 14:48:43

Can I run yiic migrate and other standard commands in CConsoleCommand in Yii?

I tried it through exec , it hangs for a long time, creates the migrations table and hangs for a long time, I don’t know how long, I didn’t wait.
I would like to perform the migration and have the output also displayed as when migrating in the usual way
Command example:

class DeployCommand extends CConsoleCommand {
  public function actionIndex() {
    exec('yiic migrate'); // это нельзя как-нибудь средствами фреймворка сделать?
  }
}

there is some kind of run method
but I don't really understand how it works and what it does :/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Devid, 2014-08-19
@alexdevid

Happened

protected function applyMigrations() {
  Yii::import('system.cli.commands.MigrateCommand');
  $command = new MigrateCommand('migrate', new CConsoleCommandRunner);
  $command->run(['up']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question