Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
fix: Make FakeContentTableSeeder runnable several times #2099
I wanted to run the FakeContentTableSeeder several times but I figured it would only work once with a fresh DB. That is because it is first creating a new account, adding the contacts, then creating a second account.
When relaunching it, it would randomly get a ContactFieldType instance, that could belong to account number 2 whereas we run the seeder as account number 1. Then, the following failure is triggered:
because it tries to access a ContactFieldType owned by account 2 whereas it queries account_id=1.
The fix I propose scopes the request to the current account and only creates the account firstname.lastname@example.org if it does not exist yet.
As a result, one can now run FakeContentTableSeeder more than once regardless of the DB state.