File tree 1 file changed +12
-2
lines changed
storage/framework/core/orm/src
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(
158
158
if ( 'belongsToMany' in model ) {
159
159
const belongsToManyArr = model . belongsToMany || [ ]
160
160
for ( const belongsToManyRelation of belongsToManyArr ) {
161
+ let modelRelation : Model
162
+
161
163
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
+
163
172
const modelRelationTableName = getTableName ( modelRelation , modelRelationPath )
164
173
const modelName = getModelName ( model , modelPath )
165
174
const tableName = getTableName ( model , modelPath )
@@ -1051,6 +1060,7 @@ export async function generateModelFiles(modelStringFile?: string): Promise<void
1051
1060
log . success ( 'Wrote Table Names' )
1052
1061
}
1053
1062
catch ( error ) {
1063
+ throw error
1054
1064
handleError ( 'Error while writing Table Names' , error )
1055
1065
}
1056
1066
@@ -1120,7 +1130,7 @@ export async function generateModelFiles(modelStringFile?: string): Promise<void
1120
1130
await ensureCodeStyle ( )
1121
1131
}
1122
1132
catch ( error ) {
1123
- // throw error
1133
+ throw error
1124
1134
handleError ( 'Error while generating model files' , error )
1125
1135
}
1126
1136
}
You can’t perform that action at this time.
0 commit comments