Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

varchar size info for a column that already exists is missing from migration #150

Open
sezaru opened this issue Jun 5, 2023 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@sezaru
Copy link
Contributor

sezaru commented Jun 5, 2023

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
@sezaru sezaru added bug Something isn't working needs review labels Jun 5, 2023
@zachdaniel zachdaniel added good first issue Good for newcomers and removed needs review labels Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants