E
E
EvgMul2020-02-21 21:14:56
Yii
EvgMul, 2020-02-21 21:14:56

How to perform a specific migration in yii1?

Hello. Let's say I have 10 unapplied migrations. I need to complete only one of them, which is in the middle of the list. Can you tell me, please, what command to do this?
Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-02-21
@EvgMul

Migrations are database versioning.
Logically, it cannot be that you need a migration in the middle, but not in front of them. Since before them there may be dependencies for subsequent ones.
For example, there are 6 migrations. The first 3 create tables. The next 3 add new fields to them. If you apply only the last 3, then you will get the error "there is no such table in the database". Therefore, it is impossible and does not make any sense to take and apply migration from the middle. You can only bring the database to a certain state. More details are in the documentation .
However, if you really need to do this, then there is a life hack. Delete all migrations from the folder except for the ones you want to apply and apply them. Then check back the previously deleted migrations into the folder. But this is not recommended. It's a crutch!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question