This project is archived and is in readonly mode.

#5163 ✓resolved
Thiago Pradi

rake db:seed should check if the database have pending migrations

Reported by Thiago Pradi | July 20th, 2010 @ 07:04 PM

Hi guys,

I'm using rake db:seed to populate my database, but I found a weird behavior.

The scenario:

tchandy ~ $ rails new sample_application
      create  
      create  README
....
tchandy ~ $ cd sample_application/
tchandy ~/sample_application $ rails g model User name:string
      invoke  active_record
      create    db/migrate/20100720174836_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/unit/user_test.rb
      create      test/fixtures/users.yml

This is my seeds.rb:

  User.create!(:name => "Thiago")

When I run:

tchandy ~/sample_application $ rake db:seed   
(in /Users/tchandy/sample_application)
rake aborted!
Could not find table 'users'

(See full trace by running task with --trace)

Is this behaviour normal? My opinion is that rake db:seed should check if the database have pending migrations.

The attached patch checks if the database have pending migrations, and after this, runs the db:seed.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages