Doctrine: Models with column_aggregation inheritance appear twice in SQL

200 views Asked by At

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

There are 1 answers

0
Jeremy Kauffman On

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: