knex 0.95.14 → 1.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +90 -1
  2. package/README.md +1 -1
  3. package/UPGRADING.md +7 -0
  4. package/lib/client.js +14 -1
  5. package/lib/constants.js +2 -0
  6. package/lib/dialects/better-sqlite3/index.js +72 -0
  7. package/lib/dialects/cockroachdb/crdb-querycompiler.js +92 -33
  8. package/lib/dialects/cockroachdb/crdb-tablecompiler.js +19 -0
  9. package/lib/dialects/cockroachdb/index.js +13 -0
  10. package/lib/dialects/mssql/index.js +0 -11
  11. package/lib/dialects/mssql/query/mssql-querycompiler.js +122 -64
  12. package/lib/dialects/mssql/schema/mssql-columncompiler.js +41 -6
  13. package/lib/dialects/mssql/schema/mssql-compiler.js +3 -4
  14. package/lib/dialects/mssql/schema/mssql-tablecompiler.js +24 -9
  15. package/lib/dialects/mssql/schema/mssql-viewcompiler.js +15 -1
  16. package/lib/dialects/mysql/query/mysql-querycompiler.js +93 -5
  17. package/lib/dialects/mysql/schema/mysql-columncompiler.js +32 -5
  18. package/lib/dialects/mysql/schema/mysql-tablecompiler.js +33 -6
  19. package/lib/dialects/oracle/query/oracle-querycompiler.js +7 -6
  20. package/lib/dialects/oracle/schema/internal/trigger.js +1 -1
  21. package/lib/dialects/oracle/schema/oracle-columncompiler.js +10 -4
  22. package/lib/dialects/oracle/schema/oracle-tablecompiler.js +17 -6
  23. package/lib/dialects/oracledb/index.js +0 -4
  24. package/lib/dialects/oracledb/query/oracledb-querycompiler.js +89 -0
  25. package/lib/dialects/oracledb/schema/oracledb-columncompiler.js +23 -0
  26. package/lib/dialects/postgres/index.js +21 -6
  27. package/lib/dialects/postgres/query/pg-querybuilder.js +38 -0
  28. package/lib/dialects/postgres/query/pg-querycompiler.js +172 -9
  29. package/lib/dialects/postgres/schema/pg-columncompiler.js +24 -4
  30. package/lib/dialects/postgres/schema/pg-tablecompiler.js +63 -46
  31. package/lib/dialects/redshift/index.js +12 -0
  32. package/lib/dialects/redshift/query/redshift-querycompiler.js +62 -26
  33. package/lib/dialects/redshift/schema/redshift-columncompiler.js +2 -1
  34. package/lib/dialects/redshift/schema/redshift-tablecompiler.js +4 -1
  35. package/lib/dialects/sqlite3/index.js +23 -4
  36. package/lib/dialects/sqlite3/query/sqlite-querybuilder.js +33 -0
  37. package/lib/dialects/sqlite3/query/sqlite-querycompiler.js +87 -22
  38. package/lib/dialects/sqlite3/schema/ddl.js +274 -282
  39. package/lib/dialects/sqlite3/schema/internal/sqlite-ddl-operations.js +18 -8
  40. package/lib/dialects/sqlite3/schema/sqlite-columncompiler.js +20 -0
  41. package/lib/dialects/sqlite3/schema/sqlite-compiler.js +16 -12
  42. package/lib/dialects/sqlite3/schema/sqlite-tablecompiler.js +15 -5
  43. package/lib/dialects/sqlite3/schema/sqlite-viewcompiler.js +31 -2
  44. package/lib/execution/runner.js +37 -2
  45. package/lib/knex-builder/FunctionHelper.js +36 -0
  46. package/lib/migrations/common/MigrationsLoader.js +36 -0
  47. package/lib/migrations/migrate/MigrationGenerator.js +1 -1
  48. package/lib/migrations/migrate/Migrator.js +22 -24
  49. package/lib/migrations/migrate/migration-list-resolver.js +2 -5
  50. package/lib/migrations/migrate/{configuration-merger.js → migrator-configuration-merger.js} +2 -4
  51. package/lib/migrations/migrate/sources/fs-migrations.js +4 -29
  52. package/lib/migrations/migrate/stub/js.stub +8 -1
  53. package/lib/migrations/migrate/stub/knexfile-js.stub +3 -0
  54. package/lib/migrations/migrate/stub/knexfile-ts.stub +5 -2
  55. package/lib/migrations/migrate/table-creator.js +6 -5
  56. package/lib/migrations/seed/Seeder.js +25 -92
  57. package/lib/migrations/seed/seeder-configuration-merger.js +60 -0
  58. package/lib/migrations/seed/sources/fs-seeds.js +65 -0
  59. package/lib/migrations/seed/stub/js.stub +4 -1
  60. package/lib/migrations/util/import-file.js +0 -1
  61. package/lib/query/joinclause.js +24 -5
  62. package/lib/query/method-constants.js +37 -0
  63. package/lib/query/querybuilder.js +292 -53
  64. package/lib/query/querycompiler.js +309 -85
  65. package/lib/schema/columnbuilder.js +14 -1
  66. package/lib/schema/columncompiler.js +132 -5
  67. package/lib/schema/compiler.js +1 -0
  68. package/lib/schema/tablebuilder.js +41 -8
  69. package/lib/schema/tablecompiler.js +61 -4
  70. package/lib/schema/viewcompiler.js +13 -10
  71. package/package.json +37 -27
  72. package/scripts/docker-compose.yml +7 -7
  73. package/scripts/oracledb-install-driver-libs.sh +82 -0
  74. package/scripts/runkit-example.js +1 -1
  75. package/scripts/stress-test/docker-compose.yml +3 -3
  76. package/scripts/stress-test/knex-stress-test.js +1 -1
  77. package/scripts/stress-test/reconnect-test-mysql-based-drivers.js +1 -1
  78. package/types/index.d.ts +133 -21
@@ -144,7 +144,34 @@ class QueryCompiler {
144
144
  // inserts using a single query statement.
145
145
  insert() {
146
146
  const insertValues = this.single.insert || [];
147
- let sql = this.with() + `insert into ${this.tableName} `;
147
+ const sql = this.with() + `insert into ${this.tableName} `;
148
+ const body = this._insertBody(insertValues);
149
+ return body === '' ? '' : sql + body;
150
+ }
151
+
152
+ _onConflictClause(columns) {
153
+ return columns instanceof Raw
154
+ ? this.formatter.wrap(columns)
155
+ : `(${this.formatter.columnize(columns)})`;
156
+ }
157
+
158
+ _buildInsertValues(insertData) {
159
+ let sql = '';
160
+ let i = -1;
161
+ while (++i < insertData.values.length) {
162
+ if (i !== 0) sql += '), (';
163
+ sql += this.client.parameterize(
164
+ insertData.values[i],
165
+ this.client.valueForUndefined,
166
+ this.builder,
167
+ this.bindingsHolder
168
+ );
169
+ }
170
+ return sql;
171
+ }
172
+
173
+ _insertBody(insertValues) {
174
+ let sql = '';
148
175
  if (Array.isArray(insertValues)) {
149
176
  if (insertValues.length === 0) {
150
177
  return '';
@@ -164,18 +191,7 @@ class QueryCompiler {
164
191
  this.client,
165
192
  this.bindingsHolder
166
193
  )}`;
167
- sql += ') values (';
168
- let i = -1;
169
- while (++i < insertData.values.length) {
170
- if (i !== 0) sql += '), (';
171
- sql += this.client.parameterize(
172
- insertData.values[i],
173
- this.client.valueForUndefined,
174
- this.builder,
175
- this.bindingsHolder
176
- );
177
- }
178
- sql += ')';
194
+ sql += ') values (' + this._buildInsertValues(insertData) + ')';
179
195
  } else if (insertValues.length === 1 && insertValues[0]) {
180
196
  sql += this._emptyInsertValue;
181
197
  } else {
@@ -230,6 +246,8 @@ class QueryCompiler {
230
246
  sql.push(this.aggregateRaw(stmt));
231
247
  } else if (stmt.type === 'analytic') {
232
248
  sql.push(this.analytic(stmt));
249
+ } else if (stmt.type === 'json') {
250
+ sql.push(this.json(stmt));
233
251
  } else if (stmt.value && stmt.value.length > 0) {
234
252
  sql.push(
235
253
  columnize_(
@@ -243,8 +261,9 @@ class QueryCompiler {
243
261
  }
244
262
  }
245
263
  if (sql.length === 0) sql = ['*'];
264
+ const select = this.onlyJson() ? '' : 'select ';
246
265
  return (
247
- `select ${hints}${distinctClause}` +
266
+ `${select}${hints}${distinctClause}` +
248
267
  sql.join(', ') +
249
268
  (this.tableName
250
269
  ? ` from ${this.single.only ? 'only ' : ''}${this.tableName}`
@@ -333,6 +352,12 @@ class QueryCompiler {
333
352
  })`;
334
353
  }
335
354
 
355
+ _joinTable(join) {
356
+ return join.schema && !(join.table instanceof Raw)
357
+ ? `${join.schema}.${join.table}`
358
+ : join.table;
359
+ }
360
+
336
361
  // Compiles all each of the `join` clauses on the query,
337
362
  // including any nested join queries.
338
363
  join() {
@@ -342,10 +367,7 @@ class QueryCompiler {
342
367
  if (!joins) return '';
343
368
  while (++i < joins.length) {
344
369
  const join = joins[i];
345
- const table =
346
- join.schema && !(join.table instanceof Raw)
347
- ? `${join.schema}.${join.table}`
348
- : join.table;
370
+ const table = this._joinTable(join);
349
371
  if (i > 0) sql += ' ';
350
372
  if (join.joinType === 'raw') {
351
373
  sql += unwrapRaw_(
@@ -435,6 +457,23 @@ class QueryCompiler {
435
457
 
436
458
  onIn(statement) {
437
459
  if (Array.isArray(statement.column)) return this.multiOnIn(statement);
460
+
461
+ let values;
462
+ if (statement.value instanceof Raw) {
463
+ values = this.client.parameter(
464
+ statement.value,
465
+ this.builder,
466
+ this.formatter
467
+ );
468
+ } else {
469
+ values = this.client.parameterize(
470
+ statement.value,
471
+ undefined,
472
+ this.builder,
473
+ this.bindingsHolder
474
+ );
475
+ }
476
+
438
477
  return (
439
478
  wrap_(
440
479
  statement.column,
@@ -445,14 +484,7 @@ class QueryCompiler {
445
484
  ) +
446
485
  ' ' +
447
486
  this._not(statement, 'in ') +
448
- this.wrap(
449
- this.client.parameterize(
450
- statement.value,
451
- undefined,
452
- this.builder,
453
- this.bindingsHolder
454
- )
455
- )
487
+ this.wrap(values)
456
488
  );
457
489
  }
458
490
 
@@ -653,24 +685,7 @@ class QueryCompiler {
653
685
  }
654
686
 
655
687
  multiHavingIn(statement) {
656
- let i = -1,
657
- sql = `(${columnize_(
658
- statement.column,
659
- this.builder,
660
- this.client,
661
- this.bindingsHolder
662
- )}) `;
663
- sql += this._not(statement, 'in ') + '((';
664
- while (++i < statement.value.length) {
665
- if (i !== 0) sql += '),(';
666
- sql += this.client.parameterize(
667
- statement.value[i],
668
- undefined,
669
- this.builder,
670
- this.bindingsHolder
671
- );
672
- }
673
- return sql + '))';
688
+ return this.multiOnIn(statement);
674
689
  }
675
690
 
676
691
  // Compile the "union" queries attached to the main query.
@@ -702,26 +717,44 @@ class QueryCompiler {
702
717
  // If we haven't specified any columns or a `tableName`, we're assuming this
703
718
  // is only being used for unions.
704
719
  onlyUnions() {
705
- return !this.grouped.columns && this.grouped.union && !this.tableName;
720
+ return (
721
+ (!this.grouped.columns || !!this.grouped.columns[0].value) &&
722
+ this.grouped.union &&
723
+ !this.tableName
724
+ );
725
+ }
726
+
727
+ _getValueOrParameterFromAttribute(attribute, rawValue) {
728
+ if (this.single.skipBinding[attribute] === true) {
729
+ return rawValue !== undefined && rawValue !== null
730
+ ? rawValue
731
+ : this.single[attribute];
732
+ }
733
+ return this.client.parameter(
734
+ this.single[attribute],
735
+ this.builder,
736
+ this.bindingsHolder
737
+ );
738
+ }
739
+
740
+ onlyJson() {
741
+ return (
742
+ !this.tableName &&
743
+ this.grouped.columns &&
744
+ this.grouped.columns.length === 1 &&
745
+ this.grouped.columns[0].type === 'json'
746
+ );
706
747
  }
707
748
 
708
749
  limit() {
709
750
  const noLimit = !this.single.limit && this.single.limit !== 0;
710
751
  if (noLimit) return '';
711
- return `limit ${this.client.parameter(
712
- this.single.limit,
713
- this.builder,
714
- this.bindingsHolder
715
- )}`;
752
+ return `limit ${this._getValueOrParameterFromAttribute('limit')}`;
716
753
  }
717
754
 
718
755
  offset() {
719
756
  if (!this.single.offset) return '';
720
- return `offset ${this.client.parameter(
721
- this.single.offset,
722
- this.builder,
723
- this.bindingsHolder
724
- )}`;
757
+ return `offset ${this._getValueOrParameterFromAttribute('offset')}`;
725
758
  }
726
759
 
727
760
  // Compiles a `delete` query.
@@ -882,7 +915,23 @@ class QueryCompiler {
882
915
  // Where Clause
883
916
  // ------
884
917
 
885
- whereIn(statement) {
918
+ _valueClause(statement) {
919
+ return statement.asColumn
920
+ ? wrap_(
921
+ statement.value,
922
+ undefined,
923
+ this.builder,
924
+ this.client,
925
+ this.bindingsHolder
926
+ )
927
+ : this.client.parameter(
928
+ statement.value,
929
+ this.builder,
930
+ this.bindingsHolder
931
+ );
932
+ }
933
+
934
+ _columnClause(statement) {
886
935
  let columns;
887
936
  if (Array.isArray(statement.column)) {
888
937
  columns = `(${columnize_(
@@ -900,13 +949,33 @@ class QueryCompiler {
900
949
  this.bindingsHolder
901
950
  );
902
951
  }
952
+ return columns;
953
+ }
903
954
 
955
+ whereIn(statement) {
904
956
  const values = this.client.values(
905
957
  statement.value,
906
958
  this.builder,
907
959
  this.bindingsHolder
908
960
  );
909
- return `${columns} ${this._not(statement, 'in ')}${values}`;
961
+ return `${this._columnClause(statement)} ${this._not(
962
+ statement,
963
+ 'in '
964
+ )}${values}`;
965
+ }
966
+
967
+ whereLike(statement) {
968
+ return `${this._columnClause(statement)} ${this._not(
969
+ statement,
970
+ 'like '
971
+ )}${this._valueClause(statement)}`;
972
+ }
973
+
974
+ whereILike(statement) {
975
+ return `${this._columnClause(statement)} ${this._not(
976
+ statement,
977
+ 'ilike '
978
+ )}${this._valueClause(statement)}`;
910
979
  }
911
980
 
912
981
  whereNull(statement) {
@@ -942,19 +1011,7 @@ class QueryCompiler {
942
1011
  this.bindingsHolder
943
1012
  ) +
944
1013
  ' ' +
945
- (statement.asColumn
946
- ? wrap_(
947
- statement.value,
948
- undefined,
949
- this.builder,
950
- this.client,
951
- this.bindingsHolder
952
- )
953
- : this.client.parameter(
954
- statement.value,
955
- this.builder,
956
- this.bindingsHolder
957
- ))
1014
+ this._valueClause(statement)
958
1015
  );
959
1016
  }
960
1017
 
@@ -1018,11 +1075,37 @@ class QueryCompiler {
1018
1075
  );
1019
1076
  }
1020
1077
 
1078
+ _jsonWrapValue(jsonValue) {
1079
+ if (!this.builder._isJsonObject(jsonValue)) {
1080
+ try {
1081
+ return JSON.stringify(JSON.parse(jsonValue.replace(/\n|\t/g, '')));
1082
+ } catch (e) {
1083
+ return jsonValue;
1084
+ }
1085
+ }
1086
+ return JSON.stringify(jsonValue);
1087
+ }
1088
+
1089
+ _jsonValueClause(statement) {
1090
+ statement.value = this._jsonWrapValue(statement.value);
1091
+ return this._valueClause(statement);
1092
+ }
1093
+
1094
+ whereJsonObject(statement) {
1095
+ return `${this._columnClause(statement)} ${
1096
+ statement.not ? '!=' : '='
1097
+ } ${this._jsonValueClause(statement)}`;
1098
+ }
1099
+
1021
1100
  wrap(str) {
1022
1101
  if (str.charAt(0) !== '(') return `(${str})`;
1023
1102
  return str;
1024
1103
  }
1025
1104
 
1105
+ json(stmt) {
1106
+ return this[stmt.method](stmt.params);
1107
+ }
1108
+
1026
1109
  analytic(stmt) {
1027
1110
  let sql = '';
1028
1111
  const self = this;
@@ -1097,6 +1180,12 @@ class QueryCompiler {
1097
1180
  ) +
1098
1181
  ')'
1099
1182
  : '';
1183
+ const materialized =
1184
+ statement.materialized === undefined
1185
+ ? ''
1186
+ : statement.materialized
1187
+ ? 'materialized '
1188
+ : 'not materialized ';
1100
1189
  return (
1101
1190
  (val &&
1102
1191
  columnize_(
@@ -1106,7 +1195,9 @@ class QueryCompiler {
1106
1195
  this.bindingsHolder
1107
1196
  ) +
1108
1197
  columnList +
1109
- ' as (' +
1198
+ ' as ' +
1199
+ materialized +
1200
+ '(' +
1110
1201
  val +
1111
1202
  ')') ||
1112
1203
  ''
@@ -1235,8 +1326,9 @@ class QueryCompiler {
1235
1326
  nullOrder = ' is not null';
1236
1327
  }
1237
1328
 
1329
+ let groupOrder;
1238
1330
  if (value instanceof Raw) {
1239
- return unwrapRaw_(
1331
+ groupOrder = unwrapRaw_(
1240
1332
  value,
1241
1333
  undefined,
1242
1334
  this.builder,
@@ -1244,10 +1336,46 @@ class QueryCompiler {
1244
1336
  this.bindingsHolder
1245
1337
  );
1246
1338
  } else if (value instanceof QueryBuilder || nulls) {
1247
- return '(' + formatter.columnize(value) + nullOrder + ')';
1339
+ groupOrder = '(' + formatter.columnize(value) + nullOrder + ')';
1248
1340
  } else {
1249
- return formatter.columnize(value);
1341
+ groupOrder = formatter.columnize(value);
1250
1342
  }
1343
+ return groupOrder;
1344
+ }
1345
+
1346
+ _basicGroupOrder(item, type) {
1347
+ const column = this._formatGroupsItemValue(item.value, item.nulls);
1348
+ const direction =
1349
+ type === 'order' && item.type !== 'orderByRaw'
1350
+ ? ` ${direction_(
1351
+ item.direction,
1352
+ this.builder,
1353
+ this.client,
1354
+ this.bindingsHolder
1355
+ )}`
1356
+ : '';
1357
+ return column + direction;
1358
+ }
1359
+
1360
+ _groupOrder(item, type) {
1361
+ return this._basicGroupOrder(item, type);
1362
+ }
1363
+
1364
+ _groupOrderNulls(item, type) {
1365
+ const column = this._formatGroupsItemValue(item.value);
1366
+ const direction =
1367
+ type === 'order' && item.type !== 'orderByRaw'
1368
+ ? ` ${direction_(
1369
+ item.direction,
1370
+ this.builder,
1371
+ this.client,
1372
+ this.bindingsHolder
1373
+ )}`
1374
+ : '';
1375
+ if (item.nulls && !(item.value instanceof Raw)) {
1376
+ return `${column}${direction ? direction : ''} nulls ${item.nulls}`;
1377
+ }
1378
+ return column + direction;
1251
1379
  }
1252
1380
 
1253
1381
  // Compiles the `order by` statements.
@@ -1255,17 +1383,7 @@ class QueryCompiler {
1255
1383
  const items = this.grouped[type];
1256
1384
  if (!items) return '';
1257
1385
  const sql = items.map((item) => {
1258
- const column = this._formatGroupsItemValue(item.value, item.nulls);
1259
- const direction =
1260
- type === 'order' && item.type !== 'orderByRaw'
1261
- ? ` ${direction_(
1262
- item.direction,
1263
- this.builder,
1264
- this.client,
1265
- this.bindingsHolder
1266
- )}`
1267
- : '';
1268
- return column + direction;
1386
+ return this._groupOrder(item, type);
1269
1387
  });
1270
1388
  return sql.length ? type + ' by ' + sql.join(', ') : '';
1271
1389
  }
@@ -1301,6 +1419,112 @@ class QueryCompiler {
1301
1419
  }
1302
1420
  return this._tableName;
1303
1421
  }
1422
+
1423
+ _jsonPathWrap(extraction) {
1424
+ return this.client.parameter(
1425
+ extraction.path || extraction[1],
1426
+ this.builder,
1427
+ this.bindingsHolder
1428
+ );
1429
+ }
1430
+
1431
+ // Json common functions
1432
+ _jsonExtract(nameFunction, params) {
1433
+ let extractions;
1434
+ if (Array.isArray(params.column)) {
1435
+ extractions = params.column;
1436
+ } else {
1437
+ extractions = [params];
1438
+ }
1439
+ if (!Array.isArray(nameFunction)) {
1440
+ nameFunction = [nameFunction];
1441
+ }
1442
+ return extractions
1443
+ .map((extraction) => {
1444
+ let jsonCol = `${columnize_(
1445
+ extraction.column || extraction[0],
1446
+ this.builder,
1447
+ this.client,
1448
+ this.bindingsHolder
1449
+ )}, ${this._jsonPathWrap(extraction)}`;
1450
+ nameFunction.forEach((f) => {
1451
+ jsonCol = f + '(' + jsonCol + ')';
1452
+ });
1453
+ const alias = extraction.alias || extraction[2];
1454
+ return alias
1455
+ ? this.client.alias(jsonCol, this.formatter.wrap(alias))
1456
+ : jsonCol;
1457
+ })
1458
+ .join(', ');
1459
+ }
1460
+
1461
+ _jsonSet(nameFunction, params) {
1462
+ const jsonSet = `${nameFunction}(${columnize_(
1463
+ params.column,
1464
+ this.builder,
1465
+ this.client,
1466
+ this.bindingsHolder
1467
+ )}, ${this.client.parameter(
1468
+ params.path,
1469
+ this.builder,
1470
+ this.bindingsHolder
1471
+ )}, ${this.client.parameter(
1472
+ params.value,
1473
+ this.builder,
1474
+ this.bindingsHolder
1475
+ )})`;
1476
+ return params.alias
1477
+ ? this.client.alias(jsonSet, this.formatter.wrap(params.alias))
1478
+ : jsonSet;
1479
+ }
1480
+
1481
+ _whereJsonPath(nameFunction, statement) {
1482
+ return `${nameFunction}(${this._columnClause(
1483
+ statement
1484
+ )}, ${this._jsonPathWrap({ path: statement.jsonPath })}) ${operator_(
1485
+ statement.operator,
1486
+ this.builder,
1487
+ this.client,
1488
+ this.bindingsHolder
1489
+ )} ${this._jsonValueClause(statement)}`;
1490
+ }
1491
+
1492
+ _onJsonPathEquals(nameJoinFunction, clause) {
1493
+ return (
1494
+ nameJoinFunction +
1495
+ '(' +
1496
+ wrap_(
1497
+ clause.columnFirst,
1498
+ undefined,
1499
+ this.builder,
1500
+ this.client,
1501
+ this.bindingsHolder
1502
+ ) +
1503
+ ', ' +
1504
+ this.client.parameter(
1505
+ clause.jsonPathFirst,
1506
+ this.builder,
1507
+ this.bindingsHolder
1508
+ ) +
1509
+ ') = ' +
1510
+ nameJoinFunction +
1511
+ '(' +
1512
+ wrap_(
1513
+ clause.columnSecond,
1514
+ undefined,
1515
+ this.builder,
1516
+ this.client,
1517
+ this.bindingsHolder
1518
+ ) +
1519
+ ', ' +
1520
+ this.client.parameter(
1521
+ clause.jsonPathSecond,
1522
+ this.builder,
1523
+ this.bindingsHolder
1524
+ ) +
1525
+ ')'
1526
+ );
1527
+ }
1304
1528
  }
1305
1529
 
1306
1530
  module.exports = QueryCompiler;
@@ -42,6 +42,14 @@ const modifiers = [
42
42
  'after',
43
43
  'comment',
44
44
  'collate',
45
+ 'check',
46
+ 'checkPositive',
47
+ 'checkNegative',
48
+ 'checkIn',
49
+ 'checkNotIn',
50
+ 'checkBetween',
51
+ 'checkLength',
52
+ 'checkRegex',
45
53
  ];
46
54
 
47
55
  // Aliases for convenience.
@@ -102,8 +110,13 @@ AlterMethods.alterType = function (type) {
102
110
  };
103
111
 
104
112
  // Set column method to alter (default is add).
105
- AlterMethods.alter = function () {
113
+ AlterMethods.alter = function ({
114
+ alterNullable = true,
115
+ alterType = true,
116
+ } = {}) {
106
117
  this._method = 'alter';
118
+ this.alterNullable = alterNullable;
119
+ this.alterType = alterType;
107
120
 
108
121
  return this;
109
122
  };