Skip to content

Commit 06f622b

Browse files
committed
feat(MigrationService): Add support for pretend
1 parent 7100fca commit 06f622b

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

models/MigrationService.cfc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ component accessors="true" {
193193
public struct function runNextMigration(
194194
required string direction,
195195
function postProcessHook = variables.noop,
196-
function preProcessHook = variables.noop
196+
function preProcessHook = variables.noop,
197+
boolean pretend = false
197198
) {
198199
install();
199200

@@ -206,7 +207,8 @@ component accessors="true" {
206207
arguments.direction,
207208
migration,
208209
postProcessHook,
209-
preProcessHook
210+
preProcessHook,
211+
arguments.pretend
210212
);
211213
return migration;
212214
}
@@ -227,7 +229,8 @@ component accessors="true" {
227229
public void function runAllMigrations(
228230
required string direction,
229231
function postProcessHook = variables.noop,
230-
function preProcessHook = variables.noop
232+
function preProcessHook = variables.noop,
233+
boolean pretend = false
231234
) {
232235
install();
233236

@@ -248,7 +251,8 @@ component accessors="true" {
248251
direction,
249252
migration,
250253
postProcessHook,
251-
preProcessHook
254+
preProcessHook,
255+
pretend
252256
);
253257
} );
254258
}
@@ -402,7 +406,8 @@ component accessors="true" {
402406
required string direction,
403407
required struct migrationStruct,
404408
function postProcessHook = variables.noop,
405-
function preProcessHook = variables.noop
409+
function preProcessHook = variables.noop,
410+
boolean pretend = false
406411
) {
407412
install();
408413

models/QBMigrationManager.cfc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ component accessors="true" {
121121
required string direction,
122122
required struct migrationStruct,
123123
function postProcessHook = variables.noop,
124-
function preProcessHook = variables.noop
124+
function preProcessHook = variables.noop,
125+
boolean pretend = false
125126
) {
126127
install();
127128

@@ -140,21 +141,28 @@ component accessors="true" {
140141
var schema = wirebox
141142
.getInstance( "SchemaBuilder@qb" )
142143
.setGrammar( wirebox.getInstance( defaultGrammar ) )
143-
.setDefaultOptions( { datasource: getDatasource() } );
144+
.setDefaultOptions( { datasource: getDatasource() } )
144145

145146
var query = wirebox
146147
.getInstance( "QueryBuilder@qb" )
147148
.setGrammar( wirebox.getInstance( defaultGrammar ) )
148-
.setDefaultOptions( { datasource: getDatasource() } );
149+
.setDefaultOptions( { datasource: getDatasource() } )
150+
151+
if ( arguments.pretend ) {
152+
schema.pretend();
153+
query.pretend();
154+
}
149155

150156
preProcessHook( migrationStruct );
151157

152158
$transactioned( function() {
153159
invoke( migration, direction, [ schema, query ] );
154-
logMigration( direction, migrationStruct.componentName );
160+
if ( !pretend ) {
161+
logMigration( direction, migrationStruct.componentName );
162+
}
155163
} );
156164

157-
postProcessHook( migrationStruct );
165+
postProcessHook( migrationStruct, schema, query );
158166
}
159167

160168
/**

0 commit comments

Comments
 (0)