File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
storage/framework/core/orm/src Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -158,8 +158,17 @@ export async function getPivotTables(
158158 if ( 'belongsToMany' in model ) {
159159 const belongsToManyArr = model . belongsToMany || [ ]
160160 for ( const belongsToManyRelation of belongsToManyArr ) {
161+ let modelRelation : Model
162+
161163 const modelRelationPath = path . userModelsPath ( `${ belongsToManyRelation } .ts` )
162- const modelRelation = ( await import ( modelRelationPath ) ) . default as Model
164+
165+ const coreModelRelationPath = path . storagePath ( `framework/defaults/models/${ belongsToManyRelation } .ts` )
166+
167+ if ( fs . existsSync ( modelRelationPath ) )
168+ modelRelation = ( await import ( modelRelationPath ) ) . default as Model
169+ else
170+ modelRelation = ( await import ( coreModelRelationPath ) ) . default as Model
171+
163172 const modelRelationTableName = getTableName ( modelRelation , modelRelationPath )
164173 const modelName = getModelName ( model , modelPath )
165174 const tableName = getTableName ( model , modelPath )
@@ -1051,6 +1060,7 @@ export async function generateModelFiles(modelStringFile?: string): Promise<void
10511060 log . success ( 'Wrote Table Names' )
10521061 }
10531062 catch ( error ) {
1063+ throw error
10541064 handleError ( 'Error while writing Table Names' , error )
10551065 }
10561066
@@ -1120,7 +1130,7 @@ export async function generateModelFiles(modelStringFile?: string): Promise<void
11201130 await ensureCodeStyle ( )
11211131 }
11221132 catch ( error ) {
1123- // throw error
1133+ throw error
11241134 handleError ( 'Error while generating model files' , error )
11251135 }
11261136}
You can’t perform that action at this time.
0 commit comments