DDC-1017: mysql error when renaming a manyToOne property #1269

Closed
opened 2026-01-22 13:07:48 +01:00 by admin · 3 comments
Owner

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.

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.
admin added the Bug label 2026-01-22 13:07:48 +01:00
admin closed this issue 2026-01-22 13:07:48 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 19, 2011):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Jun 19, 2011): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Jun 19, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jun 19, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 3 attachments from Jira into https://gist.github.com/3cc377385b9ddca9269d

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 3 attachments from Jira into https://gist.github.com/3cc377385b9ddca9269d - [10928_Task.php](https://gist.github.com/3cc377385b9ddca9269d#file-10928_Task-php) - [10929_User.php](https://gist.github.com/3cc377385b9ddca9269d#file-10929_User-php) - [10930_export.sql](https://gist.github.com/3cc377385b9ddca9269d#file-10930_export-sql)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1269