代码之家  ›  专栏  ›  技术社区  ›  automatix

如何使条令迁移为继承表生成适当的SQL?

  •  0
  • automatix  · 技术社区  · 4 年前

    我有两个实体 A B B类 extends A

    /**
     * Fruit
     *
     * @ORM\Table(
     *     name="fruits",
     *     indexes={}
     * )
     * @ORM\Entity
     * @ORM\InheritanceType("JOINED")
     * @ORM\DiscriminatorColumn(name="type", type="string")
     * @ORM\DiscriminatorMap({
     *     "apple" = "Apple"
     * })
     */
    abstract class Fruit extends AbstractEntity
    {
        /**
         * @var string
         * @ORM\Column(type="string" ...)
         */
        private $color;
    }
    
    /**
     * Apple
     *
     * @ORM\Table(
     *     name="apples",
     *     indexes={}
     * )
     * @ORM\Entity
     */
    class Apple extends Fruit
    {
        /**
         * @var string
         * @ORM\Column(type="string" ...)
         */
        private $foo;
    }
    

    migrations $ ./bin/console doctrine:migrations:diff )我希望它能在 apples FOREIGN KEY id 列,引用 fruit.id . 但这个参考资料不见了。

    如何让条令迁移来定义 child_table.id parent_table.id ? 或者手动编辑生成的SQL是自己实现这一点的唯一方法吗?

    0 回复  |  直到 4 年前