[DC-755] CLONE [DC-558] incorrect handling of MODEL_CLASS_PREFIX causes Doctrine_Migration_Diff to drop the whole database when working from YAML (Regression) Created: 20/Jun/10  Updated: 10/Oct/10

Status: Open
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Andrew Coulton Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Current HEAD of Doctrine 1.2


Attachments: File dc755TestCase.diff     File fix755.diff    

 Description   

Replicating the bug:
1. Set ATTR_MODEL_CLASS_PREFIX non-null
2. create schema file with entity
3. run doctrine build-all
4. copy schema file
5. edit schema file to add column to entity
6. run generate-migrations-diff from copy of schema file to edited schema file

Expected (previous) behaviour:
Migration is generated to add the new column to entity

Real behaviour:
Drops entity from database and creates new



 Comments   
Comment by Andrew Coulton [ 20/Jun/10 ]

This seems to be a regression caused by the fix for DC-558 which added the MODEL_CLASS_PREFIX to the $_toPrefix in Doctrine_Migration_Diff::generateChanges.

While this fixed the issue when generating diff from models to YAML, it has now created the reverse issue for generating diffs from YAML to YAML - as the models generated for the "from" schema do not get MODEL_CLASS_PREFIX prepended and so now this command will drop all existing tables and recreate.

I believe the fix may be to amend as:

Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
        $from = $this->_generateModels(
            Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_MODEL_CLASS_PREFIX) . self::$_fromPrefix,
            $this->_from);
        $to = $this->_generateModels(
            Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_MODEL_CLASS_PREFIX) . self::$_toPrefix,
            $this->_to                
        );

Since it seems that when presented with a folder of models _generateModels ignores the prefix anyway. However, I'm not sure of other impacts possible as a result?

Comment by Andrew Coulton [ 29/Aug/10 ]

I've been using and testing the modified version above locally for some time and it seems to work as expected. Any chance of this making it into core? Otherwise, the migrations feature is completely unusable when working YAML-YAML and using model prefixes on the newly released 1.2.3

Comment by Jonathan H. Wage [ 29/Aug/10 ]

Has anyone been able to produce this in a test case?

Comment by Andrew Coulton [ 30/Aug/10 ]

I've attached a diff file with the DC755TestCase and the required from and to YAML schema files to reproduce this bug. I wasn't sure whether you prefer like this or as a git commit?

Comment by Andrew Coulton [ 30/Aug/10 ]

Also attached a diff file of my proposed change to Doctrine_Migration_Diff to resolve this, but as I say unsure if it has implications on other migration types.

Comment by Andrew Coulton [ 10/Oct/10 ]

Fixed by http://github.com/acoulton/doctrine1/tree/DC-755

Generated at Mon Apr 21 07:21:10 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.