MeAndMark

MeAndMark

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?

Showing Posts 1 to 7

barnabasJ

barnabasJ

Ash Core Team

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?

MeAndMark

MeAndMark OP

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
barnabasJ

barnabasJ

Ash Core Team

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.

MeAndMark

MeAndMark OP

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.

barnabasJ

barnabasJ

Ash Core Team

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

MeAndMark

MeAndMark OP

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

https://github.com/meandmark/ForumApp

MeAndMark

MeAndMark OP

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.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews