pqb 0.9.0 → 0.9.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # pqb
2
2
 
3
+ ## 0.9.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve pulling db structure
8
+
9
+ ## 0.9.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Add command for pulling database structure into a migration
14
+
3
15
  ## 0.9.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.esm.js CHANGED
@@ -1,169 +1,5 @@
1
1
  import { types, Pool, DatabaseError } from 'pg';
2
2
 
3
- var __defProp$r = Object.defineProperty;
4
- var __defProps$k = Object.defineProperties;
5
- var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
7
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
8
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues$r = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp$s.call(b, prop))
13
- __defNormalProp$r(a, prop, b[prop]);
14
- if (__getOwnPropSymbols$s)
15
- for (var prop of __getOwnPropSymbols$s(b)) {
16
- if (__propIsEnum$s.call(b, prop))
17
- __defNormalProp$r(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
22
- const addColumnData = (q, key, value) => {
23
- const cloned = Object.create(q);
24
- cloned.data = __spreadProps$k(__spreadValues$r({}, q.data), { [key]: value });
25
- return cloned;
26
- };
27
- const pushColumnData = (q, key, value) => {
28
- const arr = q.data[key];
29
- return addColumnData(
30
- q,
31
- key,
32
- arr ? [...arr, value] : [value]
33
- );
34
- };
35
- const instantiateColumn = (klass, params) => {
36
- const column = new klass();
37
- Object.assign(column.data, params);
38
- return column;
39
- };
40
- class ColumnType {
41
- constructor() {
42
- this.data = {};
43
- this.isPrimaryKey = false;
44
- this.isHidden = false;
45
- this.hasDefault = false;
46
- this.chain = [];
47
- }
48
- primaryKey() {
49
- const cloned = Object.create(this);
50
- return Object.assign(cloned, { isPrimaryKey: true });
51
- }
52
- foreignKey(fnOrTable, column, options = {}) {
53
- const item = typeof fnOrTable === "string" ? __spreadValues$r({ table: fnOrTable, columns: [column] }, options) : __spreadValues$r({ fn: fnOrTable, columns: [column] }, options);
54
- return pushColumnData(this, "foreignKeys", item);
55
- }
56
- hidden() {
57
- return Object.assign(Object.create(this), { isHidden: true });
58
- }
59
- nullable() {
60
- return addColumnData(
61
- this,
62
- "isNullable",
63
- true
64
- );
65
- }
66
- encode(fn) {
67
- return Object.assign(Object.create(this), {
68
- encodeFn: fn
69
- });
70
- }
71
- parse(fn) {
72
- return Object.assign(Object.create(this), {
73
- parseFn: fn,
74
- parseItem: fn
75
- });
76
- }
77
- as(column) {
78
- return addColumnData(this, "as", column);
79
- }
80
- toSQL() {
81
- return this.dataType;
82
- }
83
- default(value) {
84
- return addColumnData(this, "default", value);
85
- }
86
- index(options = {}) {
87
- return pushColumnData(this, "indexes", options);
88
- }
89
- unique(options = {}) {
90
- return pushColumnData(this, "indexes", __spreadProps$k(__spreadValues$r({}, options), { unique: true }));
91
- }
92
- comment(comment) {
93
- return addColumnData(this, "comment", comment);
94
- }
95
- validationDefault(value) {
96
- return addColumnData(this, "validationDefault", value);
97
- }
98
- compression(compression) {
99
- return addColumnData(this, "compression", compression);
100
- }
101
- collate(collate) {
102
- return addColumnData(this, "collate", collate);
103
- }
104
- modifyQuery(cb) {
105
- return addColumnData(this, "modifyQuery", cb);
106
- }
107
- transform(fn) {
108
- const cloned = Object.create(this);
109
- cloned.chain = [...this.chain, ["transform", fn]];
110
- return cloned;
111
- }
112
- to(fn, type) {
113
- const cloned = Object.create(this);
114
- cloned.chain = [...this.chain, ["to", fn, type], ...cloned.chain];
115
- return cloned;
116
- }
117
- refine(check) {
118
- const cloned = Object.create(this);
119
- cloned.chain = [...this.chain, ["refine", check]];
120
- return cloned;
121
- }
122
- superRefine(check) {
123
- const cloned = Object.create(this);
124
- cloned.chain = [...this.chain, ["superRefine", check]];
125
- return cloned;
126
- }
127
- }
128
-
129
- const singleQuoteRegex = /'/g;
130
- const doubleQuoteRegex = /"/g;
131
- const quoteValue$1 = (value) => {
132
- const type = typeof value;
133
- if (type === "number")
134
- return String(value);
135
- else if (type === "string")
136
- return `"${value.replace(doubleQuoteRegex, '\\"').replace(singleQuoteRegex, "''")}"`;
137
- else if (type === "boolean")
138
- return value ? "true" : "false";
139
- else if (value instanceof Date)
140
- return `"${value.toISOString()}"`;
141
- else if (Array.isArray(value))
142
- return quoteArray(value);
143
- else if (type === null || type === void 0)
144
- return "NULL";
145
- else
146
- return `"${JSON.stringify(value).replace(doubleQuoteRegex, '\\"').replace(singleQuoteRegex, "''")}"`;
147
- };
148
- const quoteArray = (array) => `'{${array.map(quoteValue$1).join(",")}}'`;
149
- const quote = (value) => {
150
- const type = typeof value;
151
- if (type === "number")
152
- return `${value}`;
153
- else if (type === "string")
154
- return `'${value.replace(singleQuoteRegex, "''")}'`;
155
- else if (type === "boolean")
156
- return value ? "true" : "false";
157
- else if (value instanceof Date)
158
- return `'${value.toISOString()}'`;
159
- else if (Array.isArray(value))
160
- return quoteArray(value);
161
- else if (value === null || value === void 0)
162
- return "NULL";
163
- else
164
- return `'${JSON.stringify(value).replace(singleQuoteRegex, "''")}'`;
165
- };
166
-
167
3
  const defaultsKey = Symbol("defaults");
168
4
  const queryTypeWithLimitOne = {
169
5
  one: true,
@@ -171,6 +7,29 @@ const queryTypeWithLimitOne = {
171
7
  };
172
8
  const isQueryReturnsAll = (q) => !q.query.returnType || q.query.returnType === "all";
173
9
 
10
+ const q = (sql) => `"${sql}"`;
11
+ const qc = (column, quotedAs) => quotedAs ? `${quotedAs}.${q(column)}` : column;
12
+ const quoteFullColumn = (fullColumn, quotedAs) => {
13
+ const index = fullColumn.indexOf(".");
14
+ if (index !== -1) {
15
+ return `${q(fullColumn.slice(0, index))}.${q(fullColumn.slice(index + 1))}`;
16
+ } else if (quotedAs) {
17
+ return `${quotedAs}.${q(fullColumn)}`;
18
+ } else {
19
+ return q(fullColumn);
20
+ }
21
+ };
22
+ const expressionToSql = (expr, values, quotedAs) => {
23
+ return typeof expr === "object" && isRaw(expr) ? getRaw(expr, values) : quoteFullColumn(expr, quotedAs);
24
+ };
25
+ const quoteSchemaAndTable = (schema, table) => {
26
+ return schema ? `${q(schema)}.${q(table)}` : q(table);
27
+ };
28
+ const addValue = (values, value) => {
29
+ values.push(value);
30
+ return `$${values.length}`;
31
+ };
32
+
174
33
  const pushDistinctSql = (ctx, distinct, quotedAs) => {
175
34
  ctx.sql.push("DISTINCT");
176
35
  if (distinct.length) {
@@ -523,29 +382,29 @@ const pushIn = (ands, prefix, quotedAs, values, arg) => {
523
382
  );
524
383
  };
525
384
 
526
- var __defProp$q = Object.defineProperty;
527
- var __defProps$j = Object.defineProperties;
528
- var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
529
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
530
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
531
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
532
- var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
533
- var __spreadValues$q = (a, b) => {
385
+ var __defProp$r = Object.defineProperty;
386
+ var __defProps$k = Object.defineProperties;
387
+ var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
388
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
389
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
390
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
391
+ var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
392
+ var __spreadValues$r = (a, b) => {
534
393
  for (var prop in b || (b = {}))
535
- if (__hasOwnProp$r.call(b, prop))
536
- __defNormalProp$q(a, prop, b[prop]);
537
- if (__getOwnPropSymbols$r)
538
- for (var prop of __getOwnPropSymbols$r(b)) {
539
- if (__propIsEnum$r.call(b, prop))
540
- __defNormalProp$q(a, prop, b[prop]);
394
+ if (__hasOwnProp$s.call(b, prop))
395
+ __defNormalProp$r(a, prop, b[prop]);
396
+ if (__getOwnPropSymbols$s)
397
+ for (var prop of __getOwnPropSymbols$s(b)) {
398
+ if (__propIsEnum$s.call(b, prop))
399
+ __defNormalProp$r(a, prop, b[prop]);
541
400
  }
542
401
  return a;
543
402
  };
544
- var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
403
+ var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
545
404
  const aggregateToSql = (ctx, table, item, quotedAs) => {
546
405
  var _a;
547
406
  const sql = [`${item.function}(`];
548
- ctx = __spreadProps$j(__spreadValues$q({}, ctx), { sql });
407
+ ctx = __spreadProps$k(__spreadValues$r({}, ctx), { sql });
549
408
  const options = item.options || EMPTY_OBJECT;
550
409
  if (options.distinct && !options.withinGroup)
551
410
  sql.push("DISTINCT ");
@@ -642,6 +501,44 @@ class UnhandledTypeError extends PormInternalError {
642
501
  }
643
502
  }
644
503
 
504
+ const singleQuoteRegex = /'/g;
505
+ const doubleQuoteRegex = /"/g;
506
+ const quoteValue$1 = (value) => {
507
+ const type = typeof value;
508
+ if (type === "number")
509
+ return String(value);
510
+ else if (type === "string")
511
+ return `"${value.replace(doubleQuoteRegex, '\\"').replace(singleQuoteRegex, "''")}"`;
512
+ else if (type === "boolean")
513
+ return value ? "true" : "false";
514
+ else if (value instanceof Date)
515
+ return `"${value.toISOString()}"`;
516
+ else if (Array.isArray(value))
517
+ return quoteArray(value);
518
+ else if (type === null || type === void 0)
519
+ return "NULL";
520
+ else
521
+ return `"${JSON.stringify(value).replace(doubleQuoteRegex, '\\"').replace(singleQuoteRegex, "''")}"`;
522
+ };
523
+ const quoteArray = (array) => `'{${array.map(quoteValue$1).join(",")}}'`;
524
+ const quote = (value) => {
525
+ const type = typeof value;
526
+ if (type === "number")
527
+ return `${value}`;
528
+ else if (type === "string")
529
+ return `'${value.replace(singleQuoteRegex, "''")}'`;
530
+ else if (type === "boolean")
531
+ return value ? "true" : "false";
532
+ else if (value instanceof Date)
533
+ return `'${value.toISOString()}'`;
534
+ else if (Array.isArray(value))
535
+ return quoteArray(value);
536
+ else if (value === null || value === void 0)
537
+ return "NULL";
538
+ else
539
+ return `'${JSON.stringify(value).replace(singleQuoteRegex, "''")}'`;
540
+ };
541
+
645
542
  const relationQueryKey = Symbol("relationQuery");
646
543
  const isRequiredRelationKey = Symbol("isRequiredRelation");
647
544
 
@@ -1363,19 +1260,19 @@ const cloneQueryArrays = (q) => {
1363
1260
  }
1364
1261
  };
1365
1262
 
1366
- var __defProp$p = Object.defineProperty;
1367
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
1368
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
1369
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
1370
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1371
- var __spreadValues$p = (a, b) => {
1263
+ var __defProp$q = Object.defineProperty;
1264
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
1265
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
1266
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
1267
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1268
+ var __spreadValues$q = (a, b) => {
1372
1269
  for (var prop in b || (b = {}))
1373
- if (__hasOwnProp$q.call(b, prop))
1374
- __defNormalProp$p(a, prop, b[prop]);
1375
- if (__getOwnPropSymbols$q)
1376
- for (var prop of __getOwnPropSymbols$q(b)) {
1377
- if (__propIsEnum$q.call(b, prop))
1378
- __defNormalProp$p(a, prop, b[prop]);
1270
+ if (__hasOwnProp$r.call(b, prop))
1271
+ __defNormalProp$q(a, prop, b[prop]);
1272
+ if (__getOwnPropSymbols$r)
1273
+ for (var prop of __getOwnPropSymbols$r(b)) {
1274
+ if (__propIsEnum$r.call(b, prop))
1275
+ __defNormalProp$q(a, prop, b[prop]);
1379
1276
  }
1380
1277
  return a;
1381
1278
  };
@@ -1394,7 +1291,7 @@ const joinTruthy = (...strings) => {
1394
1291
  return strings.filter((string) => string).join("");
1395
1292
  };
1396
1293
  const getClonedQueryData = (query) => {
1397
- const cloned = __spreadValues$p({}, query);
1294
+ const cloned = __spreadValues$q({}, query);
1398
1295
  delete cloned[toSqlCacheKey];
1399
1296
  cloneQueryArrays(cloned);
1400
1297
  return cloned;
@@ -1475,28 +1372,137 @@ const getQueryParsers = (q) => {
1475
1372
  return q.query.parsers || q.columnsParsers;
1476
1373
  };
1477
1374
 
1478
- const q = (sql) => `"${sql}"`;
1479
- const qc = (column, quotedAs) => quotedAs ? `${quotedAs}.${q(column)}` : column;
1480
- const quoteFullColumn = (fullColumn, quotedAs) => {
1481
- const index = fullColumn.indexOf(".");
1482
- if (index !== -1) {
1483
- return `${q(fullColumn.slice(0, index))}.${q(fullColumn.slice(index + 1))}`;
1484
- } else if (quotedAs) {
1485
- return `${quotedAs}.${q(fullColumn)}`;
1486
- } else {
1487
- return q(fullColumn);
1488
- }
1375
+ var __defProp$p = Object.defineProperty;
1376
+ var __defProps$j = Object.defineProperties;
1377
+ var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
1378
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
1379
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
1380
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
1381
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1382
+ var __spreadValues$p = (a, b) => {
1383
+ for (var prop in b || (b = {}))
1384
+ if (__hasOwnProp$q.call(b, prop))
1385
+ __defNormalProp$p(a, prop, b[prop]);
1386
+ if (__getOwnPropSymbols$q)
1387
+ for (var prop of __getOwnPropSymbols$q(b)) {
1388
+ if (__propIsEnum$q.call(b, prop))
1389
+ __defNormalProp$p(a, prop, b[prop]);
1390
+ }
1391
+ return a;
1489
1392
  };
1490
- const expressionToSql = (expr, values, quotedAs) => {
1491
- return typeof expr === "object" && isRaw(expr) ? getRaw(expr, values) : quoteFullColumn(expr, quotedAs);
1393
+ var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
1394
+ const addColumnData = (q, key, value) => {
1395
+ const cloned = Object.create(q);
1396
+ cloned.data = __spreadProps$j(__spreadValues$p({}, q.data), { [key]: value });
1397
+ return cloned;
1492
1398
  };
1493
- const quoteSchemaAndTable = (schema, table) => {
1494
- return schema ? `${q(schema)}.${q(table)}` : q(table);
1399
+ const pushColumnData = (q, key, value) => {
1400
+ const arr = q.data[key];
1401
+ return addColumnData(
1402
+ q,
1403
+ key,
1404
+ arr ? [...arr, value] : [value]
1405
+ );
1495
1406
  };
1496
- const addValue = (values, value) => {
1497
- values.push(value);
1498
- return `$${values.length}`;
1407
+ const instantiateColumn = (klass, params) => {
1408
+ const column = new klass();
1409
+ let data;
1410
+ if (params.default !== null && params.default !== void 0) {
1411
+ data = __spreadProps$j(__spreadValues$p({}, params), { default: raw(params.default) });
1412
+ } else {
1413
+ data = params;
1414
+ }
1415
+ Object.assign(column.data, data);
1416
+ return column;
1499
1417
  };
1418
+ class ColumnType {
1419
+ constructor() {
1420
+ this.data = {};
1421
+ this.isPrimaryKey = false;
1422
+ this.isHidden = false;
1423
+ this.hasDefault = false;
1424
+ this.chain = [];
1425
+ }
1426
+ primaryKey() {
1427
+ const cloned = Object.create(this);
1428
+ return Object.assign(cloned, { isPrimaryKey: true });
1429
+ }
1430
+ foreignKey(fnOrTable, column, options = {}) {
1431
+ const item = typeof fnOrTable === "string" ? __spreadValues$p({ table: fnOrTable, columns: [column] }, options) : __spreadValues$p({ fn: fnOrTable, columns: [column] }, options);
1432
+ return pushColumnData(this, "foreignKeys", item);
1433
+ }
1434
+ hidden() {
1435
+ return Object.assign(Object.create(this), { isHidden: true });
1436
+ }
1437
+ nullable() {
1438
+ return addColumnData(
1439
+ this,
1440
+ "isNullable",
1441
+ true
1442
+ );
1443
+ }
1444
+ encode(fn) {
1445
+ return Object.assign(Object.create(this), {
1446
+ encodeFn: fn
1447
+ });
1448
+ }
1449
+ parse(fn) {
1450
+ return Object.assign(Object.create(this), {
1451
+ parseFn: fn,
1452
+ parseItem: fn
1453
+ });
1454
+ }
1455
+ as(column) {
1456
+ return addColumnData(this, "as", column);
1457
+ }
1458
+ toSQL() {
1459
+ return this.dataType;
1460
+ }
1461
+ default(value) {
1462
+ return addColumnData(this, "default", value);
1463
+ }
1464
+ index(options = {}) {
1465
+ return pushColumnData(this, "indexes", options);
1466
+ }
1467
+ unique(options = {}) {
1468
+ return pushColumnData(this, "indexes", __spreadProps$j(__spreadValues$p({}, options), { unique: true }));
1469
+ }
1470
+ comment(comment) {
1471
+ return addColumnData(this, "comment", comment);
1472
+ }
1473
+ validationDefault(value) {
1474
+ return addColumnData(this, "validationDefault", value);
1475
+ }
1476
+ compression(compression) {
1477
+ return addColumnData(this, "compression", compression);
1478
+ }
1479
+ collate(collate) {
1480
+ return addColumnData(this, "collate", collate);
1481
+ }
1482
+ modifyQuery(cb) {
1483
+ return addColumnData(this, "modifyQuery", cb);
1484
+ }
1485
+ transform(fn) {
1486
+ const cloned = Object.create(this);
1487
+ cloned.chain = [...this.chain, ["transform", fn]];
1488
+ return cloned;
1489
+ }
1490
+ to(fn, type) {
1491
+ const cloned = Object.create(this);
1492
+ cloned.chain = [...this.chain, ["to", fn, type], ...cloned.chain];
1493
+ return cloned;
1494
+ }
1495
+ refine(check) {
1496
+ const cloned = Object.create(this);
1497
+ cloned.chain = [...this.chain, ["refine", check]];
1498
+ return cloned;
1499
+ }
1500
+ superRefine(check) {
1501
+ const cloned = Object.create(this);
1502
+ cloned.chain = [...this.chain, ["superRefine", check]];
1503
+ return cloned;
1504
+ }
1505
+ }
1500
1506
 
1501
1507
  var __defProp$o = Object.defineProperty;
1502
1508
  var __defProps$i = Object.defineProperties;
@@ -1848,18 +1854,21 @@ class DateTimeWithTimeZoneBaseClass extends DateTimeBaseClass {
1848
1854
  );
1849
1855
  }
1850
1856
  }
1857
+ const timestampToCode = (self, t) => {
1858
+ const { dateTimePrecision: p } = self.data;
1859
+ return columnCode(
1860
+ self,
1861
+ t,
1862
+ `${t}.${self instanceof TimestampColumn ? "timestamp" : "timestampWithTimeZone"}(${p && p !== 6 ? p : ""})${dateDataToCode(self.data)}`
1863
+ );
1864
+ };
1851
1865
  class TimestampColumn extends DateTimeBaseClass {
1852
1866
  constructor() {
1853
1867
  super(...arguments);
1854
1868
  this.dataType = "timestamp";
1855
1869
  }
1856
1870
  toCode(t) {
1857
- const { dateTimePrecision } = this.data;
1858
- return columnCode(
1859
- this,
1860
- t,
1861
- `${t}.timestamp(${dateTimePrecision || ""})${dateDataToCode(this.data)}`
1862
- );
1871
+ return timestampToCode(this, t);
1863
1872
  }
1864
1873
  }
1865
1874
  class TimestampWithTimeZoneColumn extends DateTimeWithTimeZoneBaseClass {
@@ -1869,14 +1878,7 @@ class TimestampWithTimeZoneColumn extends DateTimeWithTimeZoneBaseClass {
1869
1878
  this.baseDataType = "timestamp";
1870
1879
  }
1871
1880
  toCode(t) {
1872
- const { dateTimePrecision } = this.data;
1873
- return columnCode(
1874
- this,
1875
- t,
1876
- `${t}.timestampWithTimeZone(${dateTimePrecision || ""})${dateDataToCode(
1877
- this.data
1878
- )}`
1879
- );
1881
+ return timestampToCode(this, t);
1880
1882
  }
1881
1883
  }
1882
1884
  class TimeColumn extends DateTimeBaseClass {
@@ -2067,6 +2069,8 @@ const indexToCode = (index, t) => {
2067
2069
  const options = [];
2068
2070
  for (const key of optionsKeys) {
2069
2071
  const value = index.options[key];
2072
+ if (value === null || value === void 0)
2073
+ continue;
2070
2074
  options.push(
2071
2075
  `${key}: ${typeof value === "object" ? singleQuoteArray(value) : typeof value === "string" ? singleQuote(value) : value},`
2072
2076
  );
@@ -2178,8 +2182,6 @@ const columnIndexesToCode = (indexes) => {
2178
2182
  arr.push(`order: ${singleQuote(index.order)},`);
2179
2183
  if (index.name)
2180
2184
  arr.push(`name: ${singleQuote(index.name)},`);
2181
- if (index.unique)
2182
- arr.push(`unique: true,`);
2183
2185
  if (index.using)
2184
2186
  arr.push(`using: ${singleQuote(index.using)},`);
2185
2187
  if (index.include)
@@ -4101,7 +4103,10 @@ const columnsByType = {
4101
4103
  uuid: UUIDColumn,
4102
4104
  tsvector: TsVectorColumn,
4103
4105
  tsquery: TsQueryColumn,
4104
- jsonb: JSONColumn
4106
+ jsonb: JSONColumn,
4107
+ smallserial: SmallSerialColumn,
4108
+ serial: SerialColumn,
4109
+ bigserial: BigSerialColumn
4105
4110
  };
4106
4111
 
4107
4112
  var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;