orator
orator copied to clipboard
Is there anyway I can physically delete a row even if the model is set to softdelete?
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!
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
Thanks for the quick reply!
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'