<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Thu Jun 20 11:39:49 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DBAL-420/DBAL-420.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DBAL-420] Schema Drop SQL incorrect on PostgreSQL with entities with GeneratedValue(strategy=&quot;IDENTITY&quot;)</title>
                <link>http://www.doctrine-project.org/jira/browse/DBAL-420</link>
                <project id="10040" key="DBAL">Doctrine DBAL</project>
                        <description>&lt;p&gt;This problem is probably related to #&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DBAL-54&quot; title=&quot;Incorrect sequence dropping in PostgreSQL&quot;&gt;&lt;del&gt;DBAL-54&lt;/del&gt;&lt;/a&gt;. However that was closed by the raiser as he changed his Entity model and it went away.&lt;/p&gt;

&lt;p&gt;When schema drop is run the following error occurs:&lt;br/&gt;
Doctrine\DBAL\DBALException: An exception occurred while executing &apos;DROP SEQUENCE radacct_radacctid_seq&apos;:&lt;/p&gt;

&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;2BP01&amp;#93;&lt;/span&gt;: Dependent objects still exist: 7 ERROR:  cannot drop sequence radacct_radacctid_seq because other objects depend on it&lt;br/&gt;
DETAIL:  default for table radacct column radacctid depends on sequence radacct_radacctid_seq&lt;br/&gt;
HINT:  Use DROP ... CASCADE to drop the dependent objects too.&lt;/p&gt;


&lt;p&gt;The source of this problem is the difference between strategy=&quot;IDENTITY&quot; and strategy=&quot;SEQUENCE&quot;&lt;/p&gt;

&lt;p&gt;With SEQUENCE doctrine creates the table schema with field type BIGINT and no specified. It then creates a seperate sequence and as far as I can tell takes care of getting and inserting the next id number itself.&lt;/p&gt;

&lt;p&gt;With IDENTITY doctrine creates the table schema with field type BIGSERIAL and no specified default. Now postgres automatically creates a sequence and creates the column with type BIGINT and sets the DEFAULT to the pgpsql statement required to get the nextval from the sequence.&lt;/p&gt;

&lt;p&gt;At this point the two differently configured tables will work successfully and identically, except SEQUENCE tables will only get a correct new ID when run through the doctrine code while IDENTITY tables will get the correct new ID whenever an insert is done to the table.&lt;/p&gt;

&lt;p&gt;Because in the case of an IDENTITY field postgresql creates the field with a default value refering to the sequence the sequence can not be deleted before the table reference is removed.&lt;/p&gt;

&lt;p&gt;For my case I need the IDENTITY fields to work as we have a RADIUS server that needs to insert into one table which is managed and mapped to an entity in Doctrine.&lt;/p&gt;

&lt;p&gt;Swapping the order of DROP TABLE and DROP SEQUENCE commands in Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php in getQueries() line 159. Does not work as a quick fix. The following error occurs as the sequence is quite correctly be dropped along with the table.&lt;/p&gt;

&lt;p&gt;Doctrine\DBAL\DBALException: An exception occurred while executing &apos;DROP SEQUENCE radacct_radacctid_seq&apos;:&lt;/p&gt;

&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42P01&amp;#93;&lt;/span&gt;: Undefined table: 7 ERROR:  sequence &quot;radacct_radacctid_seq&quot; does not exist&lt;/p&gt;
</description>
                <environment>Symfony 2.1, PHP5.4, PostgreSQL 9.1 on Ubuntu 12.04</environment>
            <key id="14403">DBAL-420</key>
            <summary>Schema Drop SQL incorrect on PostgreSQL with entities with GeneratedValue(strategy=&quot;IDENTITY&quot;)</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="adamashley">Adam Ashley</reporter>
                        <labels>
                        <label>postgresql</label>
                        <label>schematool</label>
                    </labels>
                <created>Wed, 23 Jan 2013 09:22:22 +0000</created>
                <updated>Sun, 14 Apr 2013 12:37:30 +0000</updated>
                    <resolved>Sun, 14 Apr 2013 12:37:30 +0000</resolved>
                            <version>2.3.2</version>
                                <fixVersion>2.3.4</fixVersion>
                                <component>Schema Managers</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="19395" author="adamashley" created="Thu, 24 Jan 2013 00:00:41 +0000"  >&lt;p&gt;This issue also appears to affect Doctrine_Migrations. Generated migrations try to drop and recreate automatically generated sequences associated with SERIAL fields making a mess of the database.&lt;/p&gt;</comment>
                    <comment id="19882" author="beberlei" created="Fri, 22 Mar 2013 10:05:35 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-289&amp;#93;&lt;/span&gt; was opened&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/dbal/pull/289&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/289&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="19985" author="powerkiki" created="Fri, 12 Apr 2013 06:20:15 +0000"  >&lt;p&gt;@Adam Ashley, could you test whether &lt;a href=&quot;https://github.com/doctrine/dbal/pull/289&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/289&lt;/a&gt; solve your issue ?&lt;/p&gt;</comment>
                    <comment id="20008" author="doctrinebot" created="Sun, 14 Apr 2013 12:36:08 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-289&amp;#93;&lt;/span&gt; was closed:&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/dbal/pull/289&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/289&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>