edgehog-device-manager/edgehog

Restore working seeds

Closed this issue · 0 comments

rbino commented

Assuming an empty Postgresql running on the same machine (e.g. docker run --net=host --name some-postgres --rm -e POSTGRES_PASSWORD=postgresql postgres:latest), it should be possible to bring up a working backend with just

git clone git@github.com:edgehog-device-manager/edgehog.git
cd edgehog/backend
mix deps.get
mix ecto.reset

Right now, this fails with

** (MatchError) no match of right hand side value: {:error, #Ecto.Changeset<action: :insert, changes: %{name: "Test Cluster"}, errors: [base_api_url: {"can't be blank", [validation: :required]}], data: #Edgehog.Astarte.Cluster<>, valid?: false>}
    priv/repo/seeds.exs:45: (file)
    (elixir 1.15.5) lib/code.ex:1435: Code.require_file/2
    (mix 1.15.5) lib/mix/tasks/run.ex:146: Mix.Tasks.Run.run/5
    (mix 1.15.5) lib/mix/tasks/run.ex:85: Mix.Tasks.Run.run/1
    (mix 1.15.5) lib/mix/task.ex:447: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.5) lib/mix/task.ex:506: Mix.Task.run_alias/6
    (mix 1.15.5) lib/mix/cli.ex:92: Mix.CLI.run_task/2
    /home/rbino/.asdf/installs/elixir/1.15.5-otp-26/bin/mix:2: (file)

It should be possible to just seed default data without any additional step