rake-db 2.10.28 → 2.10.30
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 +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1078,7 +1078,7 @@ declare const rakeDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreato
|
|
|
1078
1078
|
decimal<Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(precision?: Precision_1 | undefined, scale?: Scale_1 | undefined): pqb.DecimalColumn<Precision_1, Scale_1>;
|
|
1079
1079
|
real(): pqb.RealColumn;
|
|
1080
1080
|
doublePrecision(): pqb.DoublePrecisionColumn;
|
|
1081
|
-
identity(options?: pqb.TableData.Identity | undefined):
|
|
1081
|
+
identity(options?: pqb.TableData.Identity | undefined): orchid_core.ColumnWithDefault<pqb.IntegerColumn, orchid_core.Expression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, unknown, unknown, orchid_core.ColumnDataBase>>>;
|
|
1082
1082
|
smallSerial(): pqb.SmallSerialColumn;
|
|
1083
1083
|
serial(): pqb.SerialColumn;
|
|
1084
1084
|
bigSerial(): pqb.BigSerialColumn;
|
package/dist/index.js
CHANGED
|
@@ -361,11 +361,12 @@ const columnToSql = (name, item, values, hasMultiplePrimaryKeys, snakeCase) => {
|
|
|
361
361
|
if (item.data.check) {
|
|
362
362
|
line.push(checkToSql(item.data.check, values));
|
|
363
363
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
364
|
+
const def = item.data.default;
|
|
365
|
+
if (def !== void 0 && def !== null && typeof def !== "function") {
|
|
366
|
+
if (orchidCore.isRawSQL(def)) {
|
|
367
|
+
line.push(`DEFAULT ${def.toSQL({ values })}`);
|
|
367
368
|
} else {
|
|
368
|
-
line.push(`DEFAULT ${pqb.quote(
|
|
369
|
+
line.push(`DEFAULT ${pqb.quote(def)}`);
|
|
369
370
|
}
|
|
370
371
|
}
|
|
371
372
|
const { foreignKeys } = item.data;
|
|
@@ -1124,11 +1125,11 @@ const astToQueries = (ast, snakeCase, language) => {
|
|
|
1124
1125
|
);
|
|
1125
1126
|
}
|
|
1126
1127
|
if (from.default !== to.default) {
|
|
1127
|
-
const value = to.default === void 0
|
|
1128
|
-
if (changeType && value !==
|
|
1128
|
+
const value = to.default === void 0 || to.default === null || typeof to.default === "function" ? null : typeof to.default === "object" && orchidCore.isRawSQL(to.default) ? to.default.toSQL({ values }) : pqb.quote(to.default);
|
|
1129
|
+
if (changeType && value !== null) {
|
|
1129
1130
|
alterTable.push(`ALTER COLUMN "${name}" DROP DEFAULT`);
|
|
1130
1131
|
}
|
|
1131
|
-
const expr = value ===
|
|
1132
|
+
const expr = value === null ? "DROP DEFAULT" : `SET DEFAULT ${value}`;
|
|
1132
1133
|
alterTable.push(`ALTER COLUMN "${name}" ${expr}`);
|
|
1133
1134
|
}
|
|
1134
1135
|
if (from.nullable !== to.nullable) {
|