Jira issue originally created by user josdewitte:
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 created by tom:
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 created by @beberlei:
We did some changes for PostgreSQL column diffs lately, can you verify this bug still exists on the 2.3 Branch of DBAL?
I'm running this on Symfony2 with this composer.json config:
and I'm still getting this issue today.
Comment created by @deeky666:
[josdewitte] [tom] The truncated statement is most probably related to the column default value issue on PostgreSQL which should be fixed in this commit: 8fe7410
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.
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 907f30d
) 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"?>
<id name="id" type="integer">
<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:
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!
[~tom] 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.
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.
[~beberlei] can you resolve please? I cannot do that...
Issue was closed with resolution "Fixed"