firehose/app/priv/repo/seeds.exs
2026-04-01 21:36:58 +00:00

22 lines
684 B
Elixir

# Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Firehose.Repo.insert!(%Firehose.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
if Mix.env() == :dev do
alias Firehose.Accounts
# Create demo user if not already present
unless Accounts.get_user_by_email("demo@example.com") do
{:ok, user} = Accounts.register_user(%{email: "demo@example.com"})
{:ok, {_user, _tokens}} = Accounts.update_user_password(user, %{password: "password123!"})
end
end