I have two objects: File and FileDetail. A File can have many FileDetails, but a FileDetail can only have one File. I can get this to work, but I can't delete anything from the database because of key constraints (I can't delete the File row because FileDetail depends on it, and vice versa). I have the following yaml:
File:
columns:
id:
type: integer
primary: true
autoincrement: true
...
fileDetail_id: integer
relations:
...
FileDetail:
local: fileDetail_id
foreign: id
cascade: [delete]
FileDetail:
columns:
id:
type: integer
primary: true
autoincrement: true
file_id: integer
...
relations:
...
File:
local: file_id
foreign: id
foreignAlias: Revisions
cascade: [delete]
Ideally what I would like to happen is when I delete the File row, that all the child FileDetails are deleted as well. It would even be nice if I could just manually delete all the FileDetail rows and then the File row, but because of the key constraints I'm unable to:
1451 - Cannot delete or update a parent row: a foreign key constraint fails (`file`, CONSTRAINT `file_filedetail_id_file_detail_id` FOREIGN KEY (`filedetail_id`) REFERENCES `file_detail` (`id`))
How would I get this type of relationship to work (One-To-Many on one side, but One-To-One on the other). Or should I just treat this as a Many-To-Many on both sides?