diff --git a/lib/ecto/adapters/postgres/connection.ex b/lib/ecto/adapters/postgres/connection.ex index 9a094e20..064623e8 100644 --- a/lib/ecto/adapters/postgres/connection.ex +++ b/lib/ecto/adapters/postgres/connection.ex @@ -1235,6 +1235,7 @@ if Code.ensure_loaded?(Postgrex) do ?), if_do(include_fields != [], [" INCLUDE ", ?(, include_fields, ?)]), maybe_nulls_distinct, + if_do(index.options != nil, [" WITH ", ?(, index.options, ?)]), if_do(index.where, [" WHERE ", to_string(index.where)]) ] ] diff --git a/test/ecto/adapters/postgres_test.exs b/test/ecto/adapters/postgres_test.exs index 0bd7623a..f03bee2e 100644 --- a/test/ecto/adapters/postgres_test.exs +++ b/test/ecto/adapters/postgres_test.exs @@ -2694,6 +2694,13 @@ defmodule Ecto.Adapters.PostgresTest do [~s|CREATE INDEX "posts_permalink_index" ON ONLY "posts" ("permalink")|] end + test "create an index with storage parameters" do + create = {:create, index(:posts, [:title], options: "fillfactor=50")} + + assert execute_ddl(create) == + [~s|CREATE INDEX "posts_title_index" ON "posts" ("title") WITH (fillfactor=50)|] + end + test "drop index" do drop = {:drop, index(:posts, [:id], name: "posts$main"), :restrict} assert execute_ddl(drop) == [~s|DROP INDEX "posts$main"|]