Ash FrameworkAF
Ash Framework3y ago
3 replies
Blibs

Need to duplicate migration_defaults if multiple resources uses the same table

I have a resource called User

it has this postgres configuration:

    postgres do
      table "users"

      repo Marketplace.Repo

      migration_defaults roles: "[\"seller\"]"
    end


I have a migration file for that specific resource with correctly created the roles field with the default value:

add :roles, {:array, :text}, null: false, default: ["seller"]


I also have another resource that uses the same table called Bidder.

it has this postgres configuration:

  postgres do
    table "users"

    repo Marketplace.Repo
  end


If I try to create a migration file for that resource, it will alter the user table changing the
role
default to nil.

Can I stop it from doing it without having to duplicate that code in both resources?
Was this page helpful?