Doctrine 1
  1. Doctrine 1
  2. DC-292

no migrations diff on template change

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0-RC1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      the generate-migrations-diff does not create migrations if the template changes fields on the model.

      For example:

      File:
      tableName: files
      inheritance:
      extends: Eeecore_Record_File
      actAs:
      Fileable:

      The Fileable Template does the following... (the "fileFields" option stores a couple of fields to add to the model)

      public function setTableDefinition()
      {

      foreach ($this->_options['fileFields'] as $key => $field)

      { $this->hasColumn($field['name'], $field['type'], $field['length'], $field['options']); }

      }

      everything works fine on generate-migrations-models (the initial migrations)... but if we change something on the "fileFields" the generate-migrations-diff call doesn't do anything. We have to rebuild all migrations or write a new migration by hand.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I added coverage for this issue and it is working as expected. I compare two schemas:

        Article:
          columns:
            title: string(255)
            body: clob
        

        and I compare it to this one:

        Article:
          actAs: [Timestampable]
          columns:
            title: string(255)
            body: clob
        

        And now I do this:

                $migration = new Doctrine_Migration(dirname(__FILE__) . '/DC292/migrations');
                $diff = new Doctrine_Migration_Diff(dirname(__FILE__) . '/DC292/from.yml', dirname(__FILE__) . '/DC292/to.yml', $migration);
                $changes = $diff->generateChanges();
                print_r($changes);
        

        It has this in the array:

            [created_columns] => Array
                (
                    [article] => Array
                        (
                            [created_at] => Array
                                (
                                    [notnull] => 1
                                    [type] => timestamp
                                    [length] => 25
                                )
        
                            [updated_at] => Array
                                (
                                    [notnull] => 1
                                    [type] => timestamp
                                    [length] => 25
                                )
        
                        )
        
                )
        
        
        Show
        Jonathan H. Wage added a comment - I added coverage for this issue and it is working as expected. I compare two schemas: Article: columns: title: string(255) body: clob and I compare it to this one: Article: actAs: [Timestampable] columns: title: string(255) body: clob And now I do this: $migration = new Doctrine_Migration(dirname(__FILE__) . '/DC292/migrations'); $diff = new Doctrine_Migration_Diff(dirname(__FILE__) . '/DC292/from.yml', dirname(__FILE__) . '/DC292/to.yml', $migration); $changes = $diff->generateChanges(); print_r($changes); It has this in the array: [created_columns] => Array ( [article] => Array ( [created_at] => Array ( [notnull] => 1 [type] => timestamp [length] => 25 ) [updated_at] => Array ( [notnull] => 1 [type] => timestamp [length] => 25 ) ) )
        Hide
        Christian Jaentsch added a comment -

        The problem does not occur if you compare 2 schemas while one has a certain template and the other not.

        In my case the problem occurs when the 2 schemas both already have the same template definition but in one case the template itself has changed (e.g. injects one more field into the database table of a certain model via setTableDefinition).

        Show
        Christian Jaentsch added a comment - The problem does not occur if you compare 2 schemas while one has a certain template and the other not. In my case the problem occurs when the 2 schemas both already have the same template definition but in one case the template itself has changed (e.g. injects one more field into the database table of a certain model via setTableDefinition).
        Hide
        Jonathan H. Wage added a comment -

        When I test that it works as well. Can you show some kind of reproducible test case?

        Show
        Jonathan H. Wage added a comment - When I test that it works as well. Can you show some kind of reproducible test case?
        Hide
        Jonathan H. Wage added a comment -

        Maybe you could add a test case for this?

        Show
        Jonathan H. Wage added a comment - Maybe you could add a test case for this?

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Christian Jaentsch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: