I have a question about how to properly perform a database migration, specificaly a rename column.
Suppose the table has a column A and I want to rename it to B. If I do the rename and then deploy the code that references B, after performing the migration and before deploying the code, I will have errors, because the code will not be up to date with the schema. On the other hand If I deploy the code first, I will also have errors because the code will reference the column B until the migration is performed.
So I thought that the best way would be, before deploying the code, create a new column B with the data of A and then deploy. At first I thought that this will be okay, but then I realized that new data can be inserted in the table after making the column B with the data of A. So, what is the standard way to do this?
Thanks in advance.