In the Foreign Key Constraints Chapter I am trying to set up a foreign key constraint using the code as outlined in the book:
extension Marker : Migration {
static func prepare(on connection: PostgreSQLConnection) -> Future<Void> {
return Database.create(self, on: connection) { builder in
try addProperties(to: builder)
try builder.addReference(from: \.userId, to: \User.id)
}
}
}
but am getting the following error:
Invalid component of Swift key path
on the addReference line. What is the correct way to do this? (Iām assuming things have changed since that chapter was written?)
Thanks!