mbleigh / seed-fu

Advanced seed data handling for Rails, combining the best practices of several methods together.
MIT License
1.23k stars 155 forks source link

Remove any records NOT in the seed file? #85

Open joshuapinter opened 9 years ago

joshuapinter commented 9 years ago

This is a question and maybe a feature request if it's not possible.

I have a seeds file for a static lookup table. I would like the table to reflect exactly what is contained in the seeds file, so if I were to remove a record from the seeds file and run a db:seed it would remove the record from the table as well.

Is this possible? If yes, what is required? If no, what would involved with supporting it?

Thanks!

lime commented 8 years ago

Would .seed_exactly be a good name if we end up implementing this as a feature?

joshuapinter commented 8 years ago

Not bad.

Is seed_once a thing? I find that name non-descriptive.

lime commented 8 years ago

seed_once is a thing, and has been since 2010. :)

joshuapinter commented 3 years ago

Wow, circling back to this 4 years later. :)

Was .seed_exactly ever implemented?

lime commented 3 years ago

No, I don't think so.

.seed and .seed_once are defined in SeedFu::ActiveRecordExtension, and the actual logic in SeedFu::Seeder. I suppose the main challenge is turning the listed constraints & data into a query, and then removing non-matching records.