Request a Call Back

How to handle database migrations in a fully automated CI/CD pipeline without data loss?


We've automated our application code deployments, but database changes are still a manual, scary process. How are modern DevOps teams handling SQL schema changes within the CI/CD pipeline? We use PostgreSQL and are worried about a failed migration locking up the production database or causing data corruption. Are there specific tools that allow for "dry runs" or automated rollbacks of the database state?


   2024-03-22 in Software Development by Richard Wilson | 11210 Views


All answers to this question.


You absolutely need to look into tools like Liquibase or Flyway. These tools treat your database schema as version-controlled code. In a CI/CD pipeline, the tool checks a "schema_version" table and applies only the missing migration scripts. For safety, we always run migrations in a staging environment that is a clone of production first. Also, follow the "expand and contract" pattern: first, add the new column (expand), then deploy code that uses both, and finally delete the old column (contract). This avoids downtime and allows the code to function even if a rollback is needed.

   Answered 2024-03-25 by Susan Walker


Are you using a specific ORM like Entity Framework or Sequelize, or are you writing raw SQL migration scripts for your pipeline?

   Answered 2024-03-27 by Steven Hall

  • We are using raw SQL scripts because we want full control over the execution plan. My main fear is a long-running ALTER TABLE command locking the UI. How do you handle migrations that might take several minutes to run on a table with millions of rows?

       Commented 2024-03-29 by Jeffrey Young


We use a "pre-deployment" job in our pipeline that runs the migration. If the migration script fails, the entire deployment stops before the new code is even touched.

   Answered 2024-03-31 by Linda Young

  • This is a solid fail-safe, Linda. It ensures the environment state matches the code requirements before anything goes live.

       Commented 2024-04-01 by Susan Walker



Write a Comment

Your email address will not be published. Required fields are marked (*)




Suggested Questions

Introduction to Project Management..
Posted 2026-07-07 by learnersera.
Balancing Link Metrics With Structural Entity Maps..
Posted 2025-05-12 by learnersera.
Balancing Link Metrics With Structural Entity Maps..
Posted 2025-05-12 by learnersera.
Impact of Entity Authority on Organic Competitive..
Posted 2025-01-04 by learnersera.
Backlinks vs Entity Authority for SEO Rankings..
Posted 2025-04-14 by learnersera.
How are modern agile organizations evaluating scrum..
Posted 2025-07-19 by learnersera.
Is a specialized technical degree required to..
Posted 2025-10-05 by learnersera.
How heavily do hiring managers weigh professional..
Posted 2025-09-12 by learnersera.

Disclaimer

  • "PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc.
  • "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA.
  • COBIT® is a trademark of ISACA® registered in the United States and other countries.
  • CBAP® and IIBA® are registered trademarks of International Institute of Business Analysis™.

We Accept

We Accept

Follow Us

 facebook icon
 twitter
linkedin

Instagram
twitter
Youtube

Quick Enquiry Form

WhatsApp Us  /      +1 (713)-287-1187