I have an e-commerce application, and I have mistakenly seeded some incorrect data that has been run on production database.
What is the best practice to correct this data?
I have some new categories that I need to add and some need renaming, and I also have some products that were generated by factories which need to be deleted.
My plan is to update the category seeder, and delete the product seeder and run a migration to correct the incorrect data on prod, is this the correct way to do this?
@amiable-iguana
⚠️ First of all, it's not a good idea to run a seeder in production.
From your situation, I rather go with manual checking and remove whatever is needed. So far I know, there is no way to revert this data back in one shot.
@amiable-iguana Depending on the logic of your app.
Let's assume a case where you need to populate some categories in your database programmatically. You can use seeders or a command to do that. Seeders might be bad because it might miss your production database if your run a wrong seeder (which happens) as in your case.
I also preferer to go check the records manually and delete one by one. Or run a SQL query that delete records in a range of IDs after CAREFULLY CHECKING THE DATABASE NEW IDs
@amiable-iguana This is the concept of Database seeder.
Database seeding is populating a database with an initial set of data. It's common to load seed data such as initial user accounts or dummy data upon initial setup of an application.
The main purpose of using a seeder is to populate dummy or initial data for loading the application. Some people use it for production (including me in some cases) specifically for generating real-life data, but if you don't use it wisely, it might be messed with your existing data.