Answer the question
In order to leave comments, you need to log in
What happens when a column needs to be added to a table in a large, old, running project?
Epigraph:
Just don't touch anything, son.
1. The table has one index.
2. The existing code is tied to the number of columns.
3. An additional column is not needed for all rows, even for a smaller part of them.
While I think to fence the new table "continuation to the right" with the same index. And how do gurus act in such situations. (True, the gurus probably don't allow them.)
Answer the question
In order to leave comments, you need to log in
The existing code is tied to the number of columns.
first, slowly rewrite the code that refers to the column number to the code that will refer to the column name. But this can be done later.
second, check all STUPID queries like
select * from table1
union
select * from table2
and rewrite them as
select id, name... from table1
union
select id, name... from table2
and only then add a column, it should be added last (if you write alter table through the console, the column can fit through the graphical editor and not the last one). Of course, it’s better to prepare in advance, make a copy of the table, choose the time at which no one works with this table, change it and test it yourself (for example, at 11 pm). And also warn all users in advance (if this is an internal project and in general users can be warned), so that if something happens, they immediately write. True, they can become obedient and write that their kettle in the corridor began to boil water for a long time and most likely this is all because of your "something new there", but if something really "falls" because of you, then at least you fix it right away and there is less chance that you will get a pill.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question