I’m currently trying to setup daily processes that will import information into my database. I have many records that fail validations, and for the most part I have methods that attempt to auto-correct them and re-save, but there are some more complex scenarios that require a user to correct some information before they’re valid. I’m trying to come up with a good way in which I can set this up and I’ve come up with two methods, but I’m not sure which I should really go with…
I figure I could import into my models like I normally do, and when they don’t pass validations then I will go ahead and save them to the database anyways and then flag them with a boolean column as “invalid”. Then I’ll setup an action and view to allow the user to see and correct all the records that have been flagged.
Pros: The pro to this method is I don’t have to create various new models/tables for each model that I’m importing into for temporary storage.
Cons: I’m still storing bad data in the table, and also would have to alter many queries to filter out invalid records based on the boolean column I would add to the model.
I create new models that mimic the model that I want to import the records into… but then I’m adding alot of logic that is shared between the two – not to mention I have a lot of additional files and code. However, this method wouldn’t have me storing invalid data in my tables.