mix ash.codegen not detecting changes

I have just created a new project, added two resources to a new domain with mix ash.gen.resource, and mix ash.codegen is says No changes detected, so no migrations or snapshots have been created. I am also getting a strange compiler warning about redefined modules, which makes me suspect something has gone wrong with the generators.
mix ash.gen.domain ChocolateMusicPlayer.Collection; mix ash.gen.resource ChocolateMusicPlayer.Collection.Track --default-actions read,create --uuid-primary-key id --attribute length:integer:public --attribute number:integer:public --attribute position:integer:public --attribute title:string:public; mix ash.gen.resource ChocolateMusicPlayer.Collection.Release --default-actions read,create --uuid-primary-key id --attribute date:date:public --attribute title:string:public --relationship has_many:tracks:ChocolateMusicPlayer.Collection.Track
mix ash.gen.domain ChocolateMusicPlayer.Collection; mix ash.gen.resource ChocolateMusicPlayer.Collection.Track --default-actions read,create --uuid-primary-key id --attribute length:integer:public --attribute number:integer:public --attribute position:integer:public --attribute title:string:public; mix ash.gen.resource ChocolateMusicPlayer.Collection.Release --default-actions read,create --uuid-primary-key id --attribute date:date:public --attribute title:string:public --relationship has_many:tracks:ChocolateMusicPlayer.Collection.Track
Diffs look fine. I accept each Proceed with changes? prompt. I then manually add a corresponding belongs_to relationship to Track.
Solution:
do you have AshPostgres.DataLayer in your resources? you probably need to add --extend postgres
Jump to solution
4 Replies
aidalgol
aidalgolOP2w ago
mix ash.codegen add_track_and_release
Compiling 3 files (.ex)
warning: redefining module ChocolateMusicPlayer.Collection.Release (current version loaded from _build/dev/lib/chocolate_music_player/ebin/Elixir.ChocolateMusicPlayer.Collection.Release.beam)

1 │ defmodule ChocolateMusicPlayer.Collection.Release do
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ lib/chocolate_music_player/collection/release.ex:1: ChocolateMusicPlayer.Collection.Release (module)

warning: redefining module Inspect.ChocolateMusicPlayer.Collection.Release (current version loaded from _build/dev/lib/chocolate_music_player/ebin/Elixir.Inspect.ChocolateMusicPlayer.Collection.Release.beam)

1 │ defmodule ChocolateMusicPlayer.Collection.Release do
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ lib/chocolate_music_player/collection/release.ex:1: Inspect.ChocolateMusicPlayer.Collection.Release (module)

Generated chocolate_music_player app
Getting extensions in current project...
Running codegen for AshPostgres.DataLayer...
No changes detected, so no migrations or snapshots have been created.
mix ash.codegen add_track_and_release
Compiling 3 files (.ex)
warning: redefining module ChocolateMusicPlayer.Collection.Release (current version loaded from _build/dev/lib/chocolate_music_player/ebin/Elixir.ChocolateMusicPlayer.Collection.Release.beam)

1 │ defmodule ChocolateMusicPlayer.Collection.Release do
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ lib/chocolate_music_player/collection/release.ex:1: ChocolateMusicPlayer.Collection.Release (module)

warning: redefining module Inspect.ChocolateMusicPlayer.Collection.Release (current version loaded from _build/dev/lib/chocolate_music_player/ebin/Elixir.Inspect.ChocolateMusicPlayer.Collection.Release.beam)

1 │ defmodule ChocolateMusicPlayer.Collection.Release do
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ lib/chocolate_music_player/collection/release.ex:1: Inspect.ChocolateMusicPlayer.Collection.Release (module)

Generated chocolate_music_player app
Getting extensions in current project...
Running codegen for AshPostgres.DataLayer...
No changes detected, so no migrations or snapshots have been created.
Solution
minib
minib2w ago
do you have AshPostgres.DataLayer in your resources? you probably need to add --extend postgres
minib
minib2w ago
btw try https://albinkc.github.io/ashgen/ to build the gen commands
aidalgol
aidalgolOP2w ago
That's what was missing, thanks!

Did you find this page helpful?