How to do migrations in Polymorphic association?

ecto
phoenix

#1

Polymorphic association concept let you use the same schema for different tables, like the doc says:

we can use separate tables for each association. Let’s start over and define a new Comment schema:

defmodule Comment do
  use Ecto.Schema

  schema "abstract table: comments" do
    # This will be used by associations on each "concrete" table
    field :assoc_id, :integer
  end
end

Notice we have changed the table name to “abstract table: comments”. You can choose whatever name you want, the point here is that this particular table will never exist.
Now in your Post and Task schemas:

defmodule Post do
  use Ecto.Schema

  schema "posts" do
    has_many :comments, {"posts_comments", Comment}, foreign_key: :assoc_id
  end
end

defmodule Task do
  use Ecto.Schema

  schema "tasks" do
    has_many :comments, {"tasks_comments", Comment}, foreign_key: :assoc_id
  end
end

but how to do migration exactly ? i would say documentation details are a bit lacking,