Files
Rivertalk/river_connect/priv/repo/migrations/20260214234844_create_hierarchy.exs
T

44 lines
994 B
Elixir

defmodule RiverConnect.Repo.Migrations.CreateHierarchy do
use Ecto.Migration
def change do
create table(:springs) do
add :name, :string, null: false
# :dm, :job, :custom
add :type, :string, null: false
add :description, :text
timestamps()
end
create table(:rivers) do
add :name, :string, null: false
add :description, :text
add :spring_id, references(:springs, on_delete: :delete_all), null: false
timestamps()
end
create index(:rivers, [:spring_id])
create table(:streams) do
add :name, :string, null: false
add :topic, :string
add :river_id, references(:rivers, on_delete: :delete_all), null: false
timestamps()
end
create index(:streams, [:river_id])
create table(:trenches) do
add :name, :string
add :stream_id, references(:streams, on_delete: :delete_all), null: false
timestamps()
end
create index(:trenches, [:stream_id])
end
end