[DBAL-504] DBAL Enum fields migration issue / PostgreSQL Created: 24/Apr/13  Updated: 14/Jan/15  Resolved: 03/Jan/14

Status: Resolved
Project: Doctrine DBAL
Component/s: Drivers, Schema Managers
Affects Version/s: 2.3.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: jos de witte Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


Issue Links:
is duplicated by DDC-2238 doctrine:schema:update partially broken Resolved
relates to DBAL-4 missing column type "enum" Resolved


When using Custom Doctrine DBAL Enums the migration created using diff

works fine the first time.

However the next time it generates a SQL statement trying to change to field type to INT from integer; (Redundant)
and a truncated statement:

"ALTER schemaname.fieldname SET" .. And that's it.

Comment by Tom Vogt [ 01/May/13 ]

Doesn't only happen on Enums. I don't use any enums and I have this problem. I use a couple of geo (postGIS) fields (point, linestring, polygon) as well as array fields, so either or all of those might be causing it, too.

Comment by Benjamin Eberlei [ 04/May/13 ]

We did some changes for PostgreSQL column diffs lately, can you verify this bug still exists on the 2.3 Branch of DBAL?

Comment by Tom Vogt [ 06/May/13 ]

I'm running this on Symfony2 with this composer.json config:

"doctrine/orm": "2.3.*",
"doctrine/doctrine-bundle": ">=2.1",

and I'm still getting this issue today.

Comment by Steve Müller [ 29/Dec/13 ]

jos de witte Tom Vogt The truncated statement is most probably related to the column default value issue on PostgreSQL which should be fixed in this commit: https://github.com/doctrine/dbal/commit/8fe741053849afadef12b8bef1cc3203966ef78f
Can you please again check if this still exists in the current master branch.
If it still exists please provide your mapping information and the changes that cause wrong SQL. Thank you.

Comment by Tom Vogt [ 30/Dec/13 ]

Quick check after updating (composer says my versions are now:

  • Updating doctrine/doctrine-bundle dev-master (2ed4639 => c65e5a2)
    Checking out c65e5a21d1db794511d11fe28918f41bd6072f8f
  • Updating doctrine/dbal 2.3.x-dev (59c310b => 907f30d)
    Checking out 907f30dec77a9e83fdba8705fc642fd7815cbc11

) still shows the error happening, but I've only run an update --dump-sql and didn't init a new database or anything.

here's my mapping for one entity that causes this:

<?xml version="1.0" encoding="utf-8"?>
	<entity name="BM2\SiteBundle\Entity\Building">
		<id name="id" type="integer">
			<generator strategy="IDENTITY"/>
		<field name="workers" type="float"/>
		<field name="active" type="boolean"/>
		<field name="condition" type="integer"/>
		<field name="resupply" type="integer"/>
		<field name="current_speed" type="float"/>

		<many-to-one field="settlement" target-entity="Settlement" inversed-by="buildings"/>
		<many-to-one field="type" target-entity="BuildingType" inversed-by="buildings"/>


and on " php app/console doctrine:schema:update --dump-sql" I get for this entity:

ALTER TABLE building ALTER current_speed SET ;

I do think it is related to the default column indeed, as adding this to an existing database required me to add it with a default value that is not reflected in the mapping data, so the current column definition for this entity is:

                                 Table "public.building"
    Column     |       Type       |                       Modifiers                       
 id            | integer          | not null default nextval('building_id_seq'::regclass)
 settlement_id | integer          | 
 type_id       | integer          | 
 workers       | double precision | not null
 active        | boolean          | not null
 condition     | integer          | not null
 resupply      | integer          | not null
 current_speed | double precision | not null default 1.0

and if I drop the default (alter table building alter current_speed drop default) then the problem disappears. So at least there's a workaround now, thanks!

Comment by Steve Müller [ 30/Dec/13 ]

Tom Vogt The problem is composer installed from DBAL 2.3-dev branch. But the patch is currently only available in DBAL master. You have to test this with the current DBAL master somehow.

Comment by Tom Vogt [ 30/Dec/13 ]

confirmed fixed:

Updating dependencies (including require-dev)                          
  - Updating doctrine/dbal (2.3.x-dev 907f30d => dev-master 9ec63e2)
    Checking out 9ec63e25b572db79c09cacccb844e33ed435e479

  - Updating doctrine/orm (2.3.x-dev 1a30e0a => dev-master 58c57c5)
    Checking out 58c57c50bf3582a1672bc09733afab4167ebd5ba
php app/console doctrine:generate:entities BM2 --no-backup
ALTER TABLE settlement ALTER starvation DROP DEFAULT;

it is now correctly updating.


Comment by Steve Müller [ 30/Dec/13 ]

Benjamin Eberlei can you resolve please? I cannot do that...

Generated at Tue Dec 01 04:34:29 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.