Skip to content

Commit 7314c46

Browse files
authored
docs: add example of PARTITION BY in table/2 (#446)
Add an example of PARTITION BY option for databases that support table partitioning in table/2 function. The provided example is tested for PostgreSQL
1 parent 1acfb2a commit 7314c46

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/ecto/migration.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,12 @@ defmodule Ecto.Migration do
659659
add :name, :string
660660
add :price, :decimal
661661
end
662+
663+
create table("daily_prices", primary_key: false, options: "PARTITION BY RANGE (date)") do
664+
add :name, :string, primary_key: true
665+
add :date, :date, primary_key: true
666+
add :price, :decimal
667+
end
662668
663669
## Options
664670
@@ -674,7 +680,8 @@ defmodule Ecto.Migration do
674680
overridden in said constraints/references.
675681
* `:comment` - adds a comment to the table.
676682
* `:options` - provide custom options that will be appended after the generated
677-
statement. For example, "WITH", "INHERITS", or "ON COMMIT" clauses.
683+
statement. For example, "WITH", "INHERITS", or "ON COMMIT" clauses. "PARTITION BY"
684+
can be provided for databases that support table partitioning.
678685
679686
"""
680687
def table(name, opts \\ [])

0 commit comments

Comments
 (0)