Your problem is that rake db: reset not only reduces and recreates the database, but it also carries over seeds as well , therefore, essentially, this happens:
rake db:drop rake db:create rake db:schema:load
and then you run:
rake db:migrate
Obviously, from this, if you just stop running the db rake: prepare the command, your problem will disappear. However, to avoid this in the future, I highly recommend inserting some logic into your seed file. This is just Ruby, so you can wrap the User creation in an if statement, for example:
unless User.find_by( email: " example@railstutorial.org " )
This will be especially valuable if you have a production site that still uses seed data (for example, the SiteSetting table); you need to make sure that the data gets into your production database, but you will create duplicate records (or errors) that start the seed, without discarding.
For additional help to answer your question, see the selected answer to this .
Hope this provides all the information you need!
source share