• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ALERT: Model soft deletes have changed the underlying data structure

#1
A heads up for any developers working on a CI4 codebase. I just merged in a breaking change to the way soft deletes work. Instead of being a simple boolean flag called deleted, the default field has been changed to a new column called deleted_at. This should be either a DATETIME or INTEGER column that matches what that table is using for created_at and updated_at.

This not only brings it in line with the other timestamps across the Model and Entities, but provides a better chance for data forensics on the case something gets deleted so you can help your client figure out what might have caused things to go missing.

I have been thinking about this change for a while now, as I'm not really sure why I originally created it as a boolean. Probably an artifact from examining several MY_Model classes that were popular from previous versions of CI. If that change was ever going to happen, it had to happen prior to a Release Candidate.

I know this will likely cause some headaches for people that have already started projects on CI4 beta, but this is the last expected breaking change prior to a RC (which is close!).
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#2
Thanks for the update Lonnie.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Soft deleted rows can still be updated. This might not be particularly useful, but since `deleted_at` only affects the "find" methods (which can themselves be overridden using `withDeleted`) you could conceivably have an application that would have updates after soft deletion. Off the top of my head, I work with one app that "publishes" and "unpublishes" items regularly that would benefit greatly from such a distinction.
Reply

#4
I really like the idea of soft deletes, great work.
Practical guide to IgnitedCMS - Book coming soon
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.