0

Suppose I have a live website running on a live database and I have a dev website that is a duplicate of the live website.

The live database is where customer transactions are stored.

What if I do some changes on the dev website and dev database like add another column in a table, how can I retain all of the customer transaction inside live but at the same time saving all the changes I did from the test website to the live website?

I am using Laravel and Mysql in case it will help to come up with a solution specifically for this tech stack.

Daniel
  • 205
  • 2
  • 12

1 Answers1

0

Typically you would stage the deployment of each of these changes and the steps you use would be the same in dev as production. In the case you describe where you are adding a column these are the steps I would take first testing them in development then applying them in production

  1. Add the column to the table in the database allowing nulls
  2. Update the application code to start writing to the new column
  3. If every row is expected to have data in that column then start running a background process/scripts/sql to backfill the missing data
  4. Update the column in the table to not allow nulls
  5. Updated the application code to start reading from the new column

The above steps come with the following assumptions: None of the application code is completing any SELECT * queries. These can break if you add new unknown columns in step 1 and it's generally considered bad practice to have SELECT * queries for this reason.

I'm assuming you have a tool that manages deployment of the code and versions. You should also consider having a database change management tool to track, version and deploy these types of database changes. I've used liquibase in the past for this.

CheeseFerret
  • 597
  • 11
  • 21