duanlu9970
2016-05-24 01:02
浏览 46
已采纳

Payum Symfony Doctrine无法创建表

I am trying to add a reference to a profile (called Square) to my Payment model (extension of Payum\Core\Model\ArrayObject), but I can't add a foreign key on the table. I want to do this so that when the payment is processed I can update a field saying that the square is now paid. Here is my setup:

Square.php

/**
 * @var integer
 *
 * @ORM\Column(name="msid", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="IDENTITY")
 */
private $msid;

Payment.php

/**
 * @ORM\OneToOne(targetEntity="Square")
 * @ORM\JoinColumn(name="msid", referencedColumnName="msid")
 */
private $square;

Error Codes:

[Doctrine\DBAL\Exception\DriverException]
 An exception occurred while executing 'ALTER TABLE payment ADD CONSTRAINT FK_6D28840D405F5364 FOREIGN KEY (msid) REFERENCES square (msid)':  
  SQLSTATE[HY000]: General error: 1005 Can't create table 'memorysq_version2.#sql-1658_1487b' (errno: 150)

Several other entities use the msid field to join on, it just isn't working with my Payum Payment model.

[Doctrine\DBAL\Driver\PDOException]                                                                       
 SQLSTATE[HY000]: General error: 1005 Can't create table 'memorysq_version2.#sql-1658_1487b' (errno: 150)

[PDOException]                                                                                            
 SQLSTATE[HY000]: General error: 1005 Can't create table 'memorysq_version2.#sql-1658_1487b' (errno: 150)

Output of --dump-sql

ALTER TABLE comment ADD CONSTRAINT FK_9474526C405F5364 FOREIGN KEY (msid) REFERENCES square (msid);
ALTER TABLE asset ADD CONSTRAINT FK_2AF5A5C405F5364 FOREIGN KEY (msid) REFERENCES square (msid);
ALTER TABLE payment ADD CONSTRAINT FK_6D28840D405F5364 FOREIGN KEY (msid) REFERENCES square (msid);
ALTER TABLE square ADD CONSTRAINT FK_CDE368A9F132696E FOREIGN KEY (userid) REFERENCES user (userid);
ALTER TABLE square ADD CONSTRAINT FK_CDE368A96AFF851C FOREIGN KEY (squaretype) REFERENCES product (id);
ALTER TABLE square ADD CONSTRAINT FK_CDE368A9DC01AA6E FOREIGN KEY (dualpicture) REFERENCES asset (assetid);
ALTER TABLE square ADD CONSTRAINT FK_CDE368A97F98CD1C FOREIGN KEY (clientid) REFERENCES client (clientid);
ALTER TABLE square ADD CONSTRAINT FK_CDE368A916DB4F89 FOREIGN KEY (picture) REFERENCES asset (assetid);

Several other entities use the msid field to join on, it's just not working with my Payum Payment model. Any help would be greatly appreciated.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题