How do you change a schema safely on a live system?

SQL keys and table design · Experienced

Model answer

Use versioned migrations in source control, make additive changes first (add a nullable column, backfill, then add constraints), deploy code that works with both old and new schema, and remove old columns later. Test on a copy of production data and know how to roll back.

Learn this topic

Keys and Table Design: Why Data Is Split Into Tables in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions