Migration macros for adding the columns expected by Lazarus.Schema.
Use this module inside create table(...) or alter table(...) blocks to
add the deleted_at column and optional deletion-reason column that your
schemas expect.
Example
use Lazarus.Migrations
create table(:posts) do
soft_deletes()
endYou can also use the helper inside alter table(...).
Per-call options
soft_deletes(
include_reason: true,
deleted_at_type: :utc_datetime_usec
)Repo configuration
Defaults can be configured per migration Repo:
config :my_app, MyApp.Repo,
migration_soft_deletes: [
include_reason: true,
deleted_at_type: :utc_datetime_usec
]soft_deletes/1 merges repo-level defaults with the per-call options, with
per-call values taking precedence.
Keep migration and schema helpers aligned so the columns added here match the
fields declared with Lazarus.Schema.
Summary
Functions
Adds soft-delete columns inside a migration block.
Functions
Adds soft-delete columns inside a migration block.
Defaults for :deleted_at_type and :include_reason can be configured on the migration repo with :migration_soft_deletes.
Options:
:deleted_at_type- column type for the deleted-at field. Supported values::utc_datetime,:utc_datetime_usec,:naive_datetime,:naive_datetime_usec(default::utc_datetime_usec):include_reason- adds the deletion-reason field when true (default:true)
The deletion-reason column is always added as :text when included.