In desk Case_Supplies_Media I’ve column SupplyID_XRef. It at present has a overseas key reference to Media_List. I would like to vary the reference to Supplies_DVD_List. I discovered some bits and items, however I am unsure methods to put the entire thing collectively in code. I am utilizing GRDB.
Thanks prematurely for the assistance.
func update_Foreign_Key()
{
let the_Version = ModelData.get_Current_Version()
if the_Version == 6
{
do {
strive Database_GRDB.shared.databaseConnection!.write { db in
strive db.execute(sql: "UPDATE Case_Supplies_Media SET SupplyID_XRef = :worth", arguments: ["value": "Supplies_DVD_List"])
// FOREIGN KEY("SupplyID_XRef") REFERENCES "Media_List"
// change to this
// FOREIGN KEY("SupplyID_XRef") REFERENCES "Supplies_DVD_List"
// Set the model to 7
strive db.execute(sql: "UPDATE My_Settings SET Model = :model WHERE SettingsID = :id", arguments: ["version": 7, "id": 1])
}
} catch {
print("Updating the Foreign_Key values failed! (AppDelegate) (error)")
}
}
}