rake-db 2.27.6 → 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.
package/dist/index.d.ts CHANGED
@@ -254,14 +254,14 @@ declare const tableChangeMethods: {
254
254
  columns: Columns;
255
255
  name: string extends Name ? never : Name;
256
256
  };
257
- unique<Columns_1 extends [string | TableData.Index.ColumnOrExpressionOptions<string>, ...(string | TableData.Index.ColumnOrExpressionOptions<string>)[]], Name_1 extends string>(columns: Columns_1, ...args: [options?: TableData.Index.UniqueOptionsArg | undefined] | [name?: Name_1 | undefined, options?: TableData.Index.UniqueOptionsArg | undefined]): {
257
+ unique<Columns_1 extends [string | TableData.Index.ColumnOrExpressionOptions<string>, ...(string | TableData.Index.ColumnOrExpressionOptions<string>)[]], Name_1 extends string>(columns: Columns_1, options?: TableData.Index.UniqueOptionsArg<Name_1> | undefined): {
258
258
  tableDataItem: true;
259
259
  columns: Columns_1 extends (string | TableData.Index.ColumnOptionsForColumn<string>)[] ? { [I in keyof Columns_1]: "column" extends keyof Columns_1[I] ? Columns_1[I][keyof Columns_1[I] & "column"] : Columns_1[I]; } : never;
260
260
  name: string extends Name_1 ? never : Name_1;
261
261
  };
262
- index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg | undefined] | [name?: string | undefined, options?: TableData.Index.OptionsArg | undefined]): pqb.NonUniqDataItem;
263
- searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.TsVectorArg | undefined] | [name?: string | undefined, options?: TableData.Index.TsVectorArg | undefined]): pqb.NonUniqDataItem;
264
- exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], ...args: [options?: TableData.Exclude.Options | undefined] | [name?: string | undefined, options?: TableData.Exclude.Options | undefined]): pqb.NonUniqDataItem;
262
+ index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.OptionsArg | undefined): pqb.NonUniqDataItem;
263
+ searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.TsVectorArg | undefined): pqb.NonUniqDataItem;
264
+ exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], options?: TableData.Exclude.Options | undefined): pqb.NonUniqDataItem;
265
265
  foreignKey<ForeignTable extends string | (() => orchid_core.ForeignKeyTable), ForeignColumns extends ForeignTable extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<ForeignTable>>, ...orchid_core.ColumnNameOfTable<ReturnType<ForeignTable>>[]] : [string, ...string[]]>(columns: [string, ...string[]], fnOrTable: ForeignTable, foreignColumns: ForeignColumns, options?: TableData.References.Options | undefined): pqb.NonUniqDataItem;
266
266
  check(check: RawSQLBase<orchid_core.QueryColumn<unknown, any>, unknown>, name?: string | undefined): pqb.NonUniqDataItem;
267
267
  sql: pqb.SqlFn;
@@ -771,17 +771,17 @@ declare class Migration<CT> {
771
771
  *
772
772
  * @param tableName - name of the table to add the index for
773
773
  * @param columns - indexed columns
774
- * @param args - index options, or an index name and then options
774
+ * @param args - index options
775
775
  */
776
- addIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg] | [name?: string, options?: TableData.Index.OptionsArg]): Promise<void>;
776
+ addIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions)[], ...args: [options?: TableData.Index.OptionsArg]): Promise<void>;
777
777
  /**
778
778
  * Drop the schema, create it on rollback. See {@link addIndex}.
779
779
  *
780
780
  * @param tableName - name of the table to add the index for
781
781
  * @param columns - indexed columns
782
- * @param args - index options, or an index name and then options
782
+ * @param args - index options
783
783
  */
784
- dropIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg] | [name?: string, options?: TableData.Index.OptionsArg]): Promise<void>;
784
+ dropIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions)[], ...args: [options?: TableData.Index.OptionsArg]): Promise<void>;
785
785
  /**
786
786
  * Rename index:
787
787
  *
package/dist/index.js CHANGED
@@ -420,7 +420,7 @@ const getIndexOrExcludeMainOptions = (tableName, item, getName, snakeCase) => {
420
420
  return {
421
421
  columns,
422
422
  include,
423
- name: item.name || getName(tableName, columns)
423
+ name: item.options?.name || getName(tableName, columns)
424
424
  };
425
425
  };
426
426
  const commentsToQuery = (schemaTable, comments) => {
@@ -1512,20 +1512,20 @@ class Migration {
1512
1512
  *
1513
1513
  * @param tableName - name of the table to add the index for
1514
1514
  * @param columns - indexed columns
1515
- * @param args - index options, or an index name and then options
1515
+ * @param args - index options
1516
1516
  */
1517
1517
  addIndex(tableName, columns, ...args) {
1518
- return addIndex(this, this.up, tableName, columns, args);
1518
+ return addIndex(this, this.up, tableName, columns, ...args);
1519
1519
  }
1520
1520
  /**
1521
1521
  * Drop the schema, create it on rollback. See {@link addIndex}.
1522
1522
  *
1523
1523
  * @param tableName - name of the table to add the index for
1524
1524
  * @param columns - indexed columns
1525
- * @param args - index options, or an index name and then options
1525
+ * @param args - index options
1526
1526
  */
1527
1527
  dropIndex(tableName, columns, ...args) {
1528
- return addIndex(this, !this.up, tableName, columns, args);
1528
+ return addIndex(this, !this.up, tableName, columns, ...args);
1529
1529
  }
1530
1530
  /**
1531
1531
  * Rename index:
@@ -2250,7 +2250,7 @@ const addColumn = (migration, up, tableName, columnName, fn) => {
2250
2250
  [columnName]: t.add(fn(t))
2251
2251
  }));
2252
2252
  };
2253
- const addIndex = (migration, up, tableName, columns, args) => {
2253
+ const addIndex = (migration, up, tableName, columns, ...args) => {
2254
2254
  return changeTable(migration, up, tableName, {}, (t) => ({
2255
2255
  ...t.add(t.index(columns, ...args))
2256
2256
  }));
@@ -4260,11 +4260,7 @@ const tableToAst = (ctx, data, table, action, domains) => {
4260
4260
  const indexesOrExcludesToAst = (tableName, tableData, key) => {
4261
4261
  return tableData[key].reduce((acc, item) => {
4262
4262
  if (item.columns.length > 1 || item.columns.some((it) => "expression" in it)) {
4263
- const { name, ...options } = makeIndexOrExcludeOptions(
4264
- tableName,
4265
- item,
4266
- key
4267
- );
4263
+ const options = makeIndexOrExcludeOptions(tableName, item, key);
4268
4264
  acc.push({
4269
4265
  columns: item.columns.map((it, i) => ({
4270
4266
  with: "exclude" in item && item.exclude ? item.exclude[i] : void 0,
@@ -4276,8 +4272,7 @@ const indexesOrExcludesToAst = (tableName, tableData, key) => {
4276
4272
  options: {
4277
4273
  ...options,
4278
4274
  include: item.include?.map(orchidCore.toCamelCase)
4279
- },
4280
- name
4275
+ }
4281
4276
  });
4282
4277
  }
4283
4278
  return acc;
@@ -4444,12 +4439,12 @@ const collectColumnIndexesOrExcludes = (dbColumn, column, tableName, tableData,
4444
4439
  ((_a = column.data)[key] ?? (_a[key] = [])).push({
4445
4440
  with: "exclude" in item && item.exclude ? item.exclude[0] : void 0,
4446
4441
  options: {
4442
+ name,
4447
4443
  collate: columnOptions.collate,
4448
4444
  opclass: columnOptions.opclass,
4449
4445
  order: columnOptions.order,
4450
4446
  ...itemOptions
4451
- },
4452
- name
4447
+ }
4453
4448
  });
4454
4449
  }
4455
4450
  };
@@ -4729,7 +4724,7 @@ const pushIndexOrExcludeKeys = (change, keys, schema, table, name, key) => {
4729
4724
  const getName = key === "indexes" ? getIndexName : getExcludeName;
4730
4725
  for (const x of items) {
4731
4726
  keys.push(
4732
- x.name ? `${schema}.${x.name}` : getName(table, [{ column: change.column?.data.name ?? name }])
4727
+ x.options.name ? `${schema}.${x.options.name}` : getName(table, [{ column: change.column?.data.name ?? name }])
4733
4728
  );
4734
4729
  }
4735
4730
  }
@@ -4739,7 +4734,9 @@ const pushIndexesOrExcludesKeys = (keys, schema, table, data, key) => {
4739
4734
  if (arr) {
4740
4735
  const getName = key === "indexes" ? getIndexName : getExcludeName;
4741
4736
  for (const x of arr) {
4742
- keys.push(x.name ? `${schema}.${x.name}` : getName(table, x.columns));
4737
+ keys.push(
4738
+ x.options.name ? `${schema}.${x.options.name}` : getName(table, x.columns)
4739
+ );
4743
4740
  }
4744
4741
  }
4745
4742
  };