Problem description: rake aborted occurs when the rails project executes rake DB: migrate data migration,
Solution: Check the prompt and run bunlde exec rake DB: migrate. The migration is successful!
Knowledge added: difference in using bundle exec rake DB: migrate (derived from: http://www.iteye.com/problems/73157)
① Bundle provides a sandbox-like mechanism for rails projects, which has many advantages. To put it simply, we can ensure that the project is mainly dependent on the gem version, and rails 3 is changed from gem to core.
What does bundle exec do? Execute bundle-h to see:
"Bundle exec (1) bundle-exec.1.html
Execute a script in the context of the current bundle"
To maintain the working environment, bundle copies the configuration file gemfile to maintain the uniform gem version. Therefore, you can use the same gem for multiple projects, but different versions.
② Is there any difference between bundle Exec: rake DB: migrate is a database transplant. Then, a rake gem is actually called here, so if your system has multiple rake, for example, your system is 0.9, but you write the rake version 0.8.7 in the gemfile of this project. When there are many projects, it is entirely possible that some projects do not have the upgraded gem version. Then, write bundle exec will call rake of 0.8.7 for execution. If you do not write it, the system will call the latest version, that is, rake of 0.9 by default. Therefore, an error may occur.