Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#5163

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.

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

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • Importance changed from to Low

    Can you add test(s) for this?

    July 21st, 2010 @ 01:46 AM

  2. José Valim
    José Valim

    Rohit, unfortunately there is no easy/fast way to add tests for rake tasks. So I will apply it as it is. Thanks!

    July 21st, 2010 @ 01:55 PM

  3. Repository