title: Ruby on Rails Database Deployment with Gerrit
body: <p>I'm considering using Ruby on Rails for my next project. Understanding the deployment of a rails website is easy enough to understand (sounds like I'll be using <a href="https://www.phusionpassenger.com/" rel="noreferrer">Phusion Passenger</a>)</p>
  
  <p>But now I'm trying to figure out the database. I see a lot about "database migrations", which allow me to <em>update the database using ruby code</em>. I also see that I'm allowed to create both an <strong>up</strong> and <strong>down</strong> variant of these migrations. </p>
  
  <p>However, I can only fathom how this works cleanly in a single direction. Imagine if I suddenly say <em>"The color column cannot be null"</em>. So, the <strong>up</strong> will make it required and give all NULL entries a default value. But what will the <strong>down</strong> do? If you care about it being identical to how it started, you can't just set the default values back to NULL.</p>
  
  <p>This doesn't really matter much for releases to production. That will likely just be done in a single direction (in the <strong>up</strong> direction). <em>However, I want to use Gerrit for code reviews as well as setting up a bot to run a build before allowing check-ins...</em></p>
  
  <p>So how could that work? From one code review to the next, the build server will check out the new set of code, and run the migrations? But when this happens, it won't even retain the migration code from before, so how could it run the <strong>down</strong> steps? As an simpler example, I do not see how I could check out an old version of the code and "db migrate" backwards.</p>