Skip to content

Commit 3844909

Browse files
committedSep 21, 2021
Add an association with composite primary key
1 parent f096fa5 commit 3844909

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎integration_test/support/migration.exs

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ defmodule Ecto.Integration.Migration do
2727
add :intensity, :float
2828
add :author_id, :integer
2929
add :posted, :date
30+
add :composite_a, :integer
31+
add :composite_b, :integer
3032
timestamps(null: true)
3133
end
3234

@@ -108,6 +110,11 @@ defmodule Ecto.Integration.Migration do
108110
add :name, :string
109111
end
110112

113+
# TODO not sure if it is important to have a foreign keys defined properly; see other associations in "posts"
114+
alter table(:posts) do
115+
modify :composite_a, references(:composite_pk, column: :a, with: [composite_b: :b], type: :integer)
116+
end
117+
111118
create table(:corrupted_pk, primary_key: false) do
112119
add :a, :string
113120
end

0 commit comments

Comments
 (0)