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.
@@ -255,14 +255,14 @@ declare const tableChangeMethods: {
255
255
  columns: Columns;
256
256
  name: string extends Name ? never : Name;
257
257
  };
258
- 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]): {
258
+ 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): {
259
259
  tableDataItem: true;
260
260
  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;
261
261
  name: string extends Name_1 ? never : Name_1;
262
262
  };
263
- index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg | undefined] | [name?: string | undefined, options?: TableData.Index.OptionsArg | undefined]): pqb.NonUniqDataItem;
264
- searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.TsVectorArg | undefined] | [name?: string | undefined, options?: TableData.Index.TsVectorArg | undefined]): pqb.NonUniqDataItem;
265
- exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], ...args: [options?: TableData.Exclude.Options | undefined] | [name?: string | undefined, options?: TableData.Exclude.Options | undefined]): pqb.NonUniqDataItem;
263
+ index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.OptionsArg | undefined): pqb.NonUniqDataItem;
264
+ searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], options?: TableData.Index.TsVectorArg | undefined): pqb.NonUniqDataItem;
265
+ exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<string>[], options?: TableData.Exclude.Options | undefined): pqb.NonUniqDataItem;
266
266
  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;
267
267
  check(check: RawSQLBase<orchid_core.QueryColumn<unknown, any>, unknown>, name?: string | undefined): pqb.NonUniqDataItem;
268
268
  sql: pqb.SqlFn;
@@ -742,17 +742,17 @@ declare class Migration<CT> {
742
742
  *
743
743
  * @param tableName - name of the table to add the index for
744
744
  * @param columns - indexed columns
745
- * @param args - index options, or an index name and then options
745
+ * @param args - index options
746
746
  */
747
- addIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg] | [name?: string, options?: TableData.Index.OptionsArg]): Promise<void>;
747
+ addIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions)[], ...args: [options?: TableData.Index.OptionsArg]): Promise<void>;
748
748
  /**
749
749
  * Drop the schema, create it on rollback. See {@link addIndex}.
750
750
  *
751
751
  * @param tableName - name of the table to add the index for
752
752
  * @param columns - indexed columns
753
- * @param args - index options, or an index name and then options
753
+ * @param args - index options
754
754
  */
755
- dropIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg] | [name?: string, options?: TableData.Index.OptionsArg]): Promise<void>;
755
+ dropIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions)[], ...args: [options?: TableData.Index.OptionsArg]): Promise<void>;
756
756
  /**
757
757
  * Rename index:
758
758
  *
@@ -507,7 +507,7 @@ const getIndexOrExcludeMainOptions = (tableName, item, getName, snakeCase) => {
507
507
  return {
508
508
  columns,
509
509
  include,
510
- name: item.name || getName(tableName, columns)
510
+ name: item.options?.name || getName(tableName, columns)
511
511
  };
512
512
  };
513
513
  const commentsToQuery = (schemaTable, comments) => {
@@ -1594,20 +1594,20 @@ class Migration {
1594
1594
  *
1595
1595
  * @param tableName - name of the table to add the index for
1596
1596
  * @param columns - indexed columns
1597
- * @param args - index options, or an index name and then options
1597
+ * @param args - index options
1598
1598
  */
1599
1599
  addIndex(tableName, columns, ...args) {
1600
- return addIndex(this, this.up, tableName, columns, args);
1600
+ return addIndex(this, this.up, tableName, columns, ...args);
1601
1601
  }
1602
1602
  /**
1603
1603
  * Drop the schema, create it on rollback. See {@link addIndex}.
1604
1604
  *
1605
1605
  * @param tableName - name of the table to add the index for
1606
1606
  * @param columns - indexed columns
1607
- * @param args - index options, or an index name and then options
1607
+ * @param args - index options
1608
1608
  */
1609
1609
  dropIndex(tableName, columns, ...args) {
1610
- return addIndex(this, !this.up, tableName, columns, args);
1610
+ return addIndex(this, !this.up, tableName, columns, ...args);
1611
1611
  }
1612
1612
  /**
1613
1613
  * Rename index:
@@ -2332,7 +2332,7 @@ const addColumn = (migration, up, tableName, columnName, fn) => {
2332
2332
  [columnName]: t.add(fn(t))
2333
2333
  }));
2334
2334
  };
2335
- const addIndex = (migration, up, tableName, columns, args) => {
2335
+ const addIndex = (migration, up, tableName, columns, ...args) => {
2336
2336
  return changeTable(migration, up, tableName, {}, (t) => ({
2337
2337
  ...t.add(t.index(columns, ...args))
2338
2338
  }));
@@ -4342,11 +4342,7 @@ const tableToAst = (ctx, data, table, action, domains) => {
4342
4342
  const indexesOrExcludesToAst = (tableName, tableData, key) => {
4343
4343
  return tableData[key].reduce((acc, item) => {
4344
4344
  if (item.columns.length > 1 || item.columns.some((it) => "expression" in it)) {
4345
- const { name, ...options } = makeIndexOrExcludeOptions(
4346
- tableName,
4347
- item,
4348
- key
4349
- );
4345
+ const options = makeIndexOrExcludeOptions(tableName, item, key);
4350
4346
  acc.push({
4351
4347
  columns: item.columns.map((it, i) => ({
4352
4348
  with: "exclude" in item && item.exclude ? item.exclude[i] : void 0,
@@ -4358,8 +4354,7 @@ const indexesOrExcludesToAst = (tableName, tableData, key) => {
4358
4354
  options: {
4359
4355
  ...options,
4360
4356
  include: item.include?.map(orchidCore.toCamelCase)
4361
- },
4362
- name
4357
+ }
4363
4358
  });
4364
4359
  }
4365
4360
  return acc;
@@ -4526,12 +4521,12 @@ const collectColumnIndexesOrExcludes = (dbColumn, column, tableName, tableData,
4526
4521
  ((_a = column.data)[key] ?? (_a[key] = [])).push({
4527
4522
  with: "exclude" in item && item.exclude ? item.exclude[0] : void 0,
4528
4523
  options: {
4524
+ name,
4529
4525
  collate: columnOptions.collate,
4530
4526
  opclass: columnOptions.opclass,
4531
4527
  order: columnOptions.order,
4532
4528
  ...itemOptions
4533
- },
4534
- name
4529
+ }
4535
4530
  });
4536
4531
  }
4537
4532
  };
@@ -4811,7 +4806,7 @@ const pushIndexOrExcludeKeys = (change, keys, schema, table, name, key) => {
4811
4806
  const getName = key === "indexes" ? getIndexName : getExcludeName;
4812
4807
  for (const x of items) {
4813
4808
  keys.push(
4814
- x.name ? `${schema}.${x.name}` : getName(table, [{ column: change.column?.data.name ?? name }])
4809
+ x.options.name ? `${schema}.${x.options.name}` : getName(table, [{ column: change.column?.data.name ?? name }])
4815
4810
  );
4816
4811
  }
4817
4812
  }
@@ -4821,7 +4816,9 @@ const pushIndexesOrExcludesKeys = (keys, schema, table, data, key) => {
4821
4816
  if (arr) {
4822
4817
  const getName = key === "indexes" ? getIndexName : getExcludeName;
4823
4818
  for (const x of arr) {
4824
- keys.push(x.name ? `${schema}.${x.name}` : getName(table, x.columns));
4819
+ keys.push(
4820
+ x.options.name ? `${schema}.${x.options.name}` : getName(table, x.columns)
4821
+ );
4825
4822
  }
4826
4823
  }
4827
4824
  };