We should modify the seeders we wrote so that each one of them only runs once. The current problem is that if we ever add new seeders that we need to run, we would end up creating duplicates of database records.
i.e.,
# AndroidApps, Reviews, Replies, etc. are seeded once
php artisan db:seed
# AndroidApps, Reviews, Replies, etc. are seeded again, one duplicate of each in database
php artisan db:seed
# AndroidApps, Reviews, Replies, etc. are seeded again, two duplicates of each in database
php artisan db:seed
# ...
But we want this:
# AndroidApps, Reviews, Replies, etc. are seeded once
php artisan db:seed
# Only records that don't exist yet are seeded, records that already exist are skipped
php artisan db:seed
# Only records that don't exist yet are seeded, records that already exist are skipped
php artisan db:seed
# ...
We should modify the seeders we wrote so that each one of them only runs once. The current problem is that if we ever add new seeders that we need to run, we would end up creating duplicates of database records.
i.e.,
But we want this:
For example, here is a Voyager seeder that only runs once and here is one of our seeders that will always run.
So, we need to make a change like this for every object being seeded:
From:
To: