soft_delete_helper_module v0.0.1 SoftDeleteHelperModule.Migration

Contains functions to add soft delete columns to a table during migrations

Link to this section Summary

Functions

Adds an index on is_deleted column of the given table

Adds deleted_at and is_deleted column to a table. This column is used to track if an item is deleted or not and when

Link to this section Functions

Link to this function

create_index_on_soft_delete(table_name)

Adds an index on is_deleted column of the given table

Parameters

  • table_name: the table for which the index has to be created
Link to this function

soft_delete_columns()

Adds deleted_at and is_deleted column to a table. This column is used to track if an item is deleted or not and when

defmodule MyApp.Repo.Migrations.CreateUser do
  use Ecto.Migration

  import SoftDeleteHelperModule.Migration

  def change do
    create table(:users) do
      add :firt_name, :string

      soft_delete_columns()
    end
  end
end