@famgia/omnify-laravel 2.0.35 → 2.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BN5HLOML.js → chunk-RWNQFZZS.js} +21 -6
- package/dist/chunk-RWNQFZZS.js.map +1 -0
- package/dist/index.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +20 -5
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-BN5HLOML.js.map +0 -1
|
@@ -288,6 +288,11 @@ function generateForeignKey(propertyName, property, allSchemas, options = {}) {
|
|
|
288
288
|
const columnName = toColumnName(propertyName) + "_id";
|
|
289
289
|
const targetSchema = assocProp.target ? allSchemas[assocProp.target] : void 0;
|
|
290
290
|
const targetTable = assocProp.target ? toTableName(assocProp.target) : "unknown";
|
|
291
|
+
if (assocProp.target && !targetSchema && !assocProp.targetNamespace && !assocProp.idType) {
|
|
292
|
+
throw new Error(
|
|
293
|
+
`Association "${propertyName}" references target "${assocProp.target}" which was not found in loaded schemas. Available schemas: [${Object.keys(allSchemas).join(", ")}]. If this is an external package reference, add "targetNamespace" and "idType" to the association.`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
291
296
|
const targetPkType = assocProp.idType ?? (targetSchema ? getIdType(targetSchema) : "BigInt");
|
|
292
297
|
let method = "unsignedBigInteger";
|
|
293
298
|
if (targetPkType === "Int") {
|
|
@@ -444,8 +449,13 @@ function schemaToBlueprint(schema, allSchemas, options = {}) {
|
|
|
444
449
|
for (const targetSchemaName of pivotFor) {
|
|
445
450
|
const targetSchema = allSchemas[targetSchemaName];
|
|
446
451
|
const fkColumnName = `${toColumnName(targetSchemaName)}_id`;
|
|
452
|
+
if (!targetSchema) {
|
|
453
|
+
throw new Error(
|
|
454
|
+
`Pivot schema "${schema.name}" references target "${targetSchemaName}" in pivotFor which was not found in loaded schemas. Available schemas: [${Object.keys(allSchemas).join(", ")}]. Make sure the target schema is defined and loaded.`
|
|
455
|
+
);
|
|
456
|
+
}
|
|
447
457
|
if (!explicitColumnNames.has(fkColumnName)) {
|
|
448
|
-
const targetIdType = targetSchema
|
|
458
|
+
const targetIdType = targetSchema.options?.idType ?? "BigInt";
|
|
449
459
|
const columnType = targetIdType === "Uuid" ? "uuid" : targetIdType === "String" ? "string" : "unsignedBigInteger";
|
|
450
460
|
columns.push({
|
|
451
461
|
name: fkColumnName,
|
|
@@ -690,7 +700,12 @@ function extractManyToManyRelations(schema, allSchemas) {
|
|
|
690
700
|
}
|
|
691
701
|
const targetSchema = allSchemas[targetName];
|
|
692
702
|
const targetTable = toTableName(targetName);
|
|
693
|
-
|
|
703
|
+
if (!targetSchema && !assocProp.targetNamespace && !assocProp.idType) {
|
|
704
|
+
throw new Error(
|
|
705
|
+
`ManyToMany association in "${schema.name}" references target "${targetName}" which was not found in loaded schemas. Available schemas: [${Object.keys(allSchemas).join(", ")}]. If this is an external package reference, add "targetNamespace" and "idType" to the association.`
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
const targetPkType = assocProp.idType ?? (targetSchema ? getIdType(targetSchema) : "BigInt");
|
|
694
709
|
let isOwningSide;
|
|
695
710
|
if (assocProp.owning !== void 0) {
|
|
696
711
|
isOwningSide = assocProp.owning;
|
|
@@ -5400,10 +5415,10 @@ function laravelPlugin(options) {
|
|
|
5400
5415
|
ctx.changes.filter((c) => c.changeType === "added").map((c) => c.schemaName)
|
|
5401
5416
|
);
|
|
5402
5417
|
if (addedSchemaNames.size > 0) {
|
|
5403
|
-
const
|
|
5404
|
-
|
|
5418
|
+
const allMigrations = generateMigrations(ctx.schemas, migrationOptions);
|
|
5419
|
+
const createMigrations = allMigrations.filter(
|
|
5420
|
+
(m) => m.schemaName && addedSchemaNames.has(m.schemaName)
|
|
5405
5421
|
);
|
|
5406
|
-
const createMigrations = generateMigrations(addedSchemas, migrationOptions);
|
|
5407
5422
|
for (const migration of createMigrations) {
|
|
5408
5423
|
const tableName = migration.tables[0];
|
|
5409
5424
|
if (hasMigration(tableName, migration.schemaName)) {
|
|
@@ -5675,4 +5690,4 @@ export {
|
|
|
5675
5690
|
getFactoryPath,
|
|
5676
5691
|
laravelPlugin
|
|
5677
5692
|
};
|
|
5678
|
-
//# sourceMappingURL=chunk-
|
|
5693
|
+
//# sourceMappingURL=chunk-RWNQFZZS.js.map
|