i learn Symfony and Doctrine with Jobeet. I would like add relation in JobeetJob. this is original: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/03
I do like this:
JobeetCategory:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
JobeetCategorya:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
JobeetJob:
actAs: { Timestampable: ~ }
columns:
category_id: { type: integer, notnull: true }
categorya_id: { type: integer, notnull: true }
type: { type: string(255) }
(...)
expires_at: { type: timestamp, notnull: true }
relations:
JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs }
JobeetCategorya: { onDelete: CASCADE, local: categorya_id, foreign: id, foreignAlias: JobeetJobsa }
when i do:
php symfony doctrine:build --all --and-load
i have error
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
jobeet
.jobeet_job
, CONSTRAINTjobeet_job_categorya_id_jobeet_categorya_id
FOREIGN KEY (categorya_id
) REFERENCESjobeet_categorya
(id
) ON DELETE CASCADE)
why?
How to create a relation in Doctrine?
– hakredoctrine:build --all --and-load
then I get this error: (your error message is already in the question so put it in between) – hakre