I am building a product that is based on the Yii2 advanced template.
As part of this product and its future deployments, I am trying to automatically create the tables related to Authorization in a regular Yii2 migration.
E.g, when the end user installs the product and runs the regular Yii migration commands he should have a fully functional user management AND authorization active.
For authorization to work, the Yii2 RBAC documentation page states that 4 tables are needed (auth_*). The documentation states that they are created by running the following migration:
yii migrate --migrationPath=@yii/rbac/migrations
I'd like to offset this extra hassle from the end user by running this specific migration code for him inside a regular migration that will be stored in common/migrations
.
Any easy solution for this?
I have created a migrate.sh file where I put my migration commands that I need to run. This allows me to migrate from multiple places in the same time. It is quite simple, take a look here: https://github.com/Mihai-P/yii2-app-advanced/blob/master/migrate.sh
Instead of running ./yii migrate/up
i just run sh migrate.sh
that will update everything from any place.
The actual point of this is: you do not have to stick to exactly what Yii gave you. That is just a template for you to build on. Fork it, modify it, make it your own.