title: Can NOT insert data into database in migration?
body: <p>I am using Rails 3. I don't know if it is the rule of rails that inside migration, it seems I can not insert data into database table. If someone can confirm it is so.</p>
  
  <p>I tried the following things:</p>
  
  <p>I have two ActiveRecord model:</p>
  
  <pre><code>class Car &lt; ActiveRecord::Base
    has_many :users
    ...
  end
  
  class User &lt; ActiveRecord::Base
    belongs_to :car
    ...
  end
  </code></pre>
  
  <p>I have generate a migration file, inside the migration I have:</p>
  
  <pre><code> def self.up
      default_car = Car.new({:name =&gt; 'default_car'})
      default_car.save() #I got 'false' here
  
      User.create!(:car_id =&gt; default_car.id}) #I got default_car.id is null value
  
    end
  
    def self.down
      default_car = Car.find({:name =&gt; 'default_car'})
      default_user = User.find({:car_id=&gt;default_car.id})
  
      default_car.delete
      default_user.delete
    end
  </code></pre>
  
  <p>I got <strong>false</strong> when I trying to save the default_car to database, and my default_user have <strong>null</strong> car_id. </p>
  
  <p>Is it because in migration, it is <strong>NOT allowed</strong> to store data into database??</p>