1
1
123 1232017-05-18 06:36:57
MySQL
123 123, 2017-05-18 06:36:57

Migrations can drop the project, what to do?

In my project, I use yii/migrate, once during the deployment I raised the migrations and then it happened. Because of the migrations, the database shut down, after which MySQL fell altogether. The reason was too large table with a large number of records, and in migrations there was ADD COLUMN How to be, how can you make sure in such cases, except for testing?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Aksentiev, 2017-05-18
@Sanasol

apart from testing

And what about testing?
If there is a large table, it will change for a long time anyway.
The more - the longer.
To do this, you need to go to those. work and the site to disable.

E
Eugene Wolf, 2017-05-18
@Wolfnsex

Because of the migrations, the database shut down, after which MySQL fell altogether.
This is MySQL, it happens to him.
The reason was too large table with a large number of records, and in migrations there was ADD COLUMN How to be, how can you make sure in such cases, except for testing?
I'm not 100% sure (I haven't woken up yet to think too soberly), but it seems to me that there are 2 main options for solving the problem:
1. Do not use MySQL
2. Use replication in MySQL
The reason was too large table with a large number of records
It seems to me that the most likely problem was a too weak machine (memory, processor, disk) for such a volume of database data, and not a too large table :)

F
Fortop, 2017-05-18
@Fortop

You don't need to stop anything.
There is a table T.
The scheme is simple.
1. First, create an empty table T1 with the desired structure. That is, with the column already added.
2. Then we copy the data from T to T1.
3. If the entry in T is very active, then you may have to repeat the copy process for the data that was added while we were copying the original ones.
4. When the copying period becomes small, turn off the data recording in T.
5. Make the final synchronization.
6. Rename T to T_OLD.
A T1 rename to T
7. Enable writing to T

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question