Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-931

Newly generated Migration Classes failing to load due to method used to determine class name


    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0-ALPHA1, 1.2.0-ALPHA2, 1.2.0-ALPHA3, 1.2.0-BETA1, 1.2.0-BETA2, 1.2.0-BETA3, 1.2.0-RC1, 1.2.0, 1.2.1, 1.2.2, 1.2.3
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
    • Environment:


      The loadMigrationClassesFromDirectory() method in Doctrine_Migration uses array_diff on get_declared_classes() between including each classes script.

      When a new migration class is generated by Doctrine_Core::generateMigrationsFromDiff it's class is loaded, which means loadMigrationClassesFromDirectory silently fails to load the newly generated migration on the same request. This means that scripts that first generate migrations and then apply them must be executed twice - first to generate then to apply.

      The following example code is used to check if the database has been modifed, generate migrations between the base version and the latest models, and then migrate the database if needed:

      Doctrine_Core::generateYamlFromModels(ROOT_PATH.'tmp/yaml/', ROOT_PATH.'models/');
      $result = Doctrine_Core::generateMigrationsFromDiff(ROOT_PATH.'tmp/migrations/', ROOT_PATH.'data/yaml/', ROOT_PATH.'tmp/yaml/');
      rename(ROOT_PATH.'tmp/yaml/schema.yml', ROOT_PATH.'data/yaml/schema.yml');
      $migration = new Doctrine_Migration(ROOT_PATH.'tmp/migrations');
      $currentVersion = $migration->getCurrentVersion();
      $latestVersion = $migration->getLatestVersion();
      if ($currentVersion < $latestVersion) {
      	$this->app->addMessage("Database migration completed (from version $currentVersion to version $latestVersion)","success");
      } else {
      	$this->app->addMessage("Database is up to date and doesn't require migration (at version $currentVersion)","success");


        ppanther Adam Benson created issue -
        guilhermeblanco Guilherme Blanco made changes -
        Field Original Value New Value
        Affects Version/s 1.2.4 [ 10063 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={expand=changesets[0:20].revisions[0:29],reviews, query=DC-931}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)


          • Assignee:
            jwage Jonathan H. Wage
            ppanther Adam Benson
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: