I am trying to persist my data about tasks for a project management app I am developing. As you know, a project consists of tasks, and these tasks have dependencies on other tasks.
So far, I have done this:
defmodule Mgmt.Task do
use Ecto.Schema
schema "tasks" do
field :duration, :float
has_many :tasks, Mgmt.Task
field :start_date, :date
field :end_date, :date
field :act_duration, :float
field :act_start_date, :date
field :act_end_date, :date
field :complete, :float
field :status, :string
timestamps()
end
end
I have the following questions for my situation:
- In the code snippet above, the has_many part represents the dependencies of a task on other tasks. I would like to be able to have this piece of information as a field (say, :deps). I am wondering how to tell Ecto that this (has_many), is a field as well.
- How to define my migration file (for the very first creation of tasks table). What should I put in the ??? below
defmodule Mgmt.Repo.Migrations.CreateTasks do
use Ecto.Migration
def change do
create table(:tasks) do
add(:duration, :float)
add(?????????????)
add(:start_date, :date)
add(:end_date, :date)
add(:act_duration, :float)
add(:act_start_date, :date)
add(:act_end_date, :date)
add(:complete, :float)
add(:status, :string)
timestamps()
end
end
end
Many thanks






















