我有以下代码:
$con = $this->em->getConnection();
$query = sprintf(
"ALTER TABLE client RENAME client_%s;
ALTER TABLE client_deduplicate RENAME client;
ALTER TABLE client DROP FOREIGN KEY rem_id;",
date('Ymd'),
date('Ymd')
);
$con->executeQuery($query);
当我尝试执行doctrine:schema:update --force
时,错误是:
An exception occurred while executing 'ALTER TABLE client ADD CONSTRAIN
T FK_D99D49C4CDEADB2A FOREIGN KEY (rem_id) REFERENCES rem (id)':
SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write;duplicate key
in table '#sql-1_54'
请帮助我。提前谢谢。
答案 0 :(得分:0)
首先放下您的外键。
您的外键已绑定到现有的client
表,因此只要外键存在,就无法重命名。