74 lines
1.8 KiB
Elixir
74 lines
1.8 KiB
Elixir
actions = [
|
|
fn ->
|
|
alias RiverConnect.Hierarchy
|
|
alias RiverConnect.Repo
|
|
|
|
# 1. Create DM Spring
|
|
case Repo.get_by(Hierarchy.Spring, name: "Direct Messages") do
|
|
nil ->
|
|
{:ok, spring} =
|
|
Hierarchy.create_spring(%{
|
|
name: "Direct Messages",
|
|
type: "dm",
|
|
description: "Private conversations between users"
|
|
})
|
|
|
|
IO.puts("Created 'Direct Messages' Spring")
|
|
spring
|
|
|
|
spring ->
|
|
IO.puts("'Direct Messages' Spring already exists")
|
|
spring
|
|
end
|
|
|
|
# 2. Create Jobs Spring
|
|
{:ok, jobs_spring} =
|
|
case Repo.get_by(Hierarchy.Spring, name: "Jobs") do
|
|
nil ->
|
|
{:ok, spring} =
|
|
Hierarchy.create_spring(%{
|
|
name: "Jobs",
|
|
type: "job",
|
|
description: "Job-specific rivers"
|
|
})
|
|
|
|
IO.puts("Created 'Jobs' Spring")
|
|
{:ok, spring}
|
|
|
|
spring ->
|
|
IO.puts("'Jobs' Spring already exists")
|
|
{:ok, spring}
|
|
end
|
|
|
|
# 3. Create a sample River in Jobs
|
|
case Repo.get_by(Hierarchy.River, name: "General Construction", spring_id: jobs_spring.id) do
|
|
nil ->
|
|
{:ok, river} =
|
|
Hierarchy.create_river(%{
|
|
name: "General Construction",
|
|
description: "General discussions about construction jobs",
|
|
spring_id: jobs_spring.id
|
|
})
|
|
|
|
IO.puts("Created 'General Construction' River")
|
|
|
|
# 4. Create sample Stream
|
|
{:ok, _stream} =
|
|
Hierarchy.create_stream(%{
|
|
name: "Announcements",
|
|
topic: "Important announcements",
|
|
river_id: river.id
|
|
})
|
|
|
|
IO.puts("Created 'Announcements' Stream")
|
|
|
|
_ ->
|
|
IO.puts("'General Construction' River already exists")
|
|
end
|
|
end
|
|
]
|
|
|
|
for action <- actions do
|
|
action.()
|
|
end
|