rake-db 2.4.17 → 2.4.19

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
@@ -2462,17 +2462,27 @@ const pushTableAst = (ctx, ast, data, domains, table, pendingTables, innerFKeys
2462
2462
  }
2463
2463
  }
2464
2464
  };
2465
- const foreignKeyToAst = (fkey) => ({
2466
- columns: fkey.columnNames,
2467
- fnOrTable: fkey.foreignTableName,
2468
- foreignColumns: fkey.foreignColumnNames,
2469
- options: {
2470
- name: fkey.name && fkey.name !== getForeignKeyName(fkey.tableName, fkey.columnNames) ? fkey.name : void 0,
2471
- match: matchMap[fkey.match],
2472
- onUpdate: fkeyActionMap[fkey.onUpdate],
2473
- onDelete: fkeyActionMap[fkey.onDelete]
2474
- }
2475
- });
2465
+ const foreignKeyToAst = (fkey) => {
2466
+ const result = {
2467
+ columns: fkey.columnNames,
2468
+ fnOrTable: fkey.foreignTableName,
2469
+ foreignColumns: fkey.foreignColumnNames,
2470
+ options: {}
2471
+ };
2472
+ if (fkey.name && fkey.name !== getForeignKeyName(fkey.tableName, fkey.columnNames)) {
2473
+ result.options.name = fkey.name;
2474
+ }
2475
+ const match = matchMap[fkey.match];
2476
+ if (match)
2477
+ result.options.match = match;
2478
+ const onUpdate = fkeyActionMap[fkey.onUpdate];
2479
+ if (onUpdate)
2480
+ result.options.onUpdate = onUpdate;
2481
+ const onDelete = fkeyActionMap[fkey.onDelete];
2482
+ if (onDelete)
2483
+ result.options.onDelete = onDelete;
2484
+ return result;
2485
+ };
2476
2486
 
2477
2487
  const astToMigration = (config, ast) => {
2478
2488
  const first = [];