Code of Conduct
AI Policy
Versions
ash_postgres: 2.11.0
ash: 3.31.3
Elixir: 1.20.1
Erlang/OTP: 28.5.0.2
Operating system
NixOS, Linux x86_64
Current Behavior
mix ash.codegen --check raises an internal error when a Resource has multiple removed attributes and multiple added attributes.
In this case, _dev migrations also remain. The command should report the existing _dev migration error. It instead crashes before it reaches that check:
** (RuntimeError) Could not get matching name after 3 attempts.
Relevant call stack:
Mix.Tasks.Ash.Codegen.run/1
AshPostgres.DataLayer.codegen/1
Mix.Tasks.AshPostgres.GenerateMigrations.run/1
AshPostgres.MigrationGenerator.generate/2
create_migrations/5
fetch_operations/2
do_fetch_operations/5
attribute_operations/4
resolve_renames/4
renaming?/3
yes?/2
get_new_attribute/3
prompt/2
In --check mode, yes?/2 returns true, while prompt/2 returns "response".
The generator therefore confirms that a removed attribute is a rename, but then cannot find an added attribute named "response". It retries three times and raises.
The _dev migration check occurs after operation and rename inference, so the command never reaches this intended message:
Codegen check failed.
You have migrations remaining that were generated with the --dev flag.
Run `mix ash.codegen <name>` to remove the dev migrations and replace them
with production-ready migrations.
### Reproduction
1. Create a Resource with these persisted attributes:
```text
old_a
old_b
old_c
old_d
- Generate a production-ready migration and snapshot:
mix ash.codegen initial_attributes
mix ash.migrate
- Replace those attributes with:
- Generate development codegen:
mix ash.codegen --dev
mix ash.migrate
- Run the automated check:
The command deterministically raises:
Could not get matching name after 3 attempts.
The relevant state is:
attributes_to_remove = [old_a, old_b, old_c, old_d]
attributes_to_add = [new_a, new_b]
check = true
dev = false
Expected Behavior
- When _dev migrations remain, it should report the existing _dev migration message.
- For ambiguous changes without _dev migrations, it should report pending codegen without inventing a rename.
Code of Conduct
AI Policy
Versions
ash_postgres: 2.11.0
ash: 3.31.3
Elixir: 1.20.1
Erlang/OTP: 28.5.0.2
Operating system
NixOS, Linux x86_64
Current Behavior
mix ash.codegen --check raises an internal error when a Resource has multiple removed attributes and multiple added attributes.
In this case, _dev migrations also remain. The command should report the existing _dev migration error. It instead crashes before it reaches that check:
Relevant call stack:
In --check mode, yes?/2 returns true, while prompt/2 returns "response".
The generator therefore confirms that a removed attribute is a rename, but then cannot find an added attribute named "response". It retries three times and raises.
The _dev migration check occurs after operation and rename inference, so the command never reaches this intended message:
The command deterministically raises:
The relevant state is:
Expected Behavior