orator icon indicating copy to clipboard operation
orator copied to clipboard

Is there anyway I can physically delete a row even if the model is set to softdelete?

Open tonyzhangcn opened this issue 6 years ago • 3 comments

Hi, I have a model which inherited from SoftDelete, in most cases I need it to be soft delete but in some rare cases I need it to be deleted physically, I tried the force_delete() but it worked the same as delete, not solving my problem. Any idea is appreciated!

tonyzhangcn avatar Jul 04 '18 02:07 tonyzhangcn

force delete should delete it permanently for your use case. I'll test this out sometime today or tomorrow and verify that it's working properly

josephmancuso avatar Jul 04 '18 11:07 josephmancuso

Thanks for the quick reply!

tonyzhangcn avatar Jul 07 '18 04:07 tonyzhangcn

soft delete not work


class User(SoftDeletes, Model):

    # 设置真正的表名
    __table__ = 'student'

    # 禁用时间自动更新 created_at updated_at
    __timestamps__ = False

    # 继承 SoftDeletes 使用软删除
    __dates__ = ['deleted_at']



User.where('id', '=', 19).delete()
'DELETE FROM `student` WHERE `id` = 19'

mouday avatar Dec 10 '19 15:12 mouday