Question

Ruby rake db:seed aborting due to ** Execute db:abort_if_pending_migrations, but I think all the migrations were successful.

Here's the last portion of the output when I run rake db:migrate --trace

    ** Invoke db:load_config (first_time)
    ** Execute db:load_config
    ** Execute db:migrate
    ** Invoke db:_dump (first_time)
    ** Execute db:_dump
    ** Invoke db:schema:dump (first_time)
    ** Invoke environment 
    ** Invoke db:load_config 
    ** Execute db:schema:dump

I assume that mean it was successful (I didn't see any aborts)?

Then when I run rake db:seed --trace I get (in summary):

    ** Invoke db:seed (first_time)
    ** Execute db:seed
    ** Invoke db:abort_if_pending_migrations (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    loading plugins

(the plugins load with no errors) then:

    ** Execute db:abort_if_pending_migrations

does this mean the migration and the seed worked properly or not? Thank you for your time & input!

Était-ce utile?

La solution

If it didn't abort, it succeeded. Take a look at the code:

# desc "Raises an error if there are pending migrations"
task :abort_if_pending_migrations => :environment do
  pending_migrations = ActiveRecord::Migrator.open(ActiveRecord::Migrator.migrations_paths).pending_migrations

  if pending_migrations.any?
    puts "You have #{pending_migrations.size} pending #{pending_migrations.size > 1 ? 'migrations:' : 'migration:'}"
    pending_migrations.each do |pending_migration|
      puts '  %4d %s' % [pending_migration.version, pending_migration.name]
    end
    abort %{Run `rake db:migrate` to update your database then try again.}
  end
end

It literally does nothing if there aren't any pending migrations.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top