Issue with SwiftData migration and renaming property when using @Attribute(originalName:)

Put simply, @Attribute(originalName:) doesn't seem to work.

I'm getting "Validation error missing attribute values on mandatory destination relationship".

Tried with Xcode 26.6 on iOSes 18.6 and 26.5, and with Xcode 27 on iOS27. Same result.

Original Schema:

typealias CurrentSchemaModel = SchemaV100
typealias House = CurrentSchemaModel.House
typealias Automobile = CurrentSchemaModel.Automobile

enum SchemaV100: VersionedSchema {
   static let versionIdentifier: Schema.Version = .init(1, 0, 0)
   static var models: [any PersistentModel.Type] { [Automobile.self, House.self] }

   @Model
   final class Automobile {
      var id: UUID = UUID()
      var name: String = ""

      init(name: String) {
         self.name = name
      }
   }

   @Model
   final class House {
      var id: UUID = UUID()
      var name: String = ""
      var automobile: Automobile
      var createdDate: Date = Date()

      init(name: String, automobile: Automobile) {
         self.name = name
         self.automobile = automobile
      }
   }
}

Updated Schema (renamed House.automobile to House.automobileOne):

typealias CurrentSchemaModel = SchemaV101  /*updated from SchemaV100 */

enum SchemaV101: VersionedSchema {

   static let versionIdentifier: Schema.Version = .init(1, 0, 1)
   static var models: [any PersistentModel.Type] { [Automobile.self, House.self] }

   @Model
   final class Automobile {
      var id: UUID = UUID()
      var name: String = ""

      init(name: String) {
         self.name = name
      }
   }

   @Model
   final class House {
      var id: UUID = UUID()
      var name: String = ""
      @Attribute(originalName: "automobile") var automobileOne: Automobile
      var createdDate: Date = Date()

      init(name: String, automobileOne: Automobile) {
         self.name = name
         self.automobileOne = automobileOne
      }
   }
}

Migration Plan:

enum TestRenameMigrationPlan: SchemaMigrationPlan {

   static var schemas: [any VersionedSchema.Type] {
      let currentSchemas: [any VersionedSchema.Type] = [SchemaV100.self, SchemaV101.self]

      return currentSchemas
   }

   static var stages: [MigrationStage] { [migrateV100toV101] }

   // MARK: - V101
   static let migrateV100toV101 = MigrationStage.lightweight(fromVersion: SchemaV100.self, toVersion: SchemaV101.self)

}

SQLDebug logging shows this:

CoreData: sql: ALTER TABLE ZHOUSE RENAME TO _T_ZHOUSE
CoreData: sql: CREATE TABLE ZHOUSE ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZAUTOMOBILEONE INTEGER, ZCREATEDDATE TIMESTAMP, ZNAME VARCHAR, ZID BLOB )
CoreData: sql: INSERT INTO ZHOUSE (Z_PK,Z_ENT,Z_OPT,ZAUTOMOBILEONE,ZCREATEDDATE,ZNAME,ZID) SELECT Z_PK,Z_ENT,Z_OPT,?,ZCREATEDDATE,ZNAME,ZID FROM _T_ZHOUSE
CoreData: details: SQLite bind[0] = nil

Seems excessive to recreate table for a simple column rename, but I digress...

The curious part is the binding, SQLite bind[0] = nil, where I'd expect the originalName value (e.g. ZAUTOMOBILE) to be used.

Any thoughts or explanations would be appreciated.

Steve

Issue with SwiftData migration and renaming property when using @Attribute(originalName:)
 
 
Q