[DC-931] Newly generated Migration Classes failing to load due to method used to determine class name Created: 19/Nov/10 Updated: 17/Apr/14
|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|
|Reporter:||Adam Benson||Assignee:||Jonathan H. Wage|
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: