Open
Description
Describe the bug
Adding a specific size for a string/varchar field will not show in the migration file if the column already exists from another migration.
To Reproduce
First create the following resource:
defmodule MyResource do
use Ash.Resource, data_layer: AshPostgres.DataLayer
attributes do
uuid_primary_key :id
attribute :blibs, :string
end
postgres do
table "my_resources"
repo Repo
end
end
Now, generate a migration for it with mix ash_postgres.generate_migrations
.
This should generate the table my_resources
with the blibs
field as a :text
field.
Now, change the resource to this:
defmodule MyResource do
use Ash.Resource, data_layer: AshPostgres.DataLayer
attributes do
uuid_primary_key :id
attribute :blibs, :string
end
postgres do
table "my_resources"
migration_types blibs: {:varchar, 255}
repo Repo
end
end
And generate a new migration with mix ash_postgres.generate_migrations
This will generate the following migration:
def up do
alter table(:my_resources) do
modify :blibs, :varchar
end
end
def down do
alter table(:my_resources) do
modify :blibs, :text
end
end
Expected behavior
The final generated migration in the example above should contain information about the column size (in this case, it should add , size: 255
.
** Runtime
- Elixir version 1.14.4
- Erlang version 25
- OS Fedora 28
- Ash version 2.9.18
- any related extension versions 1.3.28