I have a small app with 3 tables in Postgres using Ecto.Table. I am migrating them to use Ash.Resource.
When I run
mix ash_postgres.generate_migrations
mix ash_postgres.generate_migrations
for the first time, the generated migrations are to create tables that already exist and the table structures are different. Are there any guides or do you have any advice for reconciling the differences?
Original ecto migration:
defmodule Iterup.Repo.Migrations.CreateAccounts do use Ecto.Migration def change do create table(:accounts, primary_key: false) do add :id, :binary_id, primary_key: true add :name, :string add :slug, :string timestamps() end create unique_index(:accounts, [:slug]) endend
defmodule Iterup.Repo.Migrations.CreateAccounts do use Ecto.Migration def change do create table(:accounts, primary_key: false) do add :id, :binary_id, primary_key: true add :name, :string add :slug, :string timestamps() end create unique_index(:accounts, [:slug]) endend
New generated migration:
defmodule Iterup.Repo.Migrations.MigrateResources1 do @moduledoc """ Updates resources based on their most recent snapshots. This file was autogenerated with `mix ash_postgres.generate_migrations` """ use Ecto.Migration def up do create table(:accounts, primary_key: false) do add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true add :name, :text, null: false add :slug, :text, null: false add :inserted_at, :utc_datetime_usec, null: false, default: fragment("now()") add :updated_at, :utc_datetime_usec, null: false, default: fragment("now()") end end def down do drop table(:accounts) endend
defmodule Iterup.Repo.Migrations.MigrateResources1 do @moduledoc """ Updates resources based on their most recent snapshots. This file was autogenerated with `mix ash_postgres.generate_migrations` """ use Ecto.Migration def up do create table(:accounts, primary_key: false) do add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true add :name, :text, null: false add :slug, :text, null: false add :inserted_at, :utc_datetime_usec, null: false, default: fragment("now()") add :updated_at, :utc_datetime_usec, null: false, default: fragment("now()") end end def down do drop table(:accounts) endend
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.