rake-db 2.3.3 → 2.3.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # rake-db
2
2
 
3
+ ## 2.3.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Change package.json exports for esm support
8
+ - Updated dependencies
9
+ - pqb@0.9.3
10
+
11
+ ## 2.3.4
12
+
13
+ ### Patch Changes
14
+
15
+ - Remove createJoinTable
16
+
3
17
  ## 2.3.3
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -73,10 +73,6 @@ declare class Migration extends TransactionAdapter {
73
73
  createTable(tableName: string, fn: ColumnsShapeCallback): Promise<void>;
74
74
  dropTable(tableName: string, options: TableOptions, fn: ColumnsShapeCallback): Promise<void>;
75
75
  dropTable(tableName: string, fn: ColumnsShapeCallback): Promise<void>;
76
- createJoinTable(tables: string[], options?: JoinTableOptions, fn?: ColumnsShapeCallback): Promise<void>;
77
- createJoinTable(tables: string[], fn?: ColumnsShapeCallback): Promise<void>;
78
- dropJoinTable(tables: string[], options?: JoinTableOptions, fn?: ColumnsShapeCallback): Promise<void>;
79
- dropJoinTable(tables: string[], fn?: ColumnsShapeCallback): Promise<void>;
80
76
  changeTable(tableName: string, options: ChangeTableOptions, fn?: ChangeTableCallback): Promise<void>;
81
77
  changeTable(tableName: string, fn: ChangeTableCallback): Promise<void>;
82
78
  renameTable(from: string, to: string): Promise<void>;
package/dist/index.js CHANGED
@@ -6,32 +6,31 @@ var pqb = require('pqb');
6
6
  var Enquirer = require('enquirer');
7
7
  var path = require('path');
8
8
  var promises = require('fs/promises');
9
- var pluralize = require('pluralize');
10
9
 
11
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
11
 
13
12
  var Enquirer__default = /*#__PURE__*/_interopDefaultLegacy(Enquirer);
14
13
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
15
14
 
16
- var __defProp$7 = Object.defineProperty;
17
- var __defProps$6 = Object.defineProperties;
18
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
19
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
20
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
21
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
22
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
23
- var __spreadValues$7 = (a, b) => {
15
+ var __defProp$6 = Object.defineProperty;
16
+ var __defProps$5 = Object.defineProperties;
17
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
18
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
19
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
20
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
21
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22
+ var __spreadValues$6 = (a, b) => {
24
23
  for (var prop in b || (b = {}))
25
- if (__hasOwnProp$7.call(b, prop))
26
- __defNormalProp$7(a, prop, b[prop]);
27
- if (__getOwnPropSymbols$7)
28
- for (var prop of __getOwnPropSymbols$7(b)) {
29
- if (__propIsEnum$7.call(b, prop))
30
- __defNormalProp$7(a, prop, b[prop]);
24
+ if (__hasOwnProp$6.call(b, prop))
25
+ __defNormalProp$6(a, prop, b[prop]);
26
+ if (__getOwnPropSymbols$6)
27
+ for (var prop of __getOwnPropSymbols$6(b)) {
28
+ if (__propIsEnum$6.call(b, prop))
29
+ __defNormalProp$6(a, prop, b[prop]);
31
30
  }
32
31
  return a;
33
32
  };
34
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
33
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
35
34
  const migrationConfigDefaults = {
36
35
  migrationsPath: path__default["default"].resolve("src", "migrations"),
37
36
  migrationsTable: "schemaMigrations",
@@ -41,7 +40,7 @@ const migrationConfigDefaults = {
41
40
  useCodeUpdater: true
42
41
  };
43
42
  const getMigrationConfigWithDefaults = (config) => {
44
- return __spreadValues$7(__spreadValues$7({}, migrationConfigDefaults), config);
43
+ return __spreadValues$6(__spreadValues$6({}, migrationConfigDefaults), config);
45
44
  };
46
45
  const getDatabaseAndUserFromOptions = (options) => {
47
46
  if (options.databaseURL) {
@@ -69,9 +68,9 @@ const setAdapterOptions = (options, set) => {
69
68
  if (set.password !== void 0) {
70
69
  url.password = set.password;
71
70
  }
72
- return __spreadProps$6(__spreadValues$7({}, options), { databaseURL: url.toString() });
71
+ return __spreadProps$5(__spreadValues$6({}, options), { databaseURL: url.toString() });
73
72
  } else {
74
- return __spreadValues$7(__spreadValues$7({}, options), set);
73
+ return __spreadValues$6(__spreadValues$6({}, options), set);
75
74
  }
76
75
  };
77
76
  const askAdminCredentials = async () => {
@@ -173,12 +172,6 @@ const getMigrationFiles = async (config, up) => {
173
172
  };
174
173
  const sortAsc = (arr) => arr.sort();
175
174
  const sortDesc = (arr) => arr.sort((a, b) => a > b ? -1 : 1);
176
- const joinWords = (...words) => {
177
- return words.slice(1).reduce(
178
- (acc, word) => acc + word[0].toUpperCase() + word.slice(1),
179
- words[0]
180
- );
181
- };
182
175
  const joinColumns = (columns) => {
183
176
  return columns.map((column) => `"${column}"`).join(", ");
184
177
  };
@@ -218,25 +211,25 @@ const setCurrentMigrationUp = (up) => {
218
211
  const getCurrentPromise = () => currentPromise;
219
212
  const getCurrentChangeCallback = () => currentChangeCallback;
220
213
 
221
- var __defProp$6 = Object.defineProperty;
222
- var __defProps$5 = Object.defineProperties;
223
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
224
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
225
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
226
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
227
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
228
- var __spreadValues$6 = (a, b) => {
214
+ var __defProp$5 = Object.defineProperty;
215
+ var __defProps$4 = Object.defineProperties;
216
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
217
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
218
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
219
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
220
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
221
+ var __spreadValues$5 = (a, b) => {
229
222
  for (var prop in b || (b = {}))
230
- if (__hasOwnProp$6.call(b, prop))
231
- __defNormalProp$6(a, prop, b[prop]);
232
- if (__getOwnPropSymbols$6)
233
- for (var prop of __getOwnPropSymbols$6(b)) {
234
- if (__propIsEnum$6.call(b, prop))
235
- __defNormalProp$6(a, prop, b[prop]);
223
+ if (__hasOwnProp$5.call(b, prop))
224
+ __defNormalProp$5(a, prop, b[prop]);
225
+ if (__getOwnPropSymbols$5)
226
+ for (var prop of __getOwnPropSymbols$5(b)) {
227
+ if (__propIsEnum$5.call(b, prop))
228
+ __defNormalProp$5(a, prop, b[prop]);
236
229
  }
237
230
  return a;
238
231
  };
239
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
232
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
240
233
  const columnToSql = (key, item, values, hasMultiplePrimaryKeys) => {
241
234
  const line = [`"${key}" ${item.toSQL()}`];
242
235
  if (item.data.compression) {
@@ -275,7 +268,7 @@ const addColumnIndex = (indexes, key, item) => {
275
268
  if (item.data.indexes) {
276
269
  indexes.push(
277
270
  ...item.data.indexes.map((index) => ({
278
- columns: [__spreadProps$5(__spreadValues$6({}, index), { column: key })],
271
+ columns: [__spreadProps$4(__spreadValues$5({}, index), { column: key })],
279
272
  options: index
280
273
  }))
281
274
  );
@@ -406,48 +399,26 @@ const primaryKeyToSql = (primaryKey) => {
406
399
  primaryKey.columns
407
400
  )})`;
408
401
  };
409
- const getPrimaryKeysOfTable = async (db, tableName) => {
410
- const { rows } = await db.query(
411
- {
412
- text: `SELECT
413
- pg_attribute.attname AS name,
414
- format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS type
415
- FROM pg_index, pg_class, pg_attribute, pg_namespace
416
- WHERE
417
- pg_class.oid = $1::regclass AND
418
- indrelid = pg_class.oid AND
419
- nspname = 'public' AND
420
- pg_class.relnamespace = pg_namespace.oid AND
421
- pg_attribute.attrelid = pg_class.oid AND
422
- pg_attribute.attnum = any(pg_index.indkey) AND
423
- indisprimary`,
424
- values: [tableName]
425
- },
426
- db.types,
427
- void 0
428
- );
429
- return rows;
430
- };
431
402
 
432
- var __defProp$5 = Object.defineProperty;
433
- var __defProps$4 = Object.defineProperties;
434
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
435
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
436
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
437
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
438
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
439
- var __spreadValues$5 = (a, b) => {
403
+ var __defProp$4 = Object.defineProperty;
404
+ var __defProps$3 = Object.defineProperties;
405
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
406
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
407
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
408
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
409
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
410
+ var __spreadValues$4 = (a, b) => {
440
411
  for (var prop in b || (b = {}))
441
- if (__hasOwnProp$5.call(b, prop))
442
- __defNormalProp$5(a, prop, b[prop]);
443
- if (__getOwnPropSymbols$5)
444
- for (var prop of __getOwnPropSymbols$5(b)) {
445
- if (__propIsEnum$5.call(b, prop))
446
- __defNormalProp$5(a, prop, b[prop]);
412
+ if (__hasOwnProp$4.call(b, prop))
413
+ __defNormalProp$4(a, prop, b[prop]);
414
+ if (__getOwnPropSymbols$4)
415
+ for (var prop of __getOwnPropSymbols$4(b)) {
416
+ if (__propIsEnum$4.call(b, prop))
417
+ __defNormalProp$4(a, prop, b[prop]);
447
418
  }
448
419
  return a;
449
420
  };
450
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
421
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
451
422
  const types = Object.assign(Object.create(pqb.columnTypes), {
452
423
  raw: pqb.raw
453
424
  });
@@ -478,14 +449,14 @@ const makeAst$1 = (up, tableName, shape, tableData, options, noPrimaryKey) => {
478
449
  }
479
450
  const primaryKey = tableData.primaryKey;
480
451
  const [schema, table] = getSchemaAndTableFromName(tableName);
481
- return __spreadProps$4(__spreadValues$5(__spreadProps$4(__spreadValues$5({
452
+ return __spreadProps$3(__spreadValues$4(__spreadProps$3(__spreadValues$4({
482
453
  type: "table",
483
454
  action: up ? "create" : "drop",
484
455
  schema,
485
456
  name: table,
486
457
  shape
487
458
  }, tableData), {
488
- primaryKey: shapePKeys.length <= 1 ? primaryKey : primaryKey ? __spreadProps$4(__spreadValues$5({}, primaryKey), { columns: [...shapePKeys, ...primaryKey.columns] }) : { columns: shapePKeys }
459
+ primaryKey: shapePKeys.length <= 1 ? primaryKey : primaryKey ? __spreadProps$3(__spreadValues$4({}, primaryKey), { columns: [...shapePKeys, ...primaryKey.columns] }) : { columns: shapePKeys }
489
460
  }), options), {
490
461
  noPrimaryKey: options.noPrimaryKey ? "ignore" : noPrimaryKey || "error"
491
462
  });
@@ -559,25 +530,25 @@ const astToQueries$1 = (ast) => {
559
530
  return result;
560
531
  };
561
532
 
562
- var __defProp$4 = Object.defineProperty;
563
- var __defProps$3 = Object.defineProperties;
564
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
565
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
566
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
567
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
568
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
569
- var __spreadValues$4 = (a, b) => {
533
+ var __defProp$3 = Object.defineProperty;
534
+ var __defProps$2 = Object.defineProperties;
535
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
536
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
537
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
538
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
539
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
540
+ var __spreadValues$3 = (a, b) => {
570
541
  for (var prop in b || (b = {}))
571
- if (__hasOwnProp$4.call(b, prop))
572
- __defNormalProp$4(a, prop, b[prop]);
573
- if (__getOwnPropSymbols$4)
574
- for (var prop of __getOwnPropSymbols$4(b)) {
575
- if (__propIsEnum$4.call(b, prop))
576
- __defNormalProp$4(a, prop, b[prop]);
542
+ if (__hasOwnProp$3.call(b, prop))
543
+ __defNormalProp$3(a, prop, b[prop]);
544
+ if (__getOwnPropSymbols$3)
545
+ for (var prop of __getOwnPropSymbols$3(b)) {
546
+ if (__propIsEnum$3.call(b, prop))
547
+ __defNormalProp$3(a, prop, b[prop]);
577
548
  }
578
549
  return a;
579
550
  };
580
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
551
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
581
552
  const newChangeTableData = () => ({
582
553
  add: { indexes: [], foreignKeys: [] },
583
554
  drop: { indexes: [], foreignKeys: [] }
@@ -593,7 +564,7 @@ const mergeTableData = (a, b) => {
593
564
  } else {
594
565
  a.primaryKey = {
595
566
  columns: [...a.primaryKey.columns, ...b.primaryKey.columns],
596
- options: __spreadValues$4(__spreadValues$4({}, a.primaryKey.options), b.primaryKey.options)
567
+ options: __spreadValues$3(__spreadValues$3({}, a.primaryKey.options), b.primaryKey.options)
597
568
  };
598
569
  }
599
570
  }
@@ -644,7 +615,7 @@ const columnTypeToColumnChange = (item) => {
644
615
  if (foreignKeys == null ? void 0 : foreignKeys.some((it) => "fn" in it)) {
645
616
  throw new Error("Callback in foreignKey is not allowed in migration");
646
617
  }
647
- return __spreadProps$3(__spreadValues$4({
618
+ return __spreadProps$2(__spreadValues$3({
648
619
  column: item,
649
620
  type: item.toSQL(),
650
621
  nullable: item.data.isNullable,
@@ -660,7 +631,7 @@ const tableChangeMethods = {
660
631
  add,
661
632
  drop,
662
633
  change(from, to, options) {
663
- return __spreadValues$4({
634
+ return __spreadValues$3({
664
635
  type: "change",
665
636
  from: columnTypeToColumnChange(from),
666
637
  to: columnTypeToColumnChange(to)
@@ -710,18 +681,18 @@ const makeAst = (up, name, changeData, changeTableData2, options) => {
710
681
  const item = changeData[key];
711
682
  if ("type" in item) {
712
683
  if (up) {
713
- shape[key] = item.type === "change" && item.usingUp ? __spreadProps$3(__spreadValues$4({}, item), { using: item.usingUp }) : item;
684
+ shape[key] = item.type === "change" && item.usingUp ? __spreadProps$2(__spreadValues$3({}, item), { using: item.usingUp }) : item;
714
685
  } else {
715
686
  if (item.type === "rename") {
716
- shape[item.name] = __spreadProps$3(__spreadValues$4({}, item), { name: key });
687
+ shape[item.name] = __spreadProps$2(__spreadValues$3({}, item), { name: key });
717
688
  } else {
718
- shape[key] = item.type === "add" ? __spreadProps$3(__spreadValues$4({}, item), { type: "drop" }) : item.type === "drop" ? __spreadProps$3(__spreadValues$4({}, item), { type: "add" }) : item.type === "change" ? __spreadProps$3(__spreadValues$4({}, item), { from: item.to, to: item.from, using: item.usingDown }) : item;
689
+ shape[key] = item.type === "add" ? __spreadProps$2(__spreadValues$3({}, item), { type: "drop" }) : item.type === "drop" ? __spreadProps$2(__spreadValues$3({}, item), { type: "add" }) : item.type === "change" ? __spreadProps$2(__spreadValues$3({}, item), { from: item.to, to: item.from, using: item.usingDown }) : item;
719
690
  }
720
691
  }
721
692
  }
722
693
  }
723
694
  const [schema, table] = getSchemaAndTableFromName(name);
724
- return __spreadValues$4({
695
+ return __spreadValues$3({
725
696
  type: "changeTable",
726
697
  schema,
727
698
  name: table,
@@ -738,10 +709,10 @@ const astToQueries = (ast) => {
738
709
  values: []
739
710
  });
740
711
  }
741
- const addPrimaryKeys = ast.add.primaryKey ? __spreadValues$4({}, ast.add.primaryKey) : {
712
+ const addPrimaryKeys = ast.add.primaryKey ? __spreadValues$3({}, ast.add.primaryKey) : {
742
713
  columns: []
743
714
  };
744
- const dropPrimaryKeys = ast.drop.primaryKey ? __spreadValues$4({}, ast.drop.primaryKey) : {
715
+ const dropPrimaryKeys = ast.drop.primaryKey ? __spreadValues$3({}, ast.drop.primaryKey) : {
745
716
  columns: []
746
717
  };
747
718
  for (const key in ast.shape) {
@@ -849,7 +820,7 @@ const astToQueries = (ast) => {
849
820
  if (fromIndex) {
850
821
  dropIndexes.push({
851
822
  columns: [
852
- __spreadValues$4({
823
+ __spreadValues$3({
853
824
  column: key
854
825
  }, fromIndex)
855
826
  ],
@@ -859,7 +830,7 @@ const astToQueries = (ast) => {
859
830
  if (toIndex) {
860
831
  addIndexes.push({
861
832
  columns: [
862
- __spreadValues$4({
833
+ __spreadValues$3({
863
834
  column: key
864
835
  }, toIndex)
865
836
  ],
@@ -909,98 +880,6 @@ const astToQueries = (ast) => {
909
880
  return result;
910
881
  };
911
882
 
912
- var __defProp$3 = Object.defineProperty;
913
- var __defProps$2 = Object.defineProperties;
914
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
915
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
916
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
917
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
918
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
919
- var __spreadValues$3 = (a, b) => {
920
- for (var prop in b || (b = {}))
921
- if (__hasOwnProp$3.call(b, prop))
922
- __defNormalProp$3(a, prop, b[prop]);
923
- if (__getOwnPropSymbols$3)
924
- for (var prop of __getOwnPropSymbols$3(b)) {
925
- if (__propIsEnum$3.call(b, prop))
926
- __defNormalProp$3(a, prop, b[prop]);
927
- }
928
- return a;
929
- };
930
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
931
- class UnknownColumn extends pqb.ColumnType {
932
- constructor(dataType) {
933
- super();
934
- this.dataType = dataType;
935
- this.operators = pqb.Operators.any;
936
- }
937
- toCode() {
938
- return "unknown";
939
- }
940
- }
941
- const createJoinTable = async (migration, up, tables, options, fn) => {
942
- const tableName = options.tableName || joinWords(...tables);
943
- if (!up) {
944
- return createTable$1(
945
- migration,
946
- up,
947
- tableName,
948
- __spreadProps$2(__spreadValues$3({}, options), { noPrimaryKey: true }),
949
- () => ({})
950
- );
951
- }
952
- const tablesWithPrimaryKeys = await Promise.all(
953
- tables.map(async (table) => {
954
- const primaryKeys = await getPrimaryKeysOfTable(migration, table).then(
955
- (items) => items.map((item) => __spreadProps$2(__spreadValues$3({}, item), {
956
- joinedName: joinWords(pluralize.singular(table), item.name)
957
- }))
958
- );
959
- const [schema, name] = getSchemaAndTableFromName(table);
960
- if (!primaryKeys.length) {
961
- throw new Error(
962
- `Primary key for table ${quoteWithSchema({
963
- schema,
964
- name
965
- })} is not defined`
966
- );
967
- }
968
- return [schema, table, primaryKeys];
969
- })
970
- );
971
- return createTable$1(migration, up, tableName, options, (t) => {
972
- const result = {};
973
- tablesWithPrimaryKeys.forEach(([schema, table, primaryKeys]) => {
974
- if (primaryKeys.length === 1) {
975
- const [{ type, joinedName, name }] = primaryKeys;
976
- const column = new UnknownColumn(type);
977
- result[joinedName] = column.foreignKey(
978
- schema ? `${schema}.${table}` : table,
979
- name
980
- );
981
- return;
982
- }
983
- primaryKeys.forEach(({ joinedName, type }) => {
984
- result[joinedName] = new UnknownColumn(type);
985
- });
986
- t.foreignKey(
987
- primaryKeys.map((key) => key.joinedName),
988
- table,
989
- primaryKeys.map((key) => key.name)
990
- );
991
- });
992
- if (fn) {
993
- Object.assign(result, fn(t));
994
- }
995
- t.primaryKey(
996
- tablesWithPrimaryKeys.flatMap(
997
- ([, , primaryKeys]) => primaryKeys.map((item) => item.joinedName)
998
- )
999
- );
1000
- return result;
1001
- });
1002
- };
1003
-
1004
883
  var __defProp$2 = Object.defineProperty;
1005
884
  var __defProps$1 = Object.defineProperties;
1006
885
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
@@ -1045,16 +924,6 @@ class Migration extends pqb.TransactionAdapter {
1045
924
  const fn = cb || cbOrOptions;
1046
925
  return createTable$1(this, !this.up, tableName, options, fn);
1047
926
  }
1048
- async createJoinTable(tables, cbOrOptions, cb) {
1049
- const options = typeof cbOrOptions === "function" ? {} : cbOrOptions || {};
1050
- const fn = cb || cbOrOptions;
1051
- return createJoinTable(this, this.up, tables, options, fn);
1052
- }
1053
- async dropJoinTable(tables, cbOrOptions, cb) {
1054
- const options = typeof cbOrOptions === "function" ? {} : cbOrOptions || {};
1055
- const fn = cb || cbOrOptions;
1056
- return createJoinTable(this, !this.up, tables, options, fn);
1057
- }
1058
927
  changeTable(tableName, cbOrOptions, cb) {
1059
928
  const [fn, options] = typeof cbOrOptions === "function" ? [cbOrOptions, {}] : [cb, cbOrOptions];
1060
929
  return changeTable(this, this.up, tableName, options, fn);