@famgia/omnify-laravel 0.0.47 → 0.0.49

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/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  schemaToBlueprint,
23
23
  toColumnName,
24
24
  toTableName
25
- } from "./chunk-AF6XW6JU.js";
25
+ } from "./chunk-RP2B7BTK.js";
26
26
  export {
27
27
  formatColumnMethod,
28
28
  formatForeignKey,
package/dist/plugin.cjs CHANGED
@@ -106,6 +106,9 @@ function propertyToColumnMethod(propertyName, property, options = {}) {
106
106
  }
107
107
  }
108
108
  const baseProp = property;
109
+ if (baseProp.primaryKey) {
110
+ modifiers.push({ method: "primary" });
111
+ }
109
112
  if (baseProp.nullable) {
110
113
  modifiers.push({ method: "nullable" });
111
114
  }
@@ -471,10 +474,24 @@ function schemaToBlueprint(schema, allSchemas, options = {}) {
471
474
  seenIndexes.add(key);
472
475
  return true;
473
476
  });
477
+ let primaryKey;
478
+ if (hasAutoId(schema)) {
479
+ primaryKey = ["id"];
480
+ } else if (schema.properties) {
481
+ const pkColumns = [];
482
+ for (const [propName, property] of Object.entries(schema.properties)) {
483
+ if (property.primaryKey) {
484
+ pkColumns.push(toColumnName(propName));
485
+ }
486
+ }
487
+ if (pkColumns.length > 0) {
488
+ primaryKey = pkColumns;
489
+ }
490
+ }
474
491
  return {
475
492
  tableName,
476
493
  columns,
477
- primaryKey: ["id"],
494
+ primaryKey,
478
495
  foreignKeys,
479
496
  indexes: uniqueIndexes
480
497
  };