class Stock extends Model {
/** @ORM\ManyToOne(targetEntity="Unit") */
protected $unit;
// ...
}
class Unit extends Model
{
/** @ORM\Column(type="string") */
protected $title;
/** @ORM\ManyToOne(targetEntity="\Application\Entity\Supplier") */
protected $supplier;
// ...
}
class Model
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// ...
}
And then:
> orm:schema-tool:update --dump-sql
ALTER TABLE SupplierStock CHANGE unit_id unit_id VARCHAR(255) NOT NULL;
And I got a error because of Unit Id has int(11) type:
[HY000][1215] Cannot add foreign key constraint
Previously schema was generated by schema-tool too and unit_id column type was INT(11). So I think problem appeared in latest versions.
[forever@local 21:39:32 ppc-main]$ composer info | grep doctrine
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
doctrine/annotations v1.2.7 Docblock Annotations Parser
doctrine/cache v1.6.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.4.3 Common Library for Doctrine projects
doctrine/dbal v2.5.4 Database Abstraction Layer
doctrine/doctrine-module 0.10.0 Zend Framework 2 Module that provides Doctrine basic functionality required for ORM and ODM modules
doctrine/doctrine-orm-module 0.9.1 Zend Framework 2 Module that provides Doctrine ORM functionality
doctrine/inflector v1.1.0 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.8 Object-Relational-Mapper for PHP
gedmo/doctrine-extensions v2.4.13 Doctrine2 behavioral extensions
slm/queue-doctrine v0.4.1 Zend Framework 2 module that integrates Doctrine as queuing system
Annotations:
And then:
And I got a error because of Unit Id has int(11) type:
[HY000][1215] Cannot add foreign key constraint
Previously schema was generated by schema-tool too and unit_id column type was INT(11). So I think problem appeared in latest versions.