i have a User and a Device Table. If a User connects to a Device, the Device will know its User (Foreign Key). A Device can only have one User.
I create a Foreign Key with
userToDevice.foreignKeyDeclaration.constrainReference(onDelete cascade)
it does alter the table like that
alter table Device add constraint DeviceFK10 foreign key (user_id) references User(id) on delete cascade;
Now, when i create a User, assign it to a Device and then delete the User, the user_id property at Device Table doesn't get deleted, too.
//CREATE DEVICE
val device = queries.deviceCreate("XYZ-Device", None) //None User
//ASSIGN USER TO DEVICE
update(deviceT)(d=> where(d.id === device.get.id) set(d.user_id := user.id))
//DELETE USER
userTable.deleteWhere(u=> u.id === user.id)
Why is it that it doesn't delete the Foreign Key even with on delete cascade?
EDIT:
I think i messed anything up with the relation.
Here you can see example code. Probably you can tell me what i am doing wrong here.
ShowCase on Github
EDIT2:
It seems like mysql doesn't even create the Foreign Key. I can't find any when i check localhost/phpmyadmin
I think the default table type for MySQL is MyISAM, which doesn't support foreign keys.