[FLOW3-general] Doctrine Migration on Adding OneToOne Relationship to TYPO3.Media:Image
Cedric Ziel
cedric at cedric-ziel.com
Tue Nov 13 01:02:30 CET 2012
Hi everyone;
I followed an article (
http://usingflow3.tumblr.com/post/20519728321/typo3-media) on how to
create a relationship to TYPO3.Media. Unfortunately, my model doesn't
quite fit the case...
You can find the related code in a gist:
https://gist.github.com/b64698f0870334884494
i have a problem with foreign keys when wiring the TYPO3.Media with my
own Domain Model. When I do
./flow doctrine:update ; everything works fine-but when generating
migrations, I get an error.
I have a Base Model:
/**
* @var \TYPO3\Media\Domain\Model\Image
* @ORM\OneToOne(cascade={"all"}, orphanRemoval=true)
*/
protected $iconPath;
Initially, I get this Migration for table creation:
$this->addSql("CREATE TABLE metaio_arel_domain_model_arelobjectpoi
(persistence_object_identifier VARCHAR(40) NOT NULL, channel VARCHAR(40)
DEFAULT NULL, popup VARCHAR(40) DEFAULT NULL, iconpath VARCHAR(40)
DEFAULT NULL, thumbnailpath VARCHAR(40) DEFAULT NULL, title VARCHAR(50)
NOT NULL, description VARCHAR(255) NOT NULL, latitude DOUBLE PRECISION
NOT NULL, longitude DOUBLE PRECISION NOT NULL, altitude INT NOT NULL,
minaccuracy INT NOT NULL, maxdistance INT NOT NULL, mindistance INT NOT
NULL, parameters VARCHAR(255) NOT NULL, visibility VARCHAR(255) NOT
NULL, INDEX IDX_2798DA7AA2F98E47 (channel), UNIQUE INDEX
UNIQ_2798DA7AA096458 (popup), UNIQUE INDEX UNIQ_2798DA7AE5681231
(iconpath), UNIQUE INDEX UNIQ_2798DA7A3317F720 (thumbnailpath), PRIMARY
KEY(persistence_object_identifier)) DEFAULT CHARACTER SET utf8 COLLATE
utf8_unicode_ci ENGINE = InnoDB");
The migration code for the foreign key to TYPO3.Media is:
$this->addSql("ALTER TABLE metaio_arel_domain_model_arelobjectpoi ADD
CONSTRAINT FK_2798DA7A3317F720 FOREIGN KEY (thumbnailpath) REFERENCES
typo3_media_domain_model_image (persistence_object_identifier)");
But this one fails on executing the migration:
Uncaught Exception
An exception occurred while executing 'ALTER TABLE
metaio_arel_domain_model_arelobjectpoi ADD CONSTRAINT FK_2798DA7A3317F720
FOREIGN KEY (thumbnailpath) REFERENCES typo3_media_domain_model_image
(persistence_object_identifier)':
SQLSTATE[HY000]: General error: 1005 Can't create table
'car_dev.#sql-47f_f8' (errno: 150)
Is there anyone knowing what's wrong?
Thank You in advance!
Cedric
More information about the FLOW3-general
mailing list