Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

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 'informationschema' and then tabel 'key_columnusage' I find this line:
CONSTRAINT_CATALOG Null
CONSTRAINT_SCHEMA maia
CONSTRAINTNAME Task_ibfk1
TABLE_CATALOG Null
TABLE_SCHEMA maia
TABLE_NAME Task
COLUMNNAME userid
ORDINAL_POSITION 1
POSITIONIN_UNIQUECONSTRAINT 1
REFERENCEDTABLESCHEMA maia
REFERENCEDTABLENAME User
REFERENCEDCOLUMNNAME id

I had to perform the following query on my database before I was able to update:
ALTER TABLE User DROP FOREIGN KEY Taskibfk1;

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

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.