For a schema to be soft-deletable, it needs a deleted_at field.
You can use the schema helper to include deleted_at and deletion_reason
fields.
Example
use Lazarus.Schema
schema "posts" do
soft_deletes()
endOptions
You can configure the following :
include_reason- determines whether or not to includedeletion_reasonfield. Set totrueby defaultdeleted_at_type- determines the type ofdeleted_atfield. Set to:utc_datetime_usecby default
Supported options:
include_reason-true,falsedeleted_at_type-:utc_datetime,:utc_datetime_usec,:naive_datetime,:naive_datetime_usec
Per-call options
soft_deletes([
include_reason: false,
deleted_at_type: :utc_datetime
])Module options
@soft_deletes_opts [
include_reason: false,
deleted_at_type: :utc_datetime
]Set up migrations
Make sure your migrations and schema match. Learn more from Migration Setup guide.