<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Mon May 20 12:31:00 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/DMIG-30/DMIG-30.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>[DMIG-30] Make :migrations:diff smart and generate Schema object changes, not SQL directly</title>
                <link>http://www.doctrine-project.org/jira/browse/DMIG-30</link>
                <project id="10041" key="DMIG">Doctrine Migrations</project>
                        <description>&lt;p&gt;Currently when using :migrations:diff the generated output will use addSql() exclusively. However there has to be a way to generate changes on the schema objects themselves by using the SchemaDiff objects and generating code from them.&lt;/p&gt;</description>
                <environment></environment>
            <key id="13196">DMIG-30</key>
            <summary>Make :migrations:diff smart and generate Schema object changes, not SQL directly</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="beberlei">Benjamin Eberlei</reporter>
                        <labels>
                    </labels>
                <created>Wed, 16 Nov 2011 22:34:01 +0000</created>
                <updated>Fri, 17 Feb 2012 06:19:43 +0000</updated>
                                                                            <due></due>
                    <votes>2</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="17367" author="veonik" created="Fri, 3 Feb 2012 22:52:55 +0000"  >&lt;p&gt;I think this would be something that would greatly increase the usefulness of migrations.&lt;/p&gt;

&lt;p&gt;After looking things over, I think doing something like this could work:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Instantiate an instance of Doctrine\ORM\Tools\Comparator, and retrieve a Doctrine\DBAL\Schema\SchemaDiff using $comparator-&amp;gt;compare($fromSchema, $toSchema);&lt;/li&gt;
	&lt;li&gt;Iterate over each of the SchemaDiff&apos;s properties to retrieve new tables, dropped tables, columns, indexes, etc to generate both up and down code&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;It seems fairly simple, but I get kind of lost thinking about how it can be tested.&lt;/p&gt;

&lt;p&gt;Another option, which may in the end be easier but more dirty, is to create a &apos;PhpPlatform&apos; that only actually implements the getCreateTableSQL, getDropTableSQL, etc methods of Doctrine\DBAL\Platforms\AbstractPlatform.&lt;/p&gt;</comment>
                    <comment id="17430" author="veonik" created="Fri, 17 Feb 2012 06:15:05 +0000"  >&lt;p&gt;I&apos;ve gone and followed what I outlined in my last comment, but there is a small snag.&lt;/p&gt;

&lt;p&gt;Comparator and SchemaDiff check for schema changes that are not possible to make using public methods. An example is a dropped index. Both Comparator and SchemaDiff support dropping indexes, but there is no Table#dropIndex to actually make it happen. &lt;/p&gt;

&lt;p&gt;However, if you use Reflection to modify the underlying Table#$_indexes array, then the proper SQL will be generated by SchemaDiff. Terrible and dirty, I know. We should do something about it &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; Should I create a ticket?&lt;/p&gt;

&lt;p&gt;Anyway, I&apos;ve attached a patch (based on the current master, 9e81984) of what I&apos;ve come up with. I &lt;em&gt;think&lt;/em&gt; I&apos;ve covered everything. This will even generate code to drop indexes and foreign keys (using Reflection). I&apos;ve tried it on a schema of around 90 entities and it works beautifully. Of course, it&apos;s definitely not done or ready, but I wanted to see what was thought about what I&apos;ve done.&lt;/p&gt;

&lt;p&gt;Finally, what would be considered an acceptable test for this kind of thing? I suppose if I refactor all of the code generating bits into individual methods, I could pretty easily test for expected output. Am I on the right track?&lt;/p&gt;

&lt;p&gt;edit: by the way, use &lt;tt&gt;migrations:diff --no-platform&lt;/tt&gt; to generate the migration&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11161" name="DMIG-30.patch" size="24317" author="veonik" created="Fri, 17 Feb 2012 06:15:05 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>