Where is the config function for an Ash Domain created?

I am starting a project with Ash and Phoenix. I take the general steps shown in the Get Started with Ash and Phoenix tutorial on the Ash documentation website. I create an Ash domain and resources. I set up the repo for the project. I add the Ash domains to the config.exs file.

config :forum_app,
  ash_domains: [ForumApp.Forum],
  ecto_repos: [ForumApp.Repo],
  generators: [timestamp_type: :utc_datetime]

When I run the mix ash.codegen command to create the initial database migration. I get the following error message in the Terminal:

(UndefinedFunctionError) function ForumApp.Forum.config/0 is undefined or private
    (forum_app 0.1.0) ForumApp.Forum.config()
    (ash_postgres 2.4.12) lib/migration_generator/migration_generator.ex:160: AshPostgres.MigrationGenerator.snapshot_path/2
    (ash_postgres 2.4.12) lib/migration_generator/migration_generator.ex:168: anonymous fn/2 in AshPostgres.MigrationGenerator.create_extension_migrations/2
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (ash_postgres 2.4.12) lib/migration_generator/migration_generator.ex:53: AshPostgres.MigrationGenerator.generate/2
    (mix 1.17.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2

The database tables for my Ash resources are not created because of this error.

I have been able to create migrations in other Ash projects so I have made a mistake somewhere. But when I look at the code from the new project and compare it with similar code from other projects, I’m not seeing where my mistake is.

Where is the config function created for an Ash domain? Where should I be looking to fix this compiler error?

Looking at this line of code. It should actually look for the config on the Repo module.

What does your postgres section on the resource look like?

Here’s the code for the postgres section on the resource.

postgres do
    table "boards"
    repo ForumApp.Repo
  end

And here’s the code for the Repo.

defmodule ForumApp.Repo do
  use AshPostgres.Repo,
    otp_app: :forum_app
    
  def installed_extensions do
    ["ash-functions", "uuid-ossp", "citext"]
  end
end

I’m not sure why it would try to use the domain in that case. Can you double check you did it exactly like in the example.

Otherwise, you can try to use igniter to bootstrap a project.

mix archive.install hex igniter_new

mix igniter.new helpdesk --install ash,ash_phoenix,ash_postgres --with phx.new

That also adds mix tasks to generate resources.
https://hexdocs.pm/ash/generators.html#generators

I used igniter to create the project. I used the following commands:

mix archive.install hex phx_new
mix igniter.new forum_app --install ash --with phx.new

And I added the AshPhoenix and AshPostgres dependencies in the mix.exs file.

Yeah, not sure TBH. If you push the code to Github, I can take a look if you want

Here’s the link to the GitHub repo for the project.

I figured out what the problem was. It was in the postgres section of one of my other resources. I had the name of the domain as the repo instead of the name of the repo.

Problem code:

postgres do
    table "posts"
    repo ForumApp.Forum
end

Fixed code:

postgres do
    table "posts"
    repo ForumApp.Repo
end

Thanks for the help. You were on correct about the postgres section being the problem.