|
2 | 2 | # |
3 | 3 | # mix run priv/repo/seeds.exs |
4 | 4 | # |
5 | | -# Inside the script, you can read and write to any of your |
6 | | -# repositories directly: |
| 5 | +# Inside the script, you can read and write to any of your repositories directly: |
7 | 6 | # |
8 | 7 | # ElixirBoilerplate.Repo.insert!(%ElixirBoilerplate.SomeSchema{}) |
9 | 8 | # |
10 | | -# We recommend using the bang functions (`insert!`, `update!` |
11 | | -# and so on) as they will fail if something goes wrong. |
| 9 | +# We recommend using the bang functions (`insert!`, `update!` and so on) as they |
| 10 | +# will fail if something goes wrong. |
| 11 | + |
| 12 | +alias ElixirBoilerplate.Planning.{Project, Task} |
| 13 | +alias ElixirBoilerplate.Repo |
| 14 | + |
| 15 | +project = |
| 16 | + %Project{ |
| 17 | + title: "TODOs", |
| 18 | + description: "A simple schema to showcase the way we are structuring our relational database data structures", |
| 19 | + inserted_at: DateTime.utc_now(), |
| 20 | + updated_at: DateTime.utc_now() |
| 21 | + } |
| 22 | + |> Repo.insert!() |
| 23 | + |
| 24 | +_tasks = |
| 25 | + Repo.insert_all(Task, [ |
| 26 | + [description: "A first task in the project;", project_id: project.id, inserted_at: DateTime.utc_now(), updated_at: DateTime.utc_now()], |
| 27 | + [description: "A second task", project_id: project.id, inserted_at: DateTime.utc_now(), updated_at: DateTime.utc_now()], |
| 28 | + [description: "And one last one…", project_id: project.id, inserted_at: DateTime.utc_now(), updated_at: DateTime.utc_now()] |
| 29 | + ]) |
0 commit comments