Knowledgebase

Managing Database Changes During Deployment Print

  • devopsinfrastructure, devops, database, migration, troubleshooting, guide, howto, solution
  • 0

Schema and code together.

THE PROBLEM

Code and schema change together, but do not deploy simultaneously.

WHAT THAT CAUSES

Code expecting a column that does not yet exist Or a removed column that code still uses

WHAT TO DO

Make changes in stages, each compatible with both versions.

HOW THAT WORKS FOR ADDING

Add the column Deploy code that writes to it Deploy code that reads from it

HOW THAT WORKS FOR REMOVING

Deploy code that stops using it Confirm nothing uses it Remove it in a later release

WHY THAT ORDER

At no point is the schema incompatible with running code.

WHAT TO NEVER DO IN ONE STEP

Rename a column.

Add, copy, switch, then remove.

WHAT TO BE CAREFUL WITH

Migrations locking large tables Migrations that also move data

WHAT TO DO ABOUT LARGE TABLES

Understand what the change locks, and for how long.

WHAT TO ALWAYS DO FIRST

Back up.

WHAT TO TEST

The migration on a copy with realistic volume.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot