L
L
lebedev1212018-10-17 01:05:10
Yii
lebedev121, 2018-10-17 01:05:10

Changing history of Yii2 migrations?

It's already night, I decided to read the documentation, but apparently I'm very stupid. Please tell me in what cases it may be necessary to change the migration history?
5bc65eeb01920055844650.png
And another question. Let's say I created the news table, already filled it with data, and after a week I decide to change the type of the content field from text to longtext. How can I do this without losing data? Is it possible somehow to make such changes in my favorite phpmyadmin, and then make it so that it is taken into account in the history of migrations.? Or is it not possible to do without creating a new migration?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idexdv, 2018-10-30
@idexdv

You can also perform this type change without rolling back the migration.
1. Change the field type in the database (text -> longtext) using PMA - it will work without problems (if you're afraid - make a backup).
2. Manually correct the field type in the migration file
- if it was then replace it with (or 'MEDIUMTEXT', if you need less). Everything will work! If you need a reinforced concrete version, then 1. Create a new migration file, 2. Specify in it the command to change the field type in the database. Cons: - extra migration file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question