title: How to add validation in migration file (Rails 4)
body: <p>I'm trying to add validation at the database level. For the model file it was no problem but now for the migration file, I just don't get how to do this. I am using SQLite for development (following Hartl's tutorial but adapting the instructions for my own app).</p>
  
  <p>I have the two following migration files:</p>
  
  <pre><code>class CreateUsers &lt; ActiveRecord::Migration
    def change
      create_table :users do |t|
  
        t.string  :email,           null: false
        t.string  :email_confirm,   null: false
        t.string  :username,        null: false
        t.text    :bio
        t.string  :location,        null: false
        t.boolean :activated,       default: false
        t.datetime :activated_at
  
        t.timestamps             null: false
      end
    end
  end
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>class AddIndexToUsersEmailAndUsername &lt; ActiveRecord::Migration
    def change
      add_index :users,  :email,         unique: true
      add_index :users,  :username,      unique: true
    end
  end
  </code></pre>
  
  <p>But the validations do not end up in schema.rb:</p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20150410200022) do
  
    create_table "Users", force: :cascade do |t|
      t.string   "email"
      t.string   "email_confirm"
      t.string   "username"
      t.text     "bio"
      t.string   "location"
      t.boolean  "activated"
      t.datetime "activated_at"
      t.datetime "created_at",    null: false
      t.datetime "updated_at",    null: false
    end
  
    add_index "users", ["email"], name: "index_users_on_email", unique: true
    add_index "users", ["username"], name: "index_users_on_username", unique: true
  
  end
  </code></pre>
  
  <p>So <code>null:false</code> and <code>default:false</code> are not in schema.rb and apparantly Rails is not implementing these validations. How should I implement these validations in the migration file? </p>
  
  <p>I've also tried using <code>change_column_null</code> and <code>change_column_default</code> instead but with the same result/schema.rb.</p>