Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

399
Vistas
How to make Doctrine PostgreSQL Foreign Key constrain DEFERRABLE

Using Doctrine2 and PostgreSQL I need to create foreign key constrains DEFERRABLE and INITIALLY DEFERRED

Found options "deferrable" and "deferred" In Doctrine/DBAL/Platforms/PostgreSqlPlatform.php, but have no idea where to use it inside Entity annotations

<?php 
/**
 * Class User
 *
 * @ORM\Table(name="jira_issues_changelogs")
 * @ORM\Entity
 * @package JiraBundle\Entity\Issue
 */
class Changelog
{
    /**
     * @var string
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="NONE")
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="\JiraBundle\Entity\Issue", inversedBy="changelog")
     * @ORM\JoinColumn(name="issue", referencedColumnName="id")

     Need this column foreign key to be DEFERRABLE INITIALLY DEFERRED

     */
    protected $issue;
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I hit this same problem with an app I was working on, and came to the conclusion that the DEFERRABLE support in Doctrine DBAL isn't exposed to Doctrine ORM.

The crux of the problem is that in the ORM's SchemaTool the gatherRelationJoinColumns() method doesn't discover any $fkOptions except for onDelete. In order to support adding 'deferrable' there would need to be extended syntax in the ORM mapping layer for it.

In my case it was easier to just patch SchemaTool to add it than coordinate with upstream to add this properly, as there are very few references to people wanting to use advanced FK options on Google.

I thought I'd dump an answer here to avoid other people having to trace the issue themselves...

If someone wants to file a Doctrine ORM issue about it, be my guest!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda