Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7701269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:56:38+00:00 2026-05-31T22:56:38+00:00

On Heroku, as soon as you push new code, the web-serving instances restart… even

  • 0

On Heroku, as soon as you push new code, the web-serving instances restart… even if the underlying database schema additions/changes (via syncdb or south migrate) haven’t yet been applied.

In many cases, this might just cause harmless errors undtil the syncdb/migrate is run soon afterward. But I’m concerned that in some cases, new code might half-work making unexpected changes in the pre-migration database.

What’s the right way to be safe against this risk?

One technique might be to add the syncdb/migrate to the Procfile so it’s run before web restart. But, in the case of multiple instances, or maybe even a case where the one old-code-instance is left running until the moment the one new-code-instance is known-up, there’s still a variant of the issue where code is talking to a DB with a mismatched schema.

Is there a ‘hold all web instances’ feature (or common best practice) for letting the migrate complete without web traffic?

Or am I being overly concerned about a risk that is negligible in practice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:56:39+00:00Added an answer on May 31, 2026 at 10:56 pm

    The safest way to handle migrations of this nature, Heroku or no, is to strictly adopt a compatibility approach with your schema and code:

    • Every additive or transformative schema change must be backwards-compatible;
    • Every destructive schema change must be performed after the code that depends on it has been removed;
    • Every code change must either be:
      • durable against the possibility that associated schema changes have not yet been made (for instance, removing a model or a field on a model) or
      • made only after the associated schema change has been performed (adding a model or a field on a model)

    If you need to make a significant transformation of a model, this approach might require the following steps:

    • Create a new database table to hold your new model structure, and deploy that migration
    • Create a new model with the new structure, and code to copy changes from the old model to the new model when the old model changes, and deploy that code
    • Execute a migration or code action to copy all old model data to the new model
    • Update your codebase to use the new model rather than the old model, deleting the old model, and deploy that code
    • Execute a migration to delete the old model structure from the database

    With some thought and planning, it can be used for more drastic changes as well:

    • Deploy code that completely removes dependence on a section of the database, presumably replacing those sections of the site with maintenance pages
    • Deploy a migration that makes drastic changes that would not for whatever reason work with the above dual-model workflow
    • Deploy code that brings the affected sections back with the new model structure supported

    This can be hard to organize and requires strict discipline and firm understanding of your code’s interaction with your database, but in practice, it does allow for most changes to be made with no more downtime than the server restart itself imposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once you have uploaded your source code to Heroku, is it possible to download
I m new to heroku. I deployed my rails 3 application in heroku and
Using: Rails 3.0.3 & Heroku & Execution Notifier & New Relic I get a
The Problem I have a Rails 3.1 app on Heroku which will soon require
so when I run heroku rake db:migrate, after pushing my latest code Heroku doesn't
I am using Heroku bamboo-mri-1.9.2 with Amazon RDS database. My app do crash on
I used to use whurl.heroku.com to make http web requests and share the responses
if in heroku i use heroku db:push --tables mytable is the integrity of the
The heroku cedar precompile my assets implicitly, even though I have written: config.assets.enabled =
In heroku app log I get: 2011-11-25T15:14:08+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/execjs-1.2.9/lib/execjs etect': Could not find a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.