Closed basimsahaf closed 2 years ago
@tangyang9464 @closetool @sagilio
@JalinWang @imp2002
/cc @tangyang9464
@JalinWang @imp2002
Maybe we should allow users to customize the table structure instead of using the default CasbinRule
. The current NewAdapterByDBWithCustomTable
is not working, we need to improve it.
@tangyang9464 that would be great.
The way others can make it work while there is a permanent fix is to manually change the structure of CasbinRule
, you can insert a new column (or replace any of the existing ones) called deletedat
with type *time.Time gorm:"column:deletedat
. If gorm sees this column, it will automatically soft delete the entries without changing anything in the implementation (https://gorm.io/docs/delete.html#Soft-Delete)
@tangyang9464 that would be great.
The way others can make it work is that if you change the structure of
CasbinRule
, you can insert a new column (or replace any of the existing ones) calleddeletedat
with type*time.Time gorm:"column:createdat
. If gorm sees this column, it will automatically soft delete the entries without changing anything in the implementation (https://gorm.io/docs/delete.html#Soft-Delete)
@basimsahaf This is not a generic field, so we will try to implement it through a custom structure
@tangyang9464 yeah, I wrote that answer for others so they can make this work while you come up with a fix.
@tangyang9464 yeah, I wrote that answer for others so they can make this work while you come up with a fix.
@basimsahaf This is exactly what we are looking for. Unfortunately, the gorm-adapter currently does not support adding fields
@basimsahaf you can implement and customze an adapter with soft-delete
I've been meaning to implement soft delete on my
casbin_rule
table i.e have adeactivated_at
column that is set to the time it the policy was deleted instead of completing nuking the row from the table. This function called here mentions in the documentation that if the table has a DeletedAt column, it'll perform the soft delete. So I added a new column calleddeletedat
but it didn't really workAny ideas or tips?