In this episode, we're setting up some test data so that we can try out Laravel's model pruning feature. First, we take a quick look at what pruning is and why you'd want it – basically, it's an easy way to clean up old stuff from your database, like deployments that are more than two weeks old.
We start with a clean Laravel project and empty database, then run migrations to prep our tables. Next, we build a Deployment
model along with its migration and a factory. Rather than just making a bunch of identical records, we implement a clever trick using Laravel's factory sequence
method to ensure each record gets a different created_at
date. We want some realistic data to test our pruning conditions, so this part is super important!
After generating 10,000 fake deployment records (each with a unique timestamp), we briefly peek at the database to confirm everything looks right. Now we've got our test data, we’re ready to dive deeper into Laravel’s pruning features in the next part. So basically, this episode is all about building the data playground we’ll use for experimenting with model pruning!