evolvingdev
I’m working with the realworld demo, and I’m trying to add a table using mix codegen or mix ash_postgres.generate_migrations, but each gives me the error:
Compiling 1 file (.ex) │
Getting extensions in current project... │
Running codegen for AshPostgres.DataLayer... │
** (Protocol.UndefinedError) protocol Enumerable not implemented for false of type Atom. This protocol is implemented for the following type(s): DBConnection.PrepareStream, DBConnecti│
on.Stream, Date.Range, Ecto.Adapters.SQL.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Iter, Jason.OrderedObject, List, Map, MapSet, Phoenix.LiveView.L│
iveStream, Postgrex.Stream, Range, Rewrite, Stream, StreamData │
(elixir 1.16.2) lib/enum.ex:1: Enumerable.impl_for!/1 │
(elixir 1.16.2) lib/enum.ex:194: Enumerable.member?/2 │
(elixir 1.16.2) lib/enum.ex:2006: Enum.member?/2 │
(elixir 1.16.2) lib/enum.ex:4402: Enum.reject_list/2 │
(ash_postgres 2.1.19) lib/migration_generator/migration_generator.ex:2892: AshPostgres.MigrationGenerator.identities/1 │
(ash_postgres 2.1.19) lib/migration_generator/migration_generator.ex:2603: AshPostgres.MigrationGenerator.do_snapshot/3 │
(ash_postgres 2.1.19) lib/migration_generator/migration_generator.ex:2596: AshPostgres.MigrationGenerator.get_snapshots/2 │
(elixir 1.16.2) lib/enum.ex:4326: Enum.flat_map_list/2
I have no idea where to start debugging this, but have found this topic that looks slimilar: AshGraphql Errors Encountered During Ash 3.0 Migration
From my mix.exs
elixir: "~> 1.16.2",
...
:phoenix, "~> 1.7.14",
:ash, "~> 3.4",
:ash_postgres, "~> 2.1"
Any help is appreciated, thanks.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
MartinElvar
Run
mix deps.update sparkand you should be good to go.evolvingdev
Thanks, after trying that, I get this error…
From my
mix.exs:jason, "~> 1.4"zachdaniel
evolvingdev
Thanks for the quick reply Zach,
no I haven’t modified my resource snapshots by hand.
When I first tried to do the migration to create a new table, it gave me an odd error - that a name must be provided, although I had, and instead of running the migration, it ran ‘Extension Migrations’, creating:
20240813065843_install_3_extensions.exs(From memory, I installed
citextfor case insenstive email signup.)and it also created:
priv/resource_snapshots/repo/extensions.jsonto give the same error as the last one above:
** (Jason.DecodeError) unexpected byte at position 1168: 0x22 ("\"")That error was replaced however by the one in my original post when I again ran the migration to create a table.
zachdaniel
Yeah, so those should be fine, they are generated as part of upgrading.
Are there snapshots for the various tables in the resource snapshots folder? Can I see the new resource you’re adding?
evolvingdev
This is where my no shame noobness comes in…
I haven’t created the resource yet. I read another post here where someone said they had, and I must have somehow skipped this part in a tutorial, but was thinking if I had to first create a resource, then Ash would given me a warning when attempting a migration that a resource was missing, and then I’d add it before trying the migration again. But instead I got that jason error.
One reason I hadn’t created the resource, was because I was thinking about how to populate the table, which is a users personal info that they can edit, and I want it to be partly populated by their account (eg email) and user profile (eg real name), so I thought it easier to create the table first and then try to understand how to work with it via Ash.
I guess that’s why the snapshot for the table I was trying to create via the migration hasn’t been created (to answer your first question)?
zachdaniel
Ash won’t warn you that a resource is missing when running migrations. The general flow is to work on your resources, and then
mix ash.codegen add_somethingto generate or modify the underlying tables, and thenmix ash.migrateto migrate them.Ultimately the main thing I’m trying to determine here is which file has invalid JSON in it. The extensions file looks fine to me, so there must be something else going wrong here. That error is in loading existing snapshots, so it must be a snapshot for a resource that is having the problem.
I cloned down the real world repo and ran this in iex to decode all the json files that could be relevant:
and all the files there currently successfully decode. So one of the new files has invalid JSON.
evolvingdev
Your first guess was right, I have edited the snapshots - indirectly via a global find and replace when I first started playing with the realworld demo to see if I could use it as a starting base to learn Ash and prototype my app by changing resource names etc and reseting the db with them.
Sorry, it’s after 2am here, so I’m a bit tired and forgot that obvious fact to answer your first question.
I’m still surprised I’ve messed up the formatting in a snapshot, but it’s possible, although I imagine you’re going to tell me that by just changing them at all (via that lazy global find and replace across all of the demo), I’ve messed up something akin to a checksum? If not or regardless, I’d better track down that invalid JSON.
I really appreciate your patience and help, and thanks for explaining some of the general workflow when using Ash. That’s the bit I’m (obviously) working out now after reading through the docs several times, and I intend to start my app from scratch once I’ve learned enough from them and the demo.
Part of my problem is trying to modify an existing app without enough learning to do so, while only doing so because it has more to teach than the doc’s examples at this time.
Some higher-level overview docs of the Ash workflow would be helpful (if I haven’t missed them sorry) and perhaps with comparisons to using Phoenix eg what typical workflow Ash replaces/changes? I pick up parts of that mixed into the existing docs, but a dedicated page under the Development section next to Project Structure — ash v3.29.3 and Generators — ash v3.29.3 would tie a lot of the docs together - perhaps as https://hexdocs.pm/ash/workflow.html?
That could describe how/when to use generators/ignite to creating resources to running migrations, how to ‘go in reverse’ eg if you want to change a resource, then do you do so and then run another migration or roll the last one back first, etc.
It’s noob stuff, but done right like the rest of the docs, you’d no doubt find a balance that helps people like me and more advanced users wanting to go beyond Phoenix to use Ash with less learning friction.
Sorry to suggest more work for you! Message me if you ever need any feedback on such a page or docs from a noobs perspective and I’ll be happy to help give feedback.
I’m looking forward to your book for some complete examples of common dev uses cases too.
zachdaniel
The feedback is much appreciated
We don’t checksum the snapshots so it is totally fine to edit them. My guess is that somewhere in that find and replace an errant
"was added somehow.I definitely agree on all points about higher level docs showing the workflows, patterns, ways of thinking etc. are warranted
We’re working on a book that will help with that kind of thing, but we also will be improving the documentation over time to help with this kind of thing!