AshPostgres migrations vs Ecto

I deployed an app to Fly.io and it just ran the migrations for me probably using the Ecto migrator before I could thing to switch over to AshPostgres for migrations.

I know I need to go in and edit the script that does migrations to use AshPostgres migrator instead, but I’m curious what the difference is between the two and what would happen if I allowed that first migration with Ecto, but started do in the rest with AshPostgres?

–update–

Just thought of one difference, Ecto isn’t going to take care of tenants if those are being used.

Also, look like support for enums as defined in AshResources

I found the guide on this, it gives a sample file for App.Release:

Since I’m not using tenants with this particular application I can ignore those differences, but I see this diff:

Default:

  defp repos do
    Application.fetch_env!(@app, :ecto_repos)
  end

Ash HQ Example:

  defp repos do
    apis()
    |> Enum.flat_map(fn api ->
      api
      |> Ash.Api.Info.resources()
      |> Enum.map(&AshPostgres.DataLayer.Info.repo/1)
    end)
    |> Enum.uniq()
  end

It looks like what the Ash HQ example is doing is dynamically finding/transforming all of the Repos defined within the projects Resources. So, I’m assuming since I have the simple setup of just one Repo that my first migration was essentially the same as this one would be since the default migrate function is the same as the AshHQ example except for how it retrieves the Repos.

1 Like