Skip to content

Commit 880d0fa

Browse files
elpeteclaude
andcommitted
feat: add pretend support to runSeed
Pass pretend through MigrationService.seed() and QBMigrationManager.runSeed(). When pretend is true, the QueryBuilder is set to pretend mode so no SQL executes. The query is now passed as a second argument to postProcessHook so callers can read the query log to display what would have been run. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5ace6a3 commit 880d0fa

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

models/IMigrationManager.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ interface {
5959
*
6060
* @invocationPath the component invocation path for the seed
6161
*/
62-
public void function runSeed( required string invocationPath, function postProcessHook, function preProcessHook );
62+
public void function runSeed( required string invocationPath, function postProcessHook, function preProcessHook, boolean pretend );
6363

6464
}

models/MigrationService.cfc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ component accessors="true" {
159159
public MigrationService function seed(
160160
string seedName,
161161
function postProcessHook = variables.noop,
162-
function preProcessHook = variables.noop
162+
function preProcessHook = variables.noop,
163+
boolean pretend = false
163164
) {
164165
if (
165166
!isNull( variables.environment ) && !arrayContainsNoCase(
@@ -175,7 +176,7 @@ component accessors="true" {
175176
if ( !directoryExists( expandPath( variables.seedsDirectory ) ) ) return this;
176177

177178
findSeeds( argumentCollection = arguments ).each( function( file ) {
178-
variables.manager.runSeed( file.componentPath, postProcessHook, preProcessHook );
179+
variables.manager.runSeed( file.componentPath, postProcessHook, preProcessHook, pretend );
179180
} );
180181

181182
return this;

models/QBMigrationManager.cfc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ component accessors="true" {
178178
public void function runSeed(
179179
required string invocationPath,
180180
function postProcessHook = variables.noop,
181-
function preProcessHook = variables.noop
181+
function preProcessHook = variables.noop,
182+
boolean pretend = false
182183
) {
183184
arguments.preProcessHook( invocationPath );
184185
var seeder = wirebox.getInstance( arguments.invocationPath );
@@ -188,10 +189,14 @@ component accessors="true" {
188189
.setGrammar( wirebox.getInstance( defaultGrammar ) )
189190
.setDefaultOptions( { datasource: getDatasource() } );
190191

192+
if ( arguments.pretend ) {
193+
query.pretend();
194+
}
195+
191196
$transactioned( function() {
192197
invoke( seeder, "run", [ query, variables.mockData ] );
193198
} );
194-
arguments.postProcessHook( invocationPath );
199+
arguments.postProcessHook( invocationPath, query );
195200
}
196201

197202

0 commit comments

Comments
 (0)