@famgia/omnify-laravel 0.0.15 → 0.0.16

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
@@ -19,7 +19,7 @@ import {
19
19
  schemaToBlueprint,
20
20
  toColumnName,
21
21
  toTableName
22
- } from "./chunk-REDFZUQY.js";
22
+ } from "./chunk-CAWNYSF3.js";
23
23
  export {
24
24
  formatColumnMethod,
25
25
  formatForeignKey,
package/dist/plugin.cjs CHANGED
@@ -238,11 +238,18 @@ function generateForeignKey(propertyName, property, allSchemas) {
238
238
  } else if (targetPkType === "String") {
239
239
  method = "string";
240
240
  }
241
+ const modifiers = [];
242
+ if (assocProp.nullable || assocProp.relation === "ManyToOne") {
243
+ modifiers.push({ method: "nullable" });
244
+ }
245
+ if (assocProp.default !== void 0 && assocProp.default !== null) {
246
+ modifiers.push({ method: "default", args: [assocProp.default] });
247
+ }
241
248
  const column = {
242
249
  name: columnName,
243
250
  method,
244
251
  args: [columnName],
245
- modifiers: assocProp.relation === "ManyToOne" ? [{ method: "nullable" }] : []
252
+ modifiers
246
253
  };
247
254
  const foreignKey = {
248
255
  columns: [columnName],