[U-co] Symfony - Doctrine con PostgreSQL

Carlos Beltrán Villamizar cbeltranv en cable.net.co
Mar Ene 12 21:40:16 UTC 2010


El mar, 12-01-2010 a las 13:44 -0500, Rafael Enrique Ortiz Guerrero
escribió:
> Hola.
> 
> 
> 
> 2010/1/12 Carlos Beltrán Villamizar <cbeltranv en cable.net.co>:
> > Compañeros de la lista. Estoy con el tema Symfony - Doctrine con
> > PostgreSQL y suena interesantisimo. Sin mebargo un esquema que tengo con
> > dos tablas y dos columnas como llave primaria y una relación entre ellas
> > me genera error en una definición de llave y en una relación que no la
> > contemplo. Quisiera saber si en esta lista hay personas relacionadas con
> > el tema. Gracias.
> 
> Quizas sea mas conveniente la lista de SL-Prog.
> 
> http://el-directorio.org/Sl-prog
> 
> y tambien que envies el error especifico que te aparece en Postgres.

Rafael Enrique

Gracias por tu pronta respuesta. Voy a intentar en la lista que sugieres
y mientras tanto aclaro el caso para esta lista. En efecto los dos
errores se producen a partir del siguiente schema.yml:

detect_relations: false
Socio:
  connection: doctrine
  tableName: socio
  columns:
    idunidadgestionfuente:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
    id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      sequence: socio_id
      autoincrement: true
    idunidadgestiontercero:
      type: integer(4)
      fixed: false
      unsigned: false
      notnull: true
      primary: false
    idtercero:
      type: integer(8)
      fixed: false
      unsigned: false
      notnull: true
      primary: false
  actAs: [Timestampable]
  indexes:
    socio_idunidadgestionfuente_id_index:
      fields: [idunidadgestionfuente, id]
      type: unique
    socio_idunidadgestiontercero_id_index:
      fields: [idunidadgestiontercero, idtercero]
      type: unique
  relations:
    Tercero:
      local: 'idunidadgestiontercero, idtercero'
      foreign: 'idunidadgestionfuente, id'
      type: one
      foreignType: many
      onDelete: CASCADE
Tercero:
  connection: doctrine
  tableName: tercero
  columns:
    idunidadgestionfuente:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      sequence: tercero_id
      autoincrement: true
  actAs: [Timestampable]
  indexes:
    tercero_idunidadgestionfuente_id_index:
      fields: [idunidadgestionfuente, id]
      type: unique
                        
A continuación el schema.sql generado:

CREATE TABLE socio (idunidadgestionfuente INT, id SERIAL,
idunidadgestiontercero INT NOT NULL, idtercero BIGINT NOT NULL,
created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY
KEY(idunidadgestionfuente, id));
CREATE TABLE tercero (idunidadgestionfuente INT, id BIGSERIAL,
created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY
KEY(idunidadgestionfuente, id));
CREATE UNIQUE INDEX socio_idunidadgestiontercero_id_index ON socio
(idunidadgestiontercero, idtercero);
CREATE UNIQUE INDEX socio_idunidadgestionfuente_id_index ON socio
(idunidadgestionfuente, id);
CREATE UNIQUE INDEX tercero_idunidadgestionfuente_id_index ON tercero
(idunidadgestionfuente, id);
CREATE INDEX idunidadgestionfuente, id ON tercero
(idunidadgestionfuente, id);
ALTER TABLE socio ADD CONSTRAINT siti FOREIGN KEY
(idunidadgestiontercero, idtercero) REFERENCES
tercero(idunidadgestionfuente, id) ON DELETE CASCADE NOT DEFERRABLE
INITIALLY IMMEDIATE;
ALTER TABLE tercero ADD CONSTRAINT tisi FOREIGN KEY
(idunidadgestionfuente, id) REFERENCES socio(idunidadgestiontercero,
idtercero) NOT DEFERRABLE INITIALLY IMMEDIATE;

Primero que todo <CREATE INDEX idunidadgestionfuente, id ON tercero
(idunidadgestionfuente, id);> no es sintácticamente correcto y no es
necesario por que ya definí el índice. ¿Como decir esto en el esquema
pues no debe generar el índice?.
Además el <ALTER TABLE tercero ADD CONSTRAINT tisi FOREIGN KEY
(idunidadgestionfuente, id) REFERENCES socio(idunidadgestiontercero,
idtercero) NOT DEFERRABLE INITIALLY IMMEDIATE;> no debe estar presente
porqué esta relación se define desde socio a tercero. ¿Como puedo en el
esquema doctrine decir esto para que no genere doble relación.

Gracias de antemano Carlos.





Más información sobre la lista de distribución Ubuntu-co