---
title: "Discussion on \"Create a sorted Index in Ecto\" | Hashnode"
description: "Discussion on \"Create a sorted Index in Ecto\". defmodule MyApp.Repo.Migrations.AddMessagesInsertedAtIndex do\n  use Ecto.Migration\n\n  @disable_ddl_transaction true\n  @disable_migration_lock true\n\n  def change do\n    create index(\"messages\", [\"inserted_at DESC\"], concurrently: true)\n  end\nend\n\nif y..."
url: "https://hashnode.com/posts/create-a-sorted-index-in-ecto/64fc5abfc16b675b241bdb3b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Create a sorted Index in Ecto](https://www.maqbool.net/create-a-sorted-index-in-ecto?utm_source=hashnode&utm_medium=feed)

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 y...

Sep 9, 2023 · 1 min read · maqbool.net  
Updated Sep 20, 2023  
Read the article

-   [#ecto](https://hashnode.com/tag/ecto)
-   [#elixir](https://hashnode.com/tag/elixir)

## Written by

[Maqbool](https://hashnode.com/@maqbool)

@maqbool · Remote

  
[View profile](https://hashnode.com/@maqbool)

Software Developer @ Underjord AB

spawn(fn -&gt; @elixirlang/@elmlang developer end)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
