# Migration Setup

For a schema to be soft-deletable, it needs a `deleted_at` field, and
corresponding fields in the database.

You can use the migration helper to include `deleted_at` and `deletion_reason`
fields.

## Example

```elixir
use Lazarus.Migrations
create table(:my_table) do
  soft_deletes()
end
```

## Options

You can configure the following :

- `include_reason` - determines whether or not to include `deletion_reason`
  field. Set to `true` by default
- `deleted_at_type` - determines the type of `deleted_at` field. Set to
  `:utc_datetime_usec` by default

Supported options:

- `include_reason` - `true`, `false`
- `deleted_at_type` - `:utc_datetime`, `:utc_datetime_usec`, `:naive_datetime`,
  `:naive_datetime_usec`

### Per-call options

```elixir
soft_deletes([
  include_reason: false,
  deleted_at_type: :utc_datetime
])
```

### Project repo config

```elixir
config :my_app, MyApp.Repo,
  migration_soft_deletes: [
    include_reason: false,
    deleted_at_type: :utc_datetime
  ]
```

## Set up schemas

Make sure your migrations and schema match. Learn more from
[Schema Setup](schema-setup.md) guide.
