Ash FrameworkAF
Ash Framework3y ago
5 replies
gordoneliel

Creating index from identity or custom index creates bad migration

When generating a migration from either an identity or custom index, I'm getting a weird migration:
Datalayer:
  postgres do
    table "plans"
    repo MyApp.Repo
    migration_defaults features: "[]"

    custom_indexes do
      index [:id, :organization_id],
        name: "unique_org_plan",
        unique: true,
        message: "a plan can only be tied to one organization"
    end
  end


Migration generated:
    create index(:plans, ["organization_id", "id", "organization_id"],
             name: "unique_org_plan",
             unique: true
           )


Doing this because the relationship migration generated by a belongs_to creating a transitive unique fk index on the multi-tenant attribute "organization_id"
Was this page helpful?