title: Rails migration add default not null properties to existing boolean field
body: <p>I have a rails model that has a non-defaulted boolean field that is nullable and am trying to set a default. I found a blog post about avoiding a 3-stat boolean issue, so am trying to cater for this. This is the migration I have:</p>
  
  <pre><code>def change
    change_column :table, is_foo, :boolean, null: false, default: false
  end
  </code></pre>
  
  <p>Running the migration fails because of existing null values in the database. What is the correct way to update existing entries to allow the schema change? Or should the not null control be added to the model:</p>
  
  <pre><code>validates :is_foo, presence: true
  </code></pre>
  
  <p>Not sure if adding this to the migration is the "right" way:</p>
  
  <pre><code> Table.update_all(:is_foo =&gt; false)
  </code></pre>
  
  <p>Similarly, this field was added by a migration without extra not null / default parameters. Would the migration to add column also require this, or would the default set the value? Here's the migration I ran:</p>
  
  <pre><code>add_column :table, is_foo, :boolean
  </code></pre>
  
  <p>If I had added <code>,null: false, default: false</code> on the add_column, would all the values have been set correctly?</p>