-
-
Notifications
You must be signed in to change notification settings - Fork 106
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Versions
Elixir: 1.18.4
OPT: 27
Operating system
MacOS
Current Behavior
I was introducing AshStateMachine
to a resource which had an existing optional status
field, which auto-generated the following migration:
defmodule MyApp.Repo.Migrations.UpdateProducts 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
rename table(:products), :status, to: :state
alter table(:products) do
modify :state, :text, null: false
end
end
def down do
alter table(:products) do
modify :status, :text, null: true
end
rename table(:product), :state, to: :status
end
end
The down/0
migration here fails because it attempts to modify :status
before :state
is renamed to :status
.
Reproduction
Have an existing resource with a nullable status
field, then remove it, and introduce AshStateMachine (or just rename it to :state
and make it nullable directly).
Expected Behavior
The correct order should be:
def down do
alter table(:products) do
modify :status, :text, null: true
end
rename table(:product), :state, to: :status
end
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Type
Projects
Status
Someday