M
M
Maxim Timofeev2015-12-23 17:26:45
Yii
Maxim Timofeev, 2015-12-23 17:26:45

Is it possible to run a migration without a console in YII2?

I wanted to make a module installer in the backend and came across a problem with adding tables to the database. It would be convenient to upload a migration file and run it. But how to do this not from the console, but from the backend of the site? Is it possible to make a request from the backend controller to the console controller? And will it be possible to run the migration?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Arutyunov, 2015-12-23
@arutyunov

If by "module in the backend" you mean an analogue of plugins in Wordpress, then install for each module through some install () method, in which you create the necessary tables, add / delete data from them, etc.

O
OnYourLips, 2015-12-23
@OnYourLips

modules will be added to hundreds of working landingpages, while each of them may have its own characteristics, but the module as an independent unit can be added or removed at any time, which means that migrations and their rollbacks are needed. I made a landing - hung it on hosting, gave the keys to the customer. And he can buy a module from the admin panel over time.

Migrations are not suitable for your task.
It is a database versioning system.
Your module classes will look like migration classes, but they are not.
And there will be other code to use them.
The reason is the non-linear nature of their installation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question