How to modify existing field with Ecto Migrations

How to modify existing field with Ecto Migrations

This is a small tutorial explaining how to create a migration to modify an existing field using Ecto migrations.

To generate a migration we need to run the command:

mix ecto.gen.migration change_my_field_to_null

This will create a new field called 20220128073919_change_my_field_to_null.exs, in the default path priv/repo/migrations (except if your using some extra library).

The timestamp on the file will be diferent for yours file.

The file generated will look something like this:

defmodule VskLanding.Repo.TenantMigrations.ChangeDateAtMandatoryActivities do
  use Ecto.Migration

  def change do
    # your migration will be here
  end
end