Ash Framework 3.0: Release Candidates

OH! Very cool. No cycles. Did NOT realize that tool had a distinction between runtime and compile. Thank you!

What’s the status of AshSqlite re: the v3 update? Is it the same “point your mix file at GH and give it a try, but be aware there may be issues” situation as Ash v3 itself, or is the SQLite support further behind?

(There’s this which seems promising, but I wanted to check directly before ploughing ahead)

All of the packages including ash_sql support ash 3.0 on their latest releases(no need for pointing at GitHub) Some packages(like ash_sql) added support in a release candidate(also on hex) :partying_face:


As for the status, some small issues here and there, but otherwise 3.0 is stable and ready to mingle :slight_smile:


Just did my first migrations since the upgrade. I didn’t see anything about changes to migrations in the guide, or a change in uuid fields.

EDIT: I now see breaking changes listed here: ash_postgres/ at main · ash-project/ash_postgres · GitHub and now see the file ash_postgres/documentation/topics/development/ at main · ash-project/ash_postgres · GitHub which explains all this. Fix the link the ash upgrade to point here.

Every resource had this in the migration file:

    alter table(:my_resource) do
      modify :updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')")
      modify :created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')")
      modify :id, :uuid, default: fragment("gen_random_uuid()")

And all indexes are recreated in the up

Nothing special about all the resources, those fields look like:

  attributes do
    uuid_primary_key :id
    create_timestamp :created_at
    update_timestamp :updated_at

The migration fails with:

** (Postgrex.Error) ERROR 42883 (undefined_function) function gen_random_uuid() does not exist

    hint: No function matches the given name and argument types. You might need to add explicit type casts.
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1054: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.16.2) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1161: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.11.1) lib/ecto/migration/runner.ex:348: Ecto.Migration.Runner.log_and_execute_ddl/3
    (elixir 1.16.2) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (ecto_sql 3.11.1) lib/ecto/migration/runner.ex:311: Ecto.Migration.Runner.perform_operation/3
    (stdlib 5.2.1) timer.erl:270:
    (ecto_sql 3.11.1) lib/ecto/migration/runner.ex:25:

Can’t find anything in the docs related to this change.

Looked at an old migration, and id was:

      add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true

(FYI, is a 404, but that link is in the upgrade guide)

The upgrade guide has been fixed, thanks for reporting the issue.

1 Like

Just to clarify, does that include ash_sqlite? Because I have this in my mix.exs:

# ...
      {:ash, "~> 3.0.0-rc.21"},
      {:ash_sqlite, "~> 0.1.1"},
      {:ash_phoenix, "~> 2.0.0-rc.4"},
# ...

and I get an error:

Because every version of ash_sqlite depends on ash >= 2.15.12 and < 3.0.0-0 and your app depends on ash ~> 3.0.0-rc.21, no version of ash_sqlite is allowed.

In short, I want to try the v3 RCs, but with sqlite instead of postgres. Is that doable?

Looking at the repo I think ash_sqlite doesn’t have a RC yet, so for now you could try pointing to main on Github until it gets tagged

{:ash_sqlite, github: "ash-project/ash_sqlite"},

Didn’t realize. Will publish one today


Want to give Ash a try for my next project. As I rather not migrate a month into the project and learning “the old way”, I rather start fresh at 3.0 RC. However, documentation does not up to date yet, or is it?

This is just some left over wording. I will address. The documentation is being overhauled. With rare exception, it should be up to date everywhere, anything like that you find is essentially a documentation bug.

1 Like

Feel free to open any issues for things like that?

1 Like

Now I know it should be up to date I’ll raise an issues (or PR) when found. Thanks for the rapid response.

do the live book tutorials work with Ash 3.0 ?
I am getting

** (Ash.Error.Framework) Framework Error

* Tutorial.Support.Ticket.assign must be performed atomically, but it could not be

Reason: cannot atomically manage relationships

See for more on atomics.

  (elixir 1.15.7) lib/process.ex:860:
  (ash 3.0.0-rc.33) lib/ash/error/framework/must_be_atomic.ex:5: Ash.Error.Framework.MustBeAtomic.exception/1
  (ash 3.0.0-rc.33) lib/ash/actions/update/update.ex:170:
  (ash 3.0.0-rc.33) lib/ash.ex:2447: Ash.update/2
  (ash 3.0.0-rc.33) lib/ash.ex:2408: Ash.update!/2
  (elixir 1.15.7) src/elixir.erl:396: :elixir.eval_external_handler/3
  (stdlib 5.1.1) erl_eval.erl:750: :erl_eval.do_apply/7
  (elixir 1.15.7) src/elixir.erl:375: :elixir.eval_forms/4
    (elixir 1.15.7) lib/process.ex:860:

this is from 9 - Managing relationships.

An, right this is a consequence of a recent change to support atomics in ETS. I will update the tutorial. Are there any other broken places that you saw?

Okay, I’ve addressed this in the tutorial. Specifically, I’ve removed the need to use manage_relationship at all in the Livebook tutorial, and therefore all of the actions are atomic safe :slight_smile: Would you mind taking a look to see what you think?

1 Like

So the tutorial works now.
Thanks for this :slight_smile:

I think there is a need for a ‘showcase’ repo / livebook depicting various use cases for many-many relationships. especially, showcasing manage_relationship – that is most common use case where I get stuck frequently.

Here are a few scenarios I have come across. Feel free to add more to the list.

  1. user many-many orgs through user_orgs

user_orgs has keys :user_role + user_id + org_id

A. when deleting user → delete from user_orgs but don’t delete orgs
B. when deleting user → also delete user_orgs and orgs
C. when creating user → also create org and pass the user_role in manage_relationship

  1. artist many-many album through artist_album
    album many-many songs through album_songs

A. create_song_with_artist_and_album → takes song attributes and artist_id, album_id to manage those

as of now, hooking into after_action has been a goto strategy to make these work. But ideally, I would love to understand how can I achieve the same using manage_relationship.

1 Like

Agreed! Please add these suggestions to the documentation overhaul community suggestions issue if you don’t mind: Community suggestions for documentation overhaul · Issue #995 · ash-project/ash · GitHub

1 Like

Will do!

Din’t know there was a tracker somewhere !

1 Like