kysely 0.12.2 → 0.13.0
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/README.md +34 -10
- package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +2 -2
- package/dist/cjs/dialect/mysql/mysql-adapter.js +2 -1
- package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +2 -2
- package/dist/cjs/dialect/postgres/postgres-adapter.js +2 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/migration/migration.d.ts +154 -11
- package/dist/cjs/migration/migration.js +256 -135
- package/dist/cjs/operation-node/column-definition-node.d.ts +6 -5
- package/dist/cjs/operation-node/column-definition-node.js +0 -4
- package/dist/cjs/operation-node/operation-node-transformer.js +2 -1
- package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +2 -2
- package/dist/cjs/query-compiler/default-query-compiler.js +4 -1
- package/dist/cjs/schema/alter-table-builder.d.ts +12 -0
- package/dist/cjs/schema/alter-table-builder.js +12 -0
- package/dist/cjs/schema/column-definition-builder.d.ts +12 -0
- package/dist/cjs/schema/column-definition-builder.js +4 -1
- package/dist/esm/dialect/mysql/mysql-adapter.d.ts +2 -2
- package/dist/esm/dialect/mysql/mysql-adapter.js +2 -1
- package/dist/esm/dialect/postgres/postgres-adapter.d.ts +2 -2
- package/dist/esm/dialect/postgres/postgres-adapter.js +2 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +2 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/migration/migration.d.ts +154 -11
- package/dist/esm/migration/migration.js +255 -134
- package/dist/esm/operation-node/column-definition-node.d.ts +6 -5
- package/dist/esm/operation-node/column-definition-node.js +0 -4
- package/dist/esm/operation-node/operation-node-transformer.js +2 -1
- package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +2 -2
- package/dist/esm/query-compiler/default-query-compiler.js +4 -1
- package/dist/esm/schema/alter-table-builder.d.ts +12 -0
- package/dist/esm/schema/alter-table-builder.js +12 -0
- package/dist/esm/schema/column-definition-builder.d.ts +12 -0
- package/dist/esm/schema/column-definition-builder.js +4 -1
- package/package.json +1 -1
|
@@ -6,20 +6,21 @@ import { GeneratedAlwaysAsNode } from './generated-always-as-node.js';
|
|
|
6
6
|
import { OperationNode } from './operation-node.js';
|
|
7
7
|
import { RawNode } from './raw-node.js';
|
|
8
8
|
import { ReferencesNode } from './references-node.js';
|
|
9
|
-
export declare type ColumnDefinitionNodeProps = Omit<Partial<ColumnDefinitionNode>, 'kind'>;
|
|
9
|
+
export declare type ColumnDefinitionNodeProps = Omit<Partial<ColumnDefinitionNode>, 'kind' | 'dataType'>;
|
|
10
10
|
export declare type ColumnDataTypeNode = DataTypeNode | RawNode;
|
|
11
11
|
export interface ColumnDefinitionNode extends OperationNode {
|
|
12
12
|
readonly kind: 'ColumnDefinitionNode';
|
|
13
13
|
readonly column: ColumnNode;
|
|
14
14
|
readonly dataType: ColumnDataTypeNode;
|
|
15
15
|
readonly references?: ReferencesNode;
|
|
16
|
-
readonly primaryKey
|
|
17
|
-
readonly autoIncrement
|
|
18
|
-
readonly unique
|
|
19
|
-
readonly
|
|
16
|
+
readonly primaryKey?: boolean;
|
|
17
|
+
readonly autoIncrement?: boolean;
|
|
18
|
+
readonly unique?: boolean;
|
|
19
|
+
readonly notNull?: boolean;
|
|
20
20
|
readonly defaultTo?: DefaultValueNode;
|
|
21
21
|
readonly check?: CheckConstraintNode;
|
|
22
22
|
readonly generatedAlwaysAs?: GeneratedAlwaysAsNode;
|
|
23
|
+
readonly unsigned?: boolean;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* @internal
|
|
@@ -281,7 +281,8 @@ export class OperationNodeTransformer {
|
|
|
281
281
|
primaryKey: node.primaryKey,
|
|
282
282
|
autoIncrement: node.autoIncrement,
|
|
283
283
|
unique: node.unique,
|
|
284
|
-
|
|
284
|
+
notNull: node.notNull,
|
|
285
|
+
unsigned: node.unsigned,
|
|
285
286
|
defaultTo: this.transformNode(node.defaultTo),
|
|
286
287
|
check: this.transformNode(node.check),
|
|
287
288
|
generatedAlwaysAs: this.transformNode(node.generatedAlwaysAs),
|
|
@@ -12,8 +12,8 @@ export interface CamelCasePluginOptions {
|
|
|
12
12
|
upperCase?: boolean;
|
|
13
13
|
/**
|
|
14
14
|
* If true, an underscore is added before each digit when converting
|
|
15
|
-
* camelCase to snake_case. For example `
|
|
16
|
-
* `
|
|
15
|
+
* camelCase to snake_case. For example `foo12Bar => foo_12_bar` and
|
|
16
|
+
* `foo_12_bar => foo12Bar`
|
|
17
17
|
*
|
|
18
18
|
* Defaults to false.
|
|
19
19
|
*/
|
|
@@ -321,6 +321,9 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
321
321
|
this.visitNode(node.column);
|
|
322
322
|
this.append(' ');
|
|
323
323
|
this.visitNode(node.dataType);
|
|
324
|
+
if (node.unsigned) {
|
|
325
|
+
this.append(' unsigned');
|
|
326
|
+
}
|
|
324
327
|
if (node.generatedAlwaysAs) {
|
|
325
328
|
this.append(' ');
|
|
326
329
|
this.visitNode(node.generatedAlwaysAs);
|
|
@@ -329,7 +332,7 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
329
332
|
this.append(' ');
|
|
330
333
|
this.visitNode(node.defaultTo);
|
|
331
334
|
}
|
|
332
|
-
if (
|
|
335
|
+
if (node.notNull) {
|
|
333
336
|
this.append(' not null');
|
|
334
337
|
}
|
|
335
338
|
if (node.unique) {
|
|
@@ -124,6 +124,12 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
|
|
|
124
124
|
* Adds a `not null` constraint for the column.
|
|
125
125
|
*/
|
|
126
126
|
notNull(): AlterTableAddColumnBuilder;
|
|
127
|
+
/**
|
|
128
|
+
* Adds a `unsigned` modifier for the column.
|
|
129
|
+
*
|
|
130
|
+
* This only works on some dialects like MySQL.
|
|
131
|
+
*/
|
|
132
|
+
unsigned(): AlterTableAddColumnBuilder;
|
|
127
133
|
/**
|
|
128
134
|
* Adds a default value constraint for the column.
|
|
129
135
|
*
|
|
@@ -253,6 +259,12 @@ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBu
|
|
|
253
259
|
* Adds a `not null` constraint for the column.
|
|
254
260
|
*/
|
|
255
261
|
notNull(): AlterTableModifyColumnBuilder;
|
|
262
|
+
/**
|
|
263
|
+
* Adds a `unsigned` modifier for the column.
|
|
264
|
+
*
|
|
265
|
+
* This only works on some dialects like MySQL.
|
|
266
|
+
*/
|
|
267
|
+
unsigned(): AlterTableModifyColumnBuilder;
|
|
256
268
|
/**
|
|
257
269
|
* Adds a default value constraint for the column.
|
|
258
270
|
*
|
|
@@ -226,6 +226,12 @@ export class AlterTableAddColumnBuilder {
|
|
|
226
226
|
columnBuilder: this.#props.columnBuilder.notNull(),
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
+
unsigned() {
|
|
230
|
+
return new AlterTableAddColumnBuilder({
|
|
231
|
+
...this.#props,
|
|
232
|
+
columnBuilder: this.#props.columnBuilder.unsigned(),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
229
235
|
defaultTo(value) {
|
|
230
236
|
return new AlterTableAddColumnBuilder({
|
|
231
237
|
...this.#props,
|
|
@@ -309,6 +315,12 @@ export class AlterTableModifyColumnBuilder {
|
|
|
309
315
|
columnBuilder: this.#props.columnBuilder.notNull(),
|
|
310
316
|
});
|
|
311
317
|
}
|
|
318
|
+
unsigned() {
|
|
319
|
+
return new AlterTableModifyColumnBuilder({
|
|
320
|
+
...this.#props,
|
|
321
|
+
columnBuilder: this.#props.columnBuilder.unsigned(),
|
|
322
|
+
});
|
|
323
|
+
}
|
|
312
324
|
defaultTo(value) {
|
|
313
325
|
return new AlterTableModifyColumnBuilder({
|
|
314
326
|
...this.#props,
|
|
@@ -66,6 +66,12 @@ export interface ColumnDefinitionBuilderInterface {
|
|
|
66
66
|
* Adds a `not null` constraint for the column.
|
|
67
67
|
*/
|
|
68
68
|
notNull(): ColumnDefinitionBuilderInterface;
|
|
69
|
+
/**
|
|
70
|
+
* Adds a `unsigned` modifier for the column.
|
|
71
|
+
*
|
|
72
|
+
* This only works on some dialects like MySQL.
|
|
73
|
+
*/
|
|
74
|
+
unsigned(): ColumnDefinitionBuilderInterface;
|
|
69
75
|
/**
|
|
70
76
|
* Adds a default value constraint for the column.
|
|
71
77
|
*
|
|
@@ -189,6 +195,12 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
|
|
|
189
195
|
* Adds a `not null` constraint for the column.
|
|
190
196
|
*/
|
|
191
197
|
notNull(): ColumnDefinitionBuilder;
|
|
198
|
+
/**
|
|
199
|
+
* Adds a `unsigned` modifier for the column.
|
|
200
|
+
*
|
|
201
|
+
* This only works on some dialects like MySQL.
|
|
202
|
+
*/
|
|
203
|
+
unsigned(): ColumnDefinitionBuilder;
|
|
192
204
|
/**
|
|
193
205
|
* Adds a default value constraint for the column.
|
|
194
206
|
*
|
|
@@ -50,7 +50,10 @@ export class ColumnDefinitionBuilder {
|
|
|
50
50
|
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { unique: true }));
|
|
51
51
|
}
|
|
52
52
|
notNull() {
|
|
53
|
-
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|
|
53
|
+
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { notNull: true }));
|
|
54
|
+
}
|
|
55
|
+
unsigned() {
|
|
56
|
+
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { unsigned: true }));
|
|
54
57
|
}
|
|
55
58
|
defaultTo(value) {
|
|
56
59
|
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|