@@ -9,22 +9,22 @@ import * as Migrations from './Migrations';
99
1010export class DefinedSchemas {
1111 config : ParseServerOptions ;
12- migrationsOptions : Migrations . MigrationsOptions ;
12+ schemaOptions : Migrations . SchemaOptions ;
1313 localSchemas: Migrations . JSONSchema [ ] ;
1414 retries: number ;
1515 maxRetries: number ;
1616
17- constructor ( migrationsOptions : Migrations . MigrationsOptions , config : ParseServerOptions ) {
17+ constructor ( schemaOptions : Migrations . SchemaOptions , config : ParseServerOptions ) {
1818 this . localSchemas = [ ] ;
1919 this . config = Config . get ( config . appId ) ;
20- this . migrationsOptions = migrationsOptions ;
20+ this . schemaOptions = schemaOptions ;
2121
22- if ( migrationsOptions && migrationsOptions . definitions ) {
23- if ( ! Array . isArray ( migrationsOptions . definitions ) ) {
22+ if ( schemaOptions && schemaOptions . definitions ) {
23+ if ( ! Array . isArray ( schemaOptions . definitions ) ) {
2424 throw `"schema.definitions" must be an array of schemas` ;
2525 }
2626
27- this . localSchemas = migrationsOptions . definitions ;
27+ this . localSchemas = schemaOptions . definitions ;
2828 }
2929
3030 this . retries = 0 ;
@@ -66,14 +66,14 @@ export class DefinedSchemas {
6666 async execute ( ) {
6767 try {
6868 logger . info ( 'Running Migrations' ) ;
69- if ( this . migrationsOptions && this . migrationsOptions . beforeMigration ) {
70- await Promise . resolve ( this . migrationsOptions . beforeMigration ( ) ) ;
69+ if ( this . schemaOptions && this . schemaOptions . beforeMigration ) {
70+ await Promise . resolve ( this . schemaOptions . beforeMigration ( ) ) ;
7171 }
7272
7373 await this . executeMigrations ( ) ;
7474
75- if ( this . migrationsOptions && this . migrationsOptions . afterMigration ) {
76- await Promise . resolve ( this . migrationsOptions . afterMigration ( ) ) ;
75+ if ( this . schemaOptions && this . schemaOptions . afterMigration ) {
76+ await Promise . resolve ( this . schemaOptions . afterMigration ( ) ) ;
7777 }
7878
7979 logger . info ( 'Running Migrations Completed' ) ;
@@ -122,7 +122,7 @@ export class DefinedSchemas {
122122 }
123123
124124 checkForMissingSchemas ( ) {
125- if ( this . migrationsOptions . strict !== true ) {
125+ if ( this . schemaOptions . strict !== true ) {
126126 return ;
127127 }
128128
@@ -141,7 +141,7 @@ export class DefinedSchemas {
141141 process . exit ( 1 ) ;
142142 }
143143
144- if ( this . migrationsOptions . strict && missingSchemas . length ) {
144+ if ( this . schemaOptions . strict && missingSchemas . length ) {
145145 logger . warn (
146146 `The following schemas are currently present in the database, but not explicitly defined in a schema: "${ missingSchemas . join (
147147 '", "'
@@ -273,22 +273,22 @@ export class DefinedSchemas {
273273 }
274274 } ) ;
275275
276- if ( this . migrationsOptions . deleteExtraFields === true ) {
276+ if ( this . schemaOptions . deleteExtraFields === true ) {
277277 fieldsToDelete . forEach ( fieldName => {
278278 newLocalSchema . deleteField ( fieldName ) ;
279279 } ) ;
280280
281281 // Delete fields from the schema then apply changes
282282 await this . updateSchemaToDB ( newLocalSchema ) ;
283- } else if ( this . migrationsOptions . strict === true && fieldsToDelete . length ) {
283+ } else if ( this . schemaOptions . strict === true && fieldsToDelete . length ) {
284284 logger . warn (
285285 `The following fields exist in the database for "${
286286 localSchema . className
287287 } ", but are missing in the schema : "${ fieldsToDelete . join ( '" ,"' ) } "`
288288 ) ;
289289 }
290290
291- if ( this . migrationsOptions . recreateModifiedFields === true ) {
291+ if ( this . schemaOptions . recreateModifiedFields === true ) {
292292 fieldsToRecreate . forEach ( field => {
293293 newLocalSchema . deleteField ( field . fieldName ) ;
294294 } ) ;
@@ -300,7 +300,7 @@ export class DefinedSchemas {
300300 const field = localSchema . fields [ fieldInfo . fieldName ] ;
301301 this . handleFields ( newLocalSchema , fieldInfo . fieldName , field ) ;
302302 } ) ;
303- } else if ( this . migrationsOptions . strict === true && fieldsToRecreate . length ) {
303+ } else if ( this . schemaOptions . strict === true && fieldsToRecreate . length ) {
304304 fieldsToRecreate . forEach ( field => {
305305 const from =
306306 field . from . type + ( field . from . targetClass ? ` (${ field . from . targetClass } )` : '' ) ;
0 commit comments