Last active
March 22, 2017 19:08
-
-
Save aleandros/027418c3a6062f9971027ed2cf494e3a to your computer and use it in GitHub Desktop.
Ecto model relationships with non-default column names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.User do | |
use MyApp.Web, :model | |
@primary_key {:UserId, :id, autogenerate: true} | |
schema "user" do | |
has_one :credential, MyApp.Credential, | |
foreign_key: :UserId, | |
references: :UserId | |
many_to_many :roles, MyApp.Role, | |
join_through: MyApp.UserRole, | |
join_keys: [UserId: :UserId, RoleId: :RoleId] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment