Search code examples
elixirecto

How to bind field to a column with different name with Elixir Ecto


I'm trying to build a small app that's going to connect to legacy db. Is there a way to define Ecto model with attribute names different that table columns?

Something like:

schema "oauth_access_tokens" do
  field :token
  field :user_id, :integer, column: :resource_owner_id
end

Solution

  • Unfortunately, I don't think it's possible right now.

    A possible solution is to use views on the database level, but I'm not sure if it's a good idea.