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

Frequent false positives on "isolate seed data" #399

Open
hakanai opened this issue Feb 15, 2023 · 0 comments
Open

Frequent false positives on "isolate seed data" #399

hakanai opened this issue Feb 15, 2023 · 0 comments

Comments

@hakanai
Copy link

hakanai commented Feb 15, 2023

While I agree with "isolate seed data" as a best practice, most of the cases where we're tripping this warning aren't cases which could be sensibly moved to seed data.

For example, it also occurs on migrations half way through the lifecycle of our application - years after the production server was created - which are in migrations specifically because they do need to be run on production servers to bring the database to a consistent state.

If we moved such code to the seeds, they would not be run, so the production server wouldn't work anymore.

Example: Say you have some category type, where all items must have a category. When you create the server for the first time, there are no items, and thus no need for any categories. You want to leave category creation to the site admin, but in the migration where you introduce categories for the first time, you have to create some category to assign to all the existing items, otherwise the database is in an inconsistent state. Leaving it nil and dealing with the nil from the code is dirtier, so what we do is create a placeholder category and then assign that for all current items.

In the meantime, is there a way to suppress individual cases of this, or is skipping the entire file the only option?

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

1 participant