views:

233

answers:

0

I have a rails project with seeds that are executed using rake db:seed. This in turn loads the RB files in the db/seeds directory which in turn executes something like this:

Fixtures.create_fixtures("db/seeds","projects")

There is a projects.yml in the form

project_name1:
  property: value

project_name2:
  property: value

In the projects SQL table there are existing projects records. Some of the ones in the YML file are new and others are not. I spent several days running DB seeds and it would change some of the project IDs but not others. But it wouldn't duplicate the ones that it didn't change the ID of even though all of them are in the YML file. So some of the records it was okay with, others it would remove and re-add with a new id (or just update the ID outright, not sure which).

Then suddenly it stopped doing this. I drop and reload my database as normal (using sql dumps to get back to a clean, unaltered state) but DB seeds runs perfectly leaving the existing data alone and only adding the new data (even though all of it is in the yml file) without touching the existing IDs.

Then suddenly again, it started doing it again. I've spent two weeks searching google for anything on seeds, existing data seeding and ID updating with no luck.

Any help is of course appreciated.