Create a sorted Index in Ecto

MaqboolMaqbool
1 min read
defmodule MyApp.Repo.Migrations.AddMessagesInsertedAtIndex do
  use Ecto.Migration

  @disable_ddl_transaction true
  @disable_migration_lock true

  def change do
    create index("messages", ["inserted_at DESC"], concurrently: true)
  end
end

if you have multiple Elixir application nodes don't forget set the advisory lock

config :wave, Wave.Repo, migration_lock: :pg_advisory_locke
0
Subscribe to my newsletter

Read articles from Maqbool directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Maqbool
Maqbool

spawn(fn -> @elixirlang/@elmlang developer end)