"No changes detected, so no migrations or snapshots have been created."

waseigo
2023-02-08

waseigo:

Hi all. I am learning how to build a simple CRUD app with Ash, and for some reason mix ash_postgres.generate_migrations fails to pick up any migrations, even after I mix ash_postgres.drop and rm -f priv/repo/migrations/* to start from scratch.

Any clues as to why?

ZachDaniel:

AshPostgres uses “snapshots” to track the current state of the tables it is generating migrations for

ZachDaniel:

So you’ll also want to remove those 🙂

ZachDaniel:

they default to priv/repo/snapshots

ZachDaniel:

IIRC

waseigo:

I have a priv/resource_snapshots/repo , but no priv/repo/snapshots

waseigo:

Ok, now it generates the users and tokens table for ash_authentication, but not the tables based on my resources

ZachDaniel:

You are likely missing either 1. an api in config :your_app, :ash_apis 2. resources in the registry for an api

waseigo:

config :bouketo, ash_apis: [Bouketo.Portfolio] config :bouketo, ash_apis: [Bouketo.Accounts]

I think that was the problem, let me make one list and try it out

waseigo:

Excellent, thank you <@197905764424089601>!

ZachDaniel:

My pleasure 🙂

ZachDaniel:

If your issue has been resolved, please add the ✅ Solved tag and close this thread by right clicking the thread in the sidebar and choosing Close Post.

waseigo:

For reference, besides the copy/past error I had made, I now enter the following sequence of commands in order to start from a clean slate:

rm -rf ./priv/repo/migrations/*
rm -rf ./priv/resource_snapshots/*
mix ash_postgres.drop
mix ash_postgres.create
mix ash_postgres.generate_migrations
mix ash_postgres.migrate
mix run priv/repo/seeds.exs

ZachDaniel:

Someone had a clever script for something like this

ZachDaniel:

you’d want to modify it to do your seeds.exs as well

waseigo:

I nuke everything and start from scratch with my reset.sh containing the commands above

waseigo:

Trying to wrap my head around Ash, so it’s easier to reset to a blank slate…

ZachDaniel:

👍

axdc:

not sure about necro etiquette, but just wanted to add my 3am brain was struggling with this for like an hour, comparing the working and non-working resources over and over, the madness slowly rising, giddy cackles escaping my throat, etc, then i realized i simply hadn’t prefixed the resources with “entry” in the non-detected registry. duh. the system didn’t flag it as invalid or anything and i skimmed right over it. so check that first as extremely low-hanging fruit, future traveler. (please kill or move this if it’s inappropriate here)

ZachDaniel:

oh man, thats crazy lol. Thanks for adding that context!