Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0
-
Fix Version/s: 2.1
-
Component/s: ORM
-
Security Level: All
-
Labels:None
-
Environment:Ubuntu Maverick 10.10
PHP 5.3.3
System Linux pim-laptop 2.6.35-25-generic-pae #44-Ubuntu SMP Fri Jan 21 19:01:46 UTC 2011 i686
mysql Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (i686) using readline 6.1
Description
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.