In this episode, we focus on updating the import job so we can keep track of how many rows have been processed. We start by cleaning up the database, deleting old imports, and truncating the customers table to set up for a fresh import.
The main thing we want to do is increment the processed_rows
column in our import job record as new rows are inserted. I show you a couple of different ways to do this—either manually updating the count, or using a neat increment function to automatically bump the column based on the affected rows. It's a quick and clean approach using the result of our insertion logic.
After wiring this up, we test it by importing a file and watching the database update in real time. There's a quick hiccup with the queue not running, but we restart it, re-import, and see the processed_rows
increasing as expected in the database until all rows are done.
By the end of this episode, you'll have a process that keeps your import job's row count accurate while it runs. In the next episode, we'll look at marking the whole job as completed when everything's done!