G
G
gto61202017-01-25 16:41:28
git
gto6120, 2017-01-25 16:41:28

How to correctly reflect the use of migration from vendor in VCS?

Good afternoon. The question is how to capture in eternity the fact that you applied the migration, but not your own, which you have in the form of a project code, but the one in the vendor yii2 folder of the framework (this folder is under .gitignore as usual). I see an option to transfer the migration from the vendor inside the project, but this is somehow crooked, because updating a third-party extension can also affect the migration (the extension has been updated, new tables are required, for example), and then I will have to manually transfer the changes, there may be more problems , intuitively feel that this is wrong.
And there is such a moment that by applying the migration from the vendor:

php yii migrate [email protected]/rbac/migrations/

I find that the tables created are not related to my user table by a foreign key.
bfee8b2fefcf477db167ec345f431967.PNG
Now I need to fix this somehow, but I don’t even know how: you can’t get into the database with your hands, the migration is outside the editable part of the project ... It turns out that you still need to drag it inside? How do you solve such problems?
Please do not throw tomatoes, I just rolled up the advanced template and I want to see the work of rbac in action and at the same time practice working with git.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-01-25
@gto6120

In my opinion, you need to rewrite the migration controller (create your own and connect it in the config)
Here is an example for two databases, but there is an example of a config for a custom controller:
https://habrahabr.ru/post/279701/
Further, in the migrate action, you can add copying the file to the console/migrations folder for example and having them in the project regardless of changes in the vendor.

E
Evgeny Bukharev, 2017-01-25
@evgenybuckharev

/**
 * Class m170113_172800_add_subscribe_table.
 */
class m170113_172800_add_subscribe_table extends \backend\modules\subscribe\migrations\m170113_150000_subscribe
{

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question