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
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
)
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"
3 Replies
ZachDaniel
ZachDaniel•2y ago
ah, yeah interesting we should unique that list can you open an issue on ash_graphql?
barnabasj
barnabasj•2y ago
ash_postgres?
ZachDaniel
ZachDaniel•2y ago
Yes, sorry 😅

Did you find this page helpful?