mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1017: mysql error when renaming a manyToOne property #1269
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Feb 4, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user phazebroek:
These are my initial properties with annotations:
// Task.php
/****
* @ManyToOne(targetEntity="Maia\Model\User", inversedBy="tasks")
*/
protected $user;
// User.php
/****
* @OneToMany(targetEntity="Maia\Model\Task", mappedBy="user")
*/
protected $tasks;
At this stage, everythings works fine.
However when I try to rename the property $user to $author like so:
// User.php
/****
* @OneToMany(targetEntity="Maia\Model\Task", mappedBy="author")
*/
protected $tasks;
and change the corresponding entity like this:
/****
* @ManyToOne(targetEntity="Maia\Model\User", inversedBy="tasks")
*/
protected $author;
and then try to update my database using the './doctrine orm:schema-tool:update --force' command, I get the following error:
[PDOException]
SQLSTATE[HY000]: General error: 1025 Error on rename of './maia/#sql-508_2be' to './maia/Task' (errno: 150)
in the database 'information_schema' and then tabel 'key_column_usage' I find this line:
CONSTRAINT_CATALOG Null
CONSTRAINT_SCHEMA maia
CONSTRAINT_NAME Task_ibfk_1
TABLE_CATALOG Null
TABLE_SCHEMA maia
TABLE_NAME Task
COLUMN_NAME user_id
ORDINAL_POSITION 1
POSITION_IN_UNIQUE_CONSTRAINT 1
REFERENCED_TABLE_SCHEMA maia
REFERENCED_TABLE_NAME User
REFERENCED_COLUMN_NAME id
I had to perform the following query on my database before I was able to update:
ALTER TABLE User DROP FOREIGN KEY Task_ibfk_1;
Maybe I am doing something wrong, this is my first project with Doctrine, but I tweeted about the error and somebody asked me to create a ticket so here it is.
@doctrinebot commented on GitHub (Jun 19, 2011):
Comment created by @beberlei:
Fixed
@doctrinebot commented on GitHub (Jun 19, 2011):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 3 attachments from Jira into https://gist.github.com/3cc377385b9ddca9269d