Running migrationService.hasMigrationsToRun( "up" ) to check for migrations to run causes cfmigrations to run a SQL query for every migration cfc in the migrations directory. So if you have a large app with hundreds or thousands of migrations, cfmigrations will run SELECT name from cfmigrations hundreds or thousands of times!
To fix this, we should cache the query results in the variables scope:
https://github.com/coldbox-modules/cfmigrations/blob/v2.0.10/models/MigrationService.cfc#L311-L318
var migrations = queryExecute(
"
SELECT name
FROM #getMigrationsTable()#
",
{},
{ datasource : getDatasource() }
);
Running
migrationService.hasMigrationsToRun( "up" )to check for migrations to run causes cfmigrations to run a SQL query for every migration cfc in the migrations directory. So if you have a large app with hundreds or thousands of migrations,cfmigrationswill runSELECT name from cfmigrationshundreds or thousands of times!To fix this, we should cache the query results in the
variablesscope:https://github.com/coldbox-modules/cfmigrations/blob/v2.0.10/models/MigrationService.cfc#L311-L318