just felt the need to actually test a migration—like literally write a test for an “add_slug_columns.php” migration.
anyone else ever had this need or something similar? specially because this migration will actually put data on this new column. 🤔
How do you approach migrations that require to add or alter data? We used to do it in the migration itself but later moved to keep the migration for changibg the schema and creating a seeder for the data manipulation. Never been happy with either solurion.
Just because I need to remember to run the seeder in order to populate/fix the data. It's not obvious, and also that means running a seeder on production, and when you see the promt asking if you are sure... I always get cold feet 😅
That's why I'm curious how you approach this.
I sometimes use a command instead of a seeder, to create some specific records. But that's still something you need to remember to run. Not sure if there's a smarter/frictionless solution.
Maybe you could just add a memo in the README of the project: "when this happens, add these records to the XY table: ..."
We have been manipulating data in the migration itself. What issues did you face @albert ?
Yep, we used to use commands in the past, but we moved to use seeders. It's usually a run it one time fix, and we do not want to overcrowd the commands namespace with this kind of actions.
On your question: I guess I will test the integirity of the db itself, make sure the column exists and the required data is is in place.