Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.0, 1.2.1
-
Fix Version/s: None
-
Component/s: Schema Files
-
Labels:None
-
Environment:HidePHP 5.2.11 (cli) (built: Oct 5 2009 21:36:09)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
Server version: Apache/2.2.13 (Unix)
Server version: 5.1.38-log MySQL Community Server (GPL)ShowPHP 5.2.11 (cli) (built: Oct 5 2009 21:36:09) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans Server version: Apache/2.2.13 (Unix) Server version: 5.1.38-log MySQL Community Server (GPL)
Description
This is the YML schema
Entity:
actAs:
Timestampable:
columns:
id:
type: integer(11)
primary: true
autoincrement: true
name: string(50)
relations:
DynamicFields:
class: DynamicField
local: id
foreign: dynamic_field_id
refClass: EntityDynamicFields
DynamicField:
actAs:
I18n:
fields: [name_xml]
columns:
id:
type: integer(11)
primary: true
autoincrement: true
name_xml:
type: string(50)
notnull: true
relations:
Entities:
class: Entity
local: dynamic_field_id
foreign: id
refClass: EntityDynamicFields
EntityDynamicFields:
actAs:
I18n:
fields: [value_xml]
columns:
id:
type: integer(11)
primary: true
dynamic_field_id:
type: integer(11)
primary: true
value_xml: string(250)
Airline:
inheritance:
extends: Entity
type: concrete
Bank:
inheritance:
extends: Entity
type: concrete
Client:
inheritance:
extends: Entity
type: concrete
Employe:
inheritance:
extends: Entity
type: concrete
Host:
inheritance:
extends: Entity
type: concrete
Partner:
inheritance:
extends: Entity
type: concrete
Person:
inheritance:
extends: Entity
type: concrete
Supplier:
inheritance:
extends: Entity
type: concrete
I run the commands
./doctrine build-all
and
./doctrine rebuild-db
The problem is when I verify if the foreign keys are created, but
these were only created for the "client" and "employee" models, to
"host" does not create the relationship in the MySQL, but if I rename
"host" with a name like "Ent", the relationship is established, or if I rename
the parent model "Entity" to "Zzzzz", all relations are created.
I did several tests, and the only way that the relation is created, is
that the model name, is alphabetically sorted before the parent model name.
This is a part of the dump of MySQL
ALTER TABLE `entity_dynamic_fields` ADD CONSTRAINT `entity_dynamic_fields_dynamic_field_id_dynamic_field_id` FOREIGN KEY (`dynamic_field_id`) REFERENCES `dynamic_field` (`id`), ADD CONSTRAINT `entity_dynamic_fields_id_airline_id` FOREIGN KEY (`id`) REFERENCES `airline` (`id`), ADD CONSTRAINT `entity_dynamic_fields_id_bank_id` FOREIGN KEY (`id`) REFERENCES `bank` (`id`), ADD CONSTRAINT `entity_dynamic_fields_id_client_id` FOREIGN KEY (`id`) REFERENCES `client` (`id`), ADD CONSTRAINT `entity_dynamic_fields_id_employe_id` FOREIGN KEY (`id`) REFERENCES `employe` (`id`), ADD CONSTRAINT `entity_dynamic_fields_id_entity_id` FOREIGN KEY (`id`) REFERENCES `entity` (`id`);
The other foreign keys are missed
you can view the diagram EER created with reverse engineering of MySQL Workbench
![]()
I know where is the problem, in Doctrine_Core::loadModels the list of models returned are alphabetically sorted, if I can rearrange the array by inheritance, the foreign keys for the models ('host' 'partner' 'person' 'supplier') are created.
more explicity:
I have this
Array ( [0] => Airline [1] => Bank [2] => Client [3] => DynamicField [4] => Employe [5] => Entity [6] => EntityDynamicFields [7] => Host [8] => Partner [9] => Person [10] => Supplier )I need this
Array ( [0] => Entity [1] => Airline [2] => Bank [3] => Client [4] => Employe [5] => Host [6] => Partner [7] => Person [8] => Supplier [9] => DynamicField [10] => EntityDynamicFields )