From 240d1648c576c5ead8aec9acfa981817e445c45d Mon Sep 17 00:00:00 2001 From: Conor Sinclair Date: Fri, 18 Sep 2026 16:39:35 +0200 Subject: [PATCH] fix: set match_tenant? on polymorphic references The reference map built for a polymorphic relationship never set match_tenant?, so merge_references/3 asked merge_uniq!/4 for a key that was absent, got an empty list, and returned nil. Snapshots normalise the key to false on read, so nil != false made every polymorphic reference compare as changed. The generator then emitted an alter-constraint operation, which on SQLite renders as a migration whose up/0 opens by raising "SQLite does not support dropping foreign key constraints". mix ash.codegen --check reported three pending files on main and the migration it wanted to write could not have run. No snapshot changes: with the key set, the computed references match the committed ones. --- lib/migration_generator/migration_generator.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/migration_generator/migration_generator.ex b/lib/migration_generator/migration_generator.ex index 1af3c0b..067a445 100644 --- a/lib/migration_generator/migration_generator.ex +++ b/lib/migration_generator/migration_generator.ex @@ -2203,6 +2203,7 @@ defmodule AshSqlite.MigrationGenerator do AshSqlite.DataLayer.Info.repo(relationship.destination) ), deferrable: false, + match_tenant?: false, destination_attribute_generated: source_attribute.generated?, multitenancy: multitenancy(relationship.source), table: AshSqlite.DataLayer.Info.table(relationship.source),