问题
Has anyone noticed this?
Whenever a model uses column_aggregation (inheritance), the schema.sql has 2 CREATE TABLE commands, one creates the basic table, and the other (apart from fields) adds an index on the inheritence column
CREATE TABLE Prop (id INT AUTO_INCREMENT, opt_property_type SMALLINT UNSIGNED DEFAULT 251 NOT NULL, property_nature VARCHAR(255), INDEX opt_property_type_idx (opt_property_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE Prop (id INT AUTO_INCREMENT, opt_property_type SMALLINT UNSIGNED DEFAULT 251 NOT NULL, property_nature VARCHAR(255), INDEX Prop_property_nature_idx (property_nature), INDEX opt_property_type_idx (opt_property_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
Note the inclusion of INDEX Prop_property_nature_idx (property_nature)
in the second statement
If anyone else is facing this, I will log a bug. Thanks
回答1:
I just came across this myself. It seems like doctrine:build-sql
is buggy.
One of the crazier things I discovered while investigating this is that doctrine:insert-sql
doesn't even use schema.sql. It dynamically generates and runs the SQL based on the model definitions.
Looks like this is a known bug and won't be fixed in Doctrine 1:
- http://www.doctrine-project.org/jira/browse/DC-123
- http://www.doctrine-project.org/jira/browse/DC-536
来源:https://stackoverflow.com/questions/6087413/doctrine-models-with-column-aggregation-inheritance-appear-twice-in-sql