0

Is there a way to run migrations on Yii from code, and not from CLI?

I want to make a web interface for the user, and I want to run the migrations from code. I don't want the user to run any command in the console.

1 Answer 1

1

You can create shell exec commands and output to a HTML file, something like this

 class someController extends CController { ... public function actionMigrate(){ echo shell_exec("/path/to/YiiApp/protected/yiic migrate up"); } 

It is however not advisable to run migrations in the frontend, migrations can potentially break the application, cause existing flows or currently logged in users to experience unexpected behaviors and possibly also create data corruption depending on the type of migration being applied. So use with caution

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.