rake-db 2.27.5 → 2.27.7

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.
@@ -505,7 +505,7 @@ const getIndexOrExcludeMainOptions = (tableName, item, getName, snakeCase) => {
505
505
  return {
506
506
  columns,
507
507
  include,
508
- name: item.name || getName(tableName, columns)
508
+ name: item.options?.name || getName(tableName, columns)
509
509
  };
510
510
  };
511
511
  const commentsToQuery = (schemaTable, comments) => {
@@ -1592,20 +1592,20 @@ class Migration {
1592
1592
  *
1593
1593
  * @param tableName - name of the table to add the index for
1594
1594
  * @param columns - indexed columns
1595
- * @param args - index options, or an index name and then options
1595
+ * @param args - index options
1596
1596
  */
1597
1597
  addIndex(tableName, columns, ...args) {
1598
- return addIndex(this, this.up, tableName, columns, args);
1598
+ return addIndex(this, this.up, tableName, columns, ...args);
1599
1599
  }
1600
1600
  /**
1601
1601
  * Drop the schema, create it on rollback. See {@link addIndex}.
1602
1602
  *
1603
1603
  * @param tableName - name of the table to add the index for
1604
1604
  * @param columns - indexed columns
1605
- * @param args - index options, or an index name and then options
1605
+ * @param args - index options
1606
1606
  */
1607
1607
  dropIndex(tableName, columns, ...args) {
1608
- return addIndex(this, !this.up, tableName, columns, args);
1608
+ return addIndex(this, !this.up, tableName, columns, ...args);
1609
1609
  }
1610
1610
  /**
1611
1611
  * Rename index:
@@ -2330,7 +2330,7 @@ const addColumn = (migration, up, tableName, columnName, fn) => {
2330
2330
  [columnName]: t.add(fn(t))
2331
2331
  }));
2332
2332
  };
2333
- const addIndex = (migration, up, tableName, columns, args) => {
2333
+ const addIndex = (migration, up, tableName, columns, ...args) => {
2334
2334
  return changeTable(migration, up, tableName, {}, (t) => ({
2335
2335
  ...t.add(t.index(columns, ...args))
2336
2336
  }));
@@ -4340,11 +4340,7 @@ const tableToAst = (ctx, data, table, action, domains) => {
4340
4340
  const indexesOrExcludesToAst = (tableName, tableData, key) => {
4341
4341
  return tableData[key].reduce((acc, item) => {
4342
4342
  if (item.columns.length > 1 || item.columns.some((it) => "expression" in it)) {
4343
- const { name, ...options } = makeIndexOrExcludeOptions(
4344
- tableName,
4345
- item,
4346
- key
4347
- );
4343
+ const options = makeIndexOrExcludeOptions(tableName, item, key);
4348
4344
  acc.push({
4349
4345
  columns: item.columns.map((it, i) => ({
4350
4346
  with: "exclude" in item && item.exclude ? item.exclude[i] : void 0,
@@ -4356,8 +4352,7 @@ const indexesOrExcludesToAst = (tableName, tableData, key) => {
4356
4352
  options: {
4357
4353
  ...options,
4358
4354
  include: item.include?.map(toCamelCase)
4359
- },
4360
- name
4355
+ }
4361
4356
  });
4362
4357
  }
4363
4358
  return acc;
@@ -4524,12 +4519,12 @@ const collectColumnIndexesOrExcludes = (dbColumn, column, tableName, tableData,
4524
4519
  ((_a = column.data)[key] ?? (_a[key] = [])).push({
4525
4520
  with: "exclude" in item && item.exclude ? item.exclude[0] : void 0,
4526
4521
  options: {
4522
+ name,
4527
4523
  collate: columnOptions.collate,
4528
4524
  opclass: columnOptions.opclass,
4529
4525
  order: columnOptions.order,
4530
4526
  ...itemOptions
4531
- },
4532
- name
4527
+ }
4533
4528
  });
4534
4529
  }
4535
4530
  };
@@ -4809,7 +4804,7 @@ const pushIndexOrExcludeKeys = (change, keys, schema, table, name, key) => {
4809
4804
  const getName = key === "indexes" ? getIndexName : getExcludeName;
4810
4805
  for (const x of items) {
4811
4806
  keys.push(
4812
- x.name ? `${schema}.${x.name}` : getName(table, [{ column: change.column?.data.name ?? name }])
4807
+ x.options.name ? `${schema}.${x.options.name}` : getName(table, [{ column: change.column?.data.name ?? name }])
4813
4808
  );
4814
4809
  }
4815
4810
  }
@@ -4819,7 +4814,9 @@ const pushIndexesOrExcludesKeys = (keys, schema, table, data, key) => {
4819
4814
  if (arr) {
4820
4815
  const getName = key === "indexes" ? getIndexName : getExcludeName;
4821
4816
  for (const x of arr) {
4822
- keys.push(x.name ? `${schema}.${x.name}` : getName(table, x.columns));
4817
+ keys.push(
4818
+ x.options.name ? `${schema}.${x.options.name}` : getName(table, x.columns)
4819
+ );
4823
4820
  }
4824
4821
  }
4825
4822
  };