Skip to content

Commit 2d97915

Browse files
authored
Add index storage parameters for Postgres (#578)
1 parent d5153e3 commit 2d97915

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/ecto/adapters/postgres/connection.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ if Code.ensure_loaded?(Postgrex) do
12351235
?),
12361236
if_do(include_fields != [], [" INCLUDE ", ?(, include_fields, ?)]),
12371237
maybe_nulls_distinct,
1238+
if_do(index.options != nil, [" WITH ", ?(, index.options, ?)]),
12381239
if_do(index.where, [" WHERE ", to_string(index.where)])
12391240
]
12401241
]

test/ecto/adapters/postgres_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,13 @@ defmodule Ecto.Adapters.PostgresTest do
26942694
[~s|CREATE INDEX "posts_permalink_index" ON ONLY "posts" ("permalink")|]
26952695
end
26962696

2697+
test "create an index with storage parameters" do
2698+
create = {:create, index(:posts, [:title], options: "fillfactor=50")}
2699+
2700+
assert execute_ddl(create) ==
2701+
[~s|CREATE INDEX "posts_title_index" ON "posts" ("title") WITH (fillfactor=50)|]
2702+
end
2703+
26972704
test "drop index" do
26982705
drop = {:drop, index(:posts, [:id], name: "posts$main"), :restrict}
26992706
assert execute_ddl(drop) == [~s|DROP INDEX "posts$main"|]

0 commit comments

Comments
 (0)