Fixtures and inheritance in Symfony

Posted by Tere on Stack Overflow See other posts from Stack Overflow or by Tere
Published on 2010-04-19T20:31:04Z Indexed on 2010/04/19 20:33 UTC
Read the original article Hit count: 365

Filed under:
|
|

Hi!

I have a database schema in Symfony like this:

    Persona:
 actAs: { Timestampable: ~ }
 columns:
  primer_nombre:  { type: string(255), notnull: true }
  segundo_nombre: { type: string(255) }
  apellido:   { type: string(255), notnull: true }
  rut:         { type: string(255) }
  email:       { type: string(255) }
  email2:      { type: string(255) } 
  direccion:     { type: string(400) }
  ciudad:        { type: string(255) }
  region:      { type: string(255) }
  pais:     { type: string(255) }
  telefono:       { type: string(255) }
  telefono2:      { type: string(255) }
  fecha_nacimiento:   { type: date }

Alumno:
 inheritance:
    type:          concrete
    extends:       Persona
 columns:
  comentario:  { type: string(255) }
  estado_pago: { type: string(255) }

Alumno_Beca:
 columns:
  persona_id:   { type: integer, primary: true }
  beca_id: { type: integer, primary: true }
 relations:
  Alumno: { onDelete: CASCADE, local: persona_id, foreign: id } 
  Beca: { onDelete: CASCADE, local: beca_id, foreign: id } 

Beca:
 columns:
  nombre:        { type: string(255) }
  monto:      { type: double }
  porcentaje:  { type: double }
  descripcion: { type: string(5000) }

As you see, "alumno" has a concrete inheritance from "persona". Now I'm trying to create fixtures for this two tables, and I can't make Doctrine to load them. It gives me this error:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (eat/alumno__beca, CONSTRAINT alumno__beca_persona_id_alumno_id FOREIGN KEY (persona_id) REFERENCES alumno (id) ON DELETE CASCADE)

Does someone know how to write a fixture for a table inherited from another?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about symfony