@@ -29,7 +29,7 @@ component accessors="true" {
29
29
return ;
30
30
}
31
31
32
- var schema = wirebox . getInstance ( " SchemaBuilder@qb " ). setGrammar ( wirebox . getInstance ( defaultGrammar ) );
32
+ var schema = newSchemaBuilder ( );
33
33
34
34
schema .create (
35
35
getMigrationsTable (),
@@ -56,7 +56,7 @@ component accessors="true" {
56
56
* Resets the database to an empty state
57
57
*/
58
58
public void function reset () {
59
- var schema = wirebox . getInstance ( " SchemaBuilder@qb " ). setGrammar ( wirebox . getInstance ( defaultGrammar ) );
59
+ var schema = newSchemaBuilder ( );
60
60
schema .dropAllObjects ( options = { datasource : getDatasource () }, schema = getSchema () );
61
61
}
62
62
@@ -138,10 +138,7 @@ component accessors="true" {
138
138
139
139
var migration = wirebox .getInstance ( migrationStruct .componentPath );
140
140
141
- var schema = wirebox
142
- .getInstance ( " SchemaBuilder@qb" )
143
- .setGrammar ( wirebox .getInstance ( defaultGrammar ) )
144
- .setDefaultOptions ( { datasource : getDatasource () } )
141
+ var schema = newSchemaBuilder ();
145
142
146
143
var query = wirebox
147
144
.getInstance ( " QueryBuilder@qb" )
@@ -169,8 +166,7 @@ component accessors="true" {
169
166
* Determines whether the migration table is installed
170
167
*/
171
168
public boolean function isMigrationTableInstalled () {
172
- var schema = wirebox .getInstance ( " SchemaBuilder@qb" ).setGrammar ( wirebox .getInstance ( defaultGrammar ) );
173
-
169
+ var schema = newSchemaBuilder ();
174
170
return schema .hasTable ( getMigrationsTable (), getSchema (), { datasource : getDatasource () } );
175
171
}
176
172
@@ -223,4 +219,12 @@ component accessors="true" {
223
219
return ; // intentionally does nothing
224
220
}
225
221
222
+ private SchemaBuilder function newSchemaBuilder () {
223
+ return variables .wirebox
224
+ .getInstance ( " SchemaBuilder@qb" )
225
+ .setGrammar ( variables .wirebox .getInstance ( getDefaultGrammar () ) )
226
+ .setDefaultSchema ( getSchema () )
227
+ .setDefaultOptions ( { datasource : getDatasource () } );
228
+ }
229
+
226
230
}
0 commit comments