rake-db 2.10.2 → 2.10.4

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
@@ -1099,39 +1099,24 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
1099
1099
  tsquery(): pqb.TsQueryColumn;
1100
1100
  uuid(): pqb.UUIDColumn;
1101
1101
  xml(): pqb.XMLColumn;
1102
- json<Type extends orchid_core.JSONTypeAny>(schemaOrFn: Type | ((j: {
1103
- set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
1104
- tuple: <T_5 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_5, rest?: Rest) => orchid_core.JSONTuple<T_5, Rest>;
1105
- union: <T_6 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_6) => orchid_core.JSONUnion<T_6>;
1106
- any: () => orchid_core.JSONAny;
1107
- bigint: () => orchid_core.JSONBigInt;
1102
+ json<Type extends orchid_core.JSONType<unknown, {}> = orchid_core.JSONUnknown>(schemaOrFn?: Type | ((j: {
1103
+ unknown: () => orchid_core.JSONUnknown;
1108
1104
  boolean: () => orchid_core.JSONBoolean;
1109
- date: () => orchid_core.JSONDate;
1110
- nan: () => orchid_core.JSONNaN;
1111
- never: () => orchid_core.JSONNever;
1112
1105
  null: () => orchid_core.JSONNull;
1113
1106
  number: () => orchid_core.JSONNumber;
1114
1107
  string: () => orchid_core.JSONString;
1115
- unknown: () => orchid_core.JSONUnknown;
1116
- array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
1117
- discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types>;
1118
- enum: <U_1 extends string, T_7 extends [U_1, ...U_1[]]>(options: T_7) => orchid_core.JSONEnum<U_1, T_7>;
1119
- instanceOf: <T_8 extends new (...args: any[]) => any>(cls: T_8) => orchid_core.JSONInstanceOf<T_8>;
1120
- intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
1121
- lazy: <T_9 extends orchid_core.JSONTypeAny>(fn: () => T_9) => orchid_core.JSONLazy<T_9>;
1122
- literal: <T_10 extends orchid_core.Primitive>(value: T_10) => orchid_core.JSONLiteral<T_10>;
1123
- map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
1124
- nativeEnum: <T_11 extends orchid_core.EnumLike>(givenEnum: T_11) => orchid_core.JSONNativeEnum<T_11>;
1125
- nullable: <T_12 extends orchid_core.JSONTypeAny>(type: T_12) => orchid_core.JSONNullable<T_12>;
1126
- nullish: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONNullish<T_13>;
1127
- object: <T_14 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_14) => orchid_core.JSONObject<T_14, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_15 extends object ? { [k in keyof T_15]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_18 extends object ? { [k in keyof T_18]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
1128
- [k: string]: Catchall["type"];
1129
- } extends infer T_16 extends object ? { [k_2 in keyof T_16]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_17 extends object ? { [k in keyof T_17]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
1130
- [k: string]: Catchall["type"];
1131
- })[k_2]; } : never>;
1132
- optional: <T_19 extends orchid_core.JSONTypeAny>(type: T_19) => orchid_core.JSONOptional<T_19>;
1133
- record: typeof orchid_core.record;
1134
- }) => Type)): pqb.JSONColumn<Type>;
1108
+ array: <T_5 extends orchid_core.JSONType<unknown, {}>>(item: T_5) => orchid_core.JSONArray<T_5, "many">;
1109
+ object: <Shape extends orchid_core.JSONObjectShape>(shape: Shape) => orchid_core.JSONObject<Shape, "strip", orchid_core.JSONType<unknown, {}>>;
1110
+ literal: <T_6 extends orchid_core.JSONPrimitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
1111
+ discriminatedUnion: <Discriminator extends string, Types extends orchid_core.JSONDiscriminatedUnionArg<Discriminator>>(discriminator: Discriminator, types: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, Types>;
1112
+ enum: <U_1 extends string, T_7 extends [U_1, ...U_1[]]>(options: T_7) => orchid_core.JSONEnum<string, T_7>;
1113
+ intersection: <Left extends orchid_core.JSONType<unknown, {}>, Right extends orchid_core.JSONType<unknown, {}>>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
1114
+ lazy: <T_8 extends orchid_core.JSONType<unknown, {}>>(fn: () => T_8) => orchid_core.JSONLazy<T_8>;
1115
+ nativeEnum: <T_9 extends orchid_core.EnumLike>(type: T_9) => orchid_core.JSONNativeEnum<T_9>;
1116
+ record: <Key extends orchid_core.JSONNumber | orchid_core.JSONString, Value extends orchid_core.JSONType<unknown, {}>>(...args: [value: Value] | [key: Key, value: Value]) => orchid_core.JSONRecord<Key, Value>;
1117
+ tuple: <T_10 extends orchid_core.JSONTupleItems, Rest extends orchid_core.JSONType<unknown, {}> | undefined = undefined>(items: T_10, rest?: Rest | undefined) => orchid_core.JSONTuple<T_10, Rest>;
1118
+ union: <T_11 extends orchid_core.JSONUnionArgs>(...types: T_11) => orchid_core.JSONUnion<T_11>;
1119
+ }) => Type) | undefined): pqb.JSONColumn<Type>;
1135
1120
  jsonText(): pqb.JSONTextColumn;
1136
1121
  array<Item extends pqb.ColumnType<unknown, pqb.BaseOperators, unknown>>(item: Item): pqb.ArrayColumn<Item>;
1137
1122
  type(dataType: string): pqb.CustomTypeColumn;
package/dist/index.js CHANGED
@@ -1085,7 +1085,9 @@ const astToQueries = (ast, snakeCase, language) => {
1085
1085
  } else if (item.type === "change") {
1086
1086
  const { from, to } = item;
1087
1087
  const name = getChangeColumnName(item, key, snakeCase);
1088
+ let changeType = false;
1088
1089
  if (to.type && (from.type !== to.type || from.collate !== to.collate)) {
1090
+ changeType = true;
1089
1091
  const type = !to.column || to.column.data.isOfCustomType ? `"${to.type}"` : to.type;
1090
1092
  alterTable.push(
1091
1093
  `ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${item.using ? ` USING ${item.using.toSQL({ values })}` : ""}`
@@ -1097,7 +1099,10 @@ const astToQueries = (ast, snakeCase, language) => {
1097
1099
  );
1098
1100
  }
1099
1101
  if (from.default !== to.default) {
1100
- const value = typeof to.default === "object" && to.default && orchidCore.isRawSQL(to.default) ? to.default.toSQL({ values }) : pqb.quote(to.default);
1102
+ const value = to.default === void 0 ? void 0 : typeof to.default === "object" && to.default && orchidCore.isRawSQL(to.default) ? to.default.toSQL({ values }) : pqb.quote(to.default);
1103
+ if (changeType && value !== void 0) {
1104
+ alterTable.push(`ALTER COLUMN "${name}" DROP DEFAULT`);
1105
+ }
1101
1106
  const expr = value === void 0 ? "DROP DEFAULT" : `SET DEFAULT ${value}`;
1102
1107
  alterTable.push(`ALTER COLUMN "${name}" ${expr}`);
1103
1108
  }