Z
Z
Zhenya Starikov2021-10-26 17:30:05
Yii
Zhenya Starikov, 2021-10-26 17:30:05

How to change table with migration history for multiple databases, yii2?

Good evening. The project uses several databases. I would like the history of table migrations of each database to be stored in a table in the corresponding database.
That is, if a table from the db1 database was changed, then a record about this was recorded in db1.migration, and if the table was from the db2 database, then in db2.migration

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2021-10-26
@kawabanga

I figured a couple of ideas right away -
1) Synchronization of the migration table to all bases comes to the forehead every time.
And here are the other two ways - 1) to specify $this->db = 'db2'
in the migration method ; 2) either make components based on the Migration base class and inherit from them, for example - MigrationDb1 MigrationDb2 and so on. And in this case, I strongly recommend separating migrations into folders.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question