Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove any records NOT in the seed file? #85

Open
joshuapinter opened this issue Nov 26, 2014 · 5 comments
Open

Remove any records NOT in the seed file? #85

joshuapinter opened this issue Nov 26, 2014 · 5 comments

Comments

@joshuapinter
Copy link
Contributor

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
Copy link

lime commented Aug 9, 2016

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

  • .seed
    • creates records if missing
    • updates attributes if they differ
  • .seed_once
    • creates records if missing
    • does not update attributes on existing records
  • .seed_exactly
    • creates records if missing
    • updates attributes if they differ
    • removes any non-listed existing records

@joshuapinter
Copy link
Contributor Author

Not bad.

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

@lime
Copy link

lime commented Aug 11, 2016

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

@joshuapinter
Copy link
Contributor Author

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

Was .seed_exactly ever implemented?

@lime
Copy link

lime commented Dec 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants