我正在尝试在第三方包中的实体中添加属性。这是我的 yml 文件
Acme\Bundle\AppBundle\Entity\Group:
type: entity
table: pim_catalog_group_new
changeTrackingPolicy: DEFERRED_EXPLICIT
fields:
sortOrder:
type: integer
manyToOne:
family:
targetEntity: Pim\Component\Catalog\Model\FamilyInterface
joinColumn:
name: family_id
referencedColumnName: id
onDelete: 'SET NULL'
当我运行以下命令时
php app/console doctrine:migrations:diff
它给了我id, family_id, sortOrder, code
和其他简单的字段,但不包括来自父类的关联字段。这是生成的迁移脚本(请注意,缺少父级的 oneToMany、manyToMany 关联字段):
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE pim_catalog_group (id INT AUTO_INCREMENT NOT NULL, family_id INT DEFAULT NULL, code VARCHAR(100) NOT NULL, sortOrder INT NOT NULL, UNIQUE INDEX UNIQ_3196D4CB77153098 (code), INDEX IDX_3196D4CBC35E566A (family_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE pim_catalog_group ADD CONSTRAINT FK_3196D4CBC35E566A FOREIGN KEY (family_id) REFERENCES pim_catalog_family (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE pim_catalog_group_translation DROP FOREIGN KEY FK_622D98DB7E366551');
$this->addSql('ALTER TABLE pim_catalog_group_translation ADD CONSTRAINT FK_622D98DB7E366551 FOREIGN KEY (foreign_key) REFERENCES pim_catalog_group (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE pim_catalog_association_group DROP FOREIGN KEY FK_E91414DDFE54D947');
$this->addSql('ALTER TABLE pim_catalog_association_group ADD CONSTRAINT FK_E91414DDFE54D947 FOREIGN KEY (group_id) REFERENCES pim_catalog_group (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE pim_catalog_group_product DROP FOREIGN KEY FK_7AC0C83AFE54D947');
$this->addSql('ALTER TABLE pim_catalog_group_product ADD CONSTRAINT FK_7AC0C83AFE54D947 FOREIGN KEY (group_id) REFERENCES pim_catalog_group (id) ON DELETE CASCADE');
}