SQL error foreign key constraint
I'm struggling for four days days now with an sql foreign key constraint fails and I reaaly have no idea why. I've read all I could about that subject and it seems that everything is fine.
Here is my schema.yml
Soiree:
actAs: { Timestampable: ~ }
columns:
titre: { type: string(255), notnull: true }
description: { type: blob(), notnull: true }
adresse: { type: string(255), notnull: true, unique: true }
code_postal: {type: integer, notnull: true }
ville: {type: string(255), notnull:true}
date: {type: timestamp, notnull: true }
type_id: {type: integer, notnull: true }
flyer: {type: string(255), notnull:true }
is_visible: { type: boolean, notnull:true, default:0 }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Type: {onDelete: CASCADE, local: type_id, foreign: id, alias: Types, class: Type, refClass: Soiree}
Type:
columns:
titre: {type: string(255), notnull: true}
Invitation:
actAs: { Timestampable: ~ }
columns:
titre: { type: string(255), notnull: true }
description: { type: blob(), notnull: true }
image: { type: string(255), notnull: true }
is_sent: {type: boolean, notnull:true, default:0}
adresse: { type: string(255) }
code_postal: { type: string(255) }
code_QR: {type: string(255), notnull: true }
invites_id: {type:integer }
user_id: {type:integer, notnull: true}
groupe_invites_id : {type:integer, notnull: true }
soiree_id: {type:integer, notnull:true}
relations:
Invites: { onDelete: CASCADE, local: invites_id, foreign: id, alias: invite, class: Invites, refClass: Invitation }
Groupe_invites: { onDelete: CASCADE, local: groupe_invites_id, foreign: id, alias: invit_groupes, class: Groupe_invites, refClass: Invitation }
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias :Soirees, class: Soiree, refClass: Invitation }
Groupe_invites:
actAs: { Timestampable: ~ }
columns:
titre: { type: string(255), notnull: true }
description: { type: string(255), notnull: true, unique: true }
invites_id: { type: integer, notnull: true }
soiree_id: { type: integer }
user_id: {type:integer, notnull: true}
relations:
Invites:
onDelete: CASCADE
local: invites_id
foreign: id
alias: invites
class: Invites
refClass: Groupe_invites
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias: Soiree, class: Soiree, refClass: Groupe_invites }
Invites:
columns:
nom: { type: string(255), notnull: true }
prenom: { type: string(255), notnull: true }
age: {type: integer, notnull : true }
email: {type: string(255), notnull: true, unique: true }
adresse: {type: blob(), notnull: true }
telephone: {type: integer(255), notnull: true }
soiree_id: {type: integer, notnull: true }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias: Soiree_invite, class: Soiree, refClass: Invites }
Organisateur:
actAs: {Timestampable: ~ }
columns:
nom: {type: string(255), notnull: true }
prenom: {type: string(255), notnull: true }
age: {type: integer, notnull: true }
description: {type: blob(), notnull: true }
photo: {type: string(255), notnull: true }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
I开发者_高级运维mage:
columns:
titre: {type: string(255), notnull: true }
description: {type: string(255), notnull: true }
lien: {type: string(255)}
album_id: {type: integer}
user_id: {type: integer}
relations:
Album: {onDelete: CASCADE, local: album_id, foreign: id, alias: Albums, class:Album, refClass:Image}
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id}
Album:
columns:
titre: {type: string(255), notnull: true }
description: {type: blob(), notnull: true }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id}
And I have an error of type:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (soiree
.invitation
, CONSTRAINT invitation_ibfk_1
FOREIGN KEY (invites_id
) REFERENCES invitation
(id
) ON DELETE CASCADE)
I really need help on this one, thank you !
I typically add the id column to my tables. Apply this to the tables where it makes sense:
id: { type: integer, primary: true, autoincrement: true }
精彩评论