kysely 0.17.3 → 0.19.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.
Files changed (114) hide show
  1. package/README.md +24 -17
  2. package/dist/cjs/dialect/database-introspector.d.ts +13 -0
  3. package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +24 -207
  4. package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +26 -3
  5. package/dist/cjs/dialect/mysql/mysql-dialect.js +27 -5
  6. package/dist/cjs/dialect/mysql/mysql-driver.d.ts +13 -4
  7. package/dist/cjs/dialect/mysql/mysql-driver.js +33 -51
  8. package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +11 -1
  9. package/dist/cjs/dialect/mysql/mysql-introspector.js +29 -7
  10. package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +25 -89
  11. package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +25 -5
  12. package/dist/cjs/dialect/postgres/postgres-dialect.js +26 -7
  13. package/dist/cjs/dialect/postgres/postgres-driver.d.ts +12 -3
  14. package/dist/cjs/dialect/postgres/postgres-driver.js +21 -39
  15. package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +11 -1
  16. package/dist/cjs/dialect/postgres/postgres-introspector.js +15 -4
  17. package/dist/cjs/dialect/sqlite/sqlite-dialect-config.d.ts +25 -28
  18. package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +19 -3
  19. package/dist/cjs/dialect/sqlite/sqlite-dialect.js +19 -3
  20. package/dist/cjs/dialect/sqlite/sqlite-driver.js +3 -37
  21. package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +11 -1
  22. package/dist/cjs/dialect/sqlite/sqlite-introspector.js +11 -4
  23. package/dist/cjs/index.d.ts +153 -2
  24. package/dist/cjs/index.js +147 -3
  25. package/dist/cjs/migration/file-migration-provider.d.ts +21 -5
  26. package/dist/cjs/migration/file-migration-provider.js +14 -13
  27. package/dist/cjs/migration/migrator.d.ts +44 -2
  28. package/dist/cjs/migration/migrator.js +77 -18
  29. package/dist/cjs/operation-node/alias-node.d.ts +2 -2
  30. package/dist/cjs/operation-node/alias-node.js +1 -2
  31. package/dist/cjs/operation-node/operation-node-transformer.js +1 -0
  32. package/dist/cjs/operation-node/update-query-node.d.ts +3 -0
  33. package/dist/cjs/operation-node/update-query-node.js +11 -2
  34. package/dist/cjs/parser/reference-parser.js +2 -1
  35. package/dist/cjs/parser/table-parser.js +2 -1
  36. package/dist/cjs/parser/update-set-parser.d.ts +3 -3
  37. package/dist/cjs/parser/with-parser.d.ts +2 -2
  38. package/dist/cjs/plugin/noop-plugin.d.ts +42 -0
  39. package/dist/cjs/plugin/noop-plugin.js +12 -0
  40. package/dist/cjs/query-builder/insert-query-builder.d.ts +1 -1
  41. package/dist/cjs/query-builder/on-conflict-builder.d.ts +1 -1
  42. package/dist/cjs/query-builder/select-query-builder.d.ts +3 -1
  43. package/dist/cjs/query-builder/select-query-builder.js +5 -5
  44. package/dist/cjs/query-builder/update-query-builder.d.ts +57 -28
  45. package/dist/cjs/query-builder/update-query-builder.js +7 -0
  46. package/dist/cjs/query-compiler/default-query-compiler.js +4 -0
  47. package/dist/cjs/query-creator.d.ts +10 -1
  48. package/dist/cjs/query-creator.js +18 -0
  49. package/dist/cjs/raw-builder/raw-builder.d.ts +32 -2
  50. package/dist/cjs/raw-builder/raw-builder.js +5 -26
  51. package/dist/cjs/schema/schema.d.ts +9 -0
  52. package/dist/cjs/schema/schema.js +12 -0
  53. package/dist/cjs/util/column-type.d.ts +9 -1
  54. package/dist/cjs/util/stack-trace-utils.d.ts +1 -0
  55. package/dist/cjs/util/stack-trace-utils.js +17 -0
  56. package/dist/esm/dialect/database-introspector.d.ts +13 -0
  57. package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +24 -207
  58. package/dist/esm/dialect/mysql/mysql-dialect.d.ts +26 -3
  59. package/dist/esm/dialect/mysql/mysql-dialect.js +27 -5
  60. package/dist/esm/dialect/mysql/mysql-driver.d.ts +13 -4
  61. package/dist/esm/dialect/mysql/mysql-driver.js +33 -51
  62. package/dist/esm/dialect/mysql/mysql-introspector.d.ts +11 -1
  63. package/dist/esm/dialect/mysql/mysql-introspector.js +30 -8
  64. package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +25 -89
  65. package/dist/esm/dialect/postgres/postgres-dialect.d.ts +25 -5
  66. package/dist/esm/dialect/postgres/postgres-dialect.js +26 -7
  67. package/dist/esm/dialect/postgres/postgres-driver.d.ts +12 -3
  68. package/dist/esm/dialect/postgres/postgres-driver.js +21 -39
  69. package/dist/esm/dialect/postgres/postgres-introspector.d.ts +11 -1
  70. package/dist/esm/dialect/postgres/postgres-introspector.js +16 -5
  71. package/dist/esm/dialect/sqlite/sqlite-dialect-config.d.ts +25 -28
  72. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +19 -3
  73. package/dist/esm/dialect/sqlite/sqlite-dialect.js +19 -3
  74. package/dist/esm/dialect/sqlite/sqlite-driver.js +4 -38
  75. package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +11 -1
  76. package/dist/esm/dialect/sqlite/sqlite-introspector.js +12 -5
  77. package/dist/esm/index.d.ts +153 -2
  78. package/dist/esm/index.js +142 -2
  79. package/dist/esm/migration/file-migration-provider.d.ts +21 -5
  80. package/dist/esm/migration/file-migration-provider.js +14 -13
  81. package/dist/esm/migration/migrator.d.ts +44 -2
  82. package/dist/esm/migration/migrator.js +76 -17
  83. package/dist/esm/operation-node/alias-node.d.ts +2 -2
  84. package/dist/esm/operation-node/alias-node.js +1 -2
  85. package/dist/esm/operation-node/operation-node-transformer.js +1 -0
  86. package/dist/esm/operation-node/update-query-node.d.ts +3 -0
  87. package/dist/esm/operation-node/update-query-node.js +11 -2
  88. package/dist/esm/parser/reference-parser.js +2 -1
  89. package/dist/esm/parser/table-parser.js +2 -1
  90. package/dist/esm/parser/update-set-parser.d.ts +3 -3
  91. package/dist/esm/parser/with-parser.d.ts +2 -2
  92. package/dist/esm/plugin/noop-plugin.d.ts +42 -0
  93. package/dist/esm/plugin/noop-plugin.js +9 -0
  94. package/dist/esm/query-builder/insert-query-builder.d.ts +1 -1
  95. package/dist/esm/query-builder/on-conflict-builder.d.ts +1 -1
  96. package/dist/esm/query-builder/select-query-builder.d.ts +3 -1
  97. package/dist/esm/query-builder/select-query-builder.js +5 -5
  98. package/dist/esm/query-builder/update-query-builder.d.ts +57 -28
  99. package/dist/esm/query-builder/update-query-builder.js +7 -0
  100. package/dist/esm/query-compiler/default-query-compiler.js +4 -0
  101. package/dist/esm/query-creator.d.ts +10 -1
  102. package/dist/esm/query-creator.js +18 -0
  103. package/dist/esm/raw-builder/raw-builder.d.ts +32 -2
  104. package/dist/esm/raw-builder/raw-builder.js +5 -26
  105. package/dist/esm/schema/schema.d.ts +9 -0
  106. package/dist/esm/schema/schema.js +12 -0
  107. package/dist/esm/util/column-type.d.ts +9 -1
  108. package/dist/esm/util/stack-trace-utils.d.ts +1 -0
  109. package/dist/esm/util/stack-trace-utils.js +14 -0
  110. package/package.json +10 -15
  111. package/dist/cjs/index-nodeless.d.ts +0 -152
  112. package/dist/cjs/index-nodeless.js +0 -153
  113. package/dist/esm/index-nodeless.d.ts +0 -152
  114. package/dist/esm/index-nodeless.js +0 -142
@@ -1,11 +1,162 @@
1
- export * from './index-nodeless.js';
2
- export * from './migration/file-migration-provider.js';
1
+ export * from './kysely.js';
2
+ export * from './query-creator.js';
3
+ export * from './query-builder/where-interface.js';
4
+ export * from './query-builder/join-interface.js';
5
+ export * from './query-builder/returning-interface.js';
6
+ export * from './query-builder/having-interface.js';
7
+ export * from './query-builder/select-query-builder.js';
8
+ export * from './query-builder/insert-query-builder.js';
9
+ export * from './query-builder/update-query-builder.js';
10
+ export * from './query-builder/delete-query-builder.js';
11
+ export * from './query-builder/no-result-error.js';
12
+ export * from './query-builder/join-builder.js';
13
+ export * from './query-builder/expression-builder.js';
14
+ export * from './query-builder/function-builder.js';
15
+ export * from './query-builder/insert-result.js';
16
+ export * from './query-builder/delete-result.js';
17
+ export * from './query-builder/update-result.js';
18
+ export * from './query-builder/on-conflict-builder.js';
19
+ export * from './raw-builder/raw-builder.js';
20
+ export * from './raw-builder/sql.js';
21
+ export * from './query-executor/query-executor.js';
22
+ export * from './query-executor/default-query-executor.js';
23
+ export * from './query-executor/noop-query-executor.js';
24
+ export * from './query-executor/query-executor-provider.js';
25
+ export * from './query-compiler/default-query-compiler.js';
26
+ export * from './query-compiler/compiled-query.js';
27
+ export * from './schema/schema.js';
28
+ export * from './schema/create-table-builder.js';
29
+ export * from './schema/drop-table-builder.js';
30
+ export * from './schema/create-index-builder.js';
31
+ export * from './schema/drop-index-builder.js';
32
+ export * from './schema/create-schema-builder.js';
33
+ export * from './schema/drop-schema-builder.js';
34
+ export * from './schema/column-definition-builder.js';
35
+ export * from './schema/foreign-key-constraint-builder.js';
36
+ export * from './schema/alter-table-builder.js';
37
+ export * from './schema/create-view-builder.js';
38
+ export * from './schema/drop-view-builder.js';
39
+ export * from './dynamic/dynamic.js';
40
+ export * from './driver/driver.js';
41
+ export * from './driver/database-connection.js';
42
+ export * from './driver/connection-provider.js';
43
+ export * from './driver/default-connection-provider.js';
44
+ export * from './driver/single-connection-provider.js';
45
+ export * from './driver/dummy-driver.js';
46
+ export * from './dialect/dialect.js';
47
+ export * from './dialect/dialect-adapter.js';
48
+ export * from './dialect/dialect-adapter-base.js';
49
+ export * from './dialect/database-introspector.js';
3
50
  export * from './dialect/sqlite/sqlite-dialect.js';
4
51
  export * from './dialect/sqlite/sqlite-dialect-config.js';
5
52
  export * from './dialect/sqlite/sqlite-driver.js';
53
+ export * from './dialect/postgres/postgres-query-compiler.js';
54
+ export * from './dialect/postgres/postgres-introspector.js';
55
+ export * from './dialect/postgres/postgres-adapter.js';
6
56
  export * from './dialect/mysql/mysql-dialect.js';
7
57
  export * from './dialect/mysql/mysql-dialect-config.js';
8
58
  export * from './dialect/mysql/mysql-driver.js';
59
+ export * from './dialect/mysql/mysql-query-compiler.js';
60
+ export * from './dialect/mysql/mysql-introspector.js';
61
+ export * from './dialect/mysql/mysql-adapter.js';
9
62
  export * from './dialect/postgres/postgres-driver.js';
10
63
  export * from './dialect/postgres/postgres-dialect-config.js';
11
64
  export * from './dialect/postgres/postgres-dialect.js';
65
+ export * from './dialect/sqlite/sqlite-query-compiler.js';
66
+ export * from './dialect/sqlite/sqlite-introspector.js';
67
+ export * from './dialect/sqlite/sqlite-adapter.js';
68
+ export * from './query-compiler/default-query-compiler.js';
69
+ export * from './query-compiler/query-compiler.js';
70
+ export * from './migration/migrator.js';
71
+ export * from './migration/file-migration-provider.js';
72
+ export * from './plugin/kysely-plugin.js';
73
+ export * from './plugin/camel-case/camel-case-plugin.js';
74
+ export * from './plugin/deduplicate-joins/deduplicate-joins-plugin.js';
75
+ export * from './operation-node/add-column-node.js';
76
+ export * from './operation-node/add-constraint-node.js';
77
+ export * from './operation-node/alias-node.js';
78
+ export * from './operation-node/alter-column-node.js';
79
+ export * from './operation-node/alter-table-node.js';
80
+ export * from './operation-node/and-node.js';
81
+ export * from './operation-node/check-constraint-node.js';
82
+ export * from './operation-node/column-definition-node.js';
83
+ export * from './operation-node/column-node.js';
84
+ export * from './operation-node/column-update-node.js';
85
+ export * from './operation-node/common-table-expression-node.js';
86
+ export * from './operation-node/common-table-expression-name-node.js';
87
+ export * from './operation-node/constraint-node.js';
88
+ export * from './operation-node/create-index-node.js';
89
+ export * from './operation-node/create-schema-node.js';
90
+ export * from './operation-node/create-table-node.js';
91
+ export * from './operation-node/create-view-node.js';
92
+ export * from './operation-node/data-type-node.js';
93
+ export * from './operation-node/default-value-node.js';
94
+ export * from './operation-node/delete-query-node.js';
95
+ export * from './operation-node/drop-column-node.js';
96
+ export * from './operation-node/drop-constraint-node.js';
97
+ export * from './operation-node/drop-index-node.js';
98
+ export * from './operation-node/drop-schema-node.js';
99
+ export * from './operation-node/drop-table-node.js';
100
+ export * from './operation-node/drop-view-node.js';
101
+ export * from './operation-node/filter-node.js';
102
+ export * from './operation-node/foreign-key-constraint-node.js';
103
+ export * from './operation-node/from-node.js';
104
+ export * from './operation-node/generated-node.js';
105
+ export * from './operation-node/group-by-item-node.js';
106
+ export * from './operation-node/group-by-node.js';
107
+ export * from './operation-node/having-node.js';
108
+ export * from './operation-node/identifier-node.js';
109
+ export * from './operation-node/insert-query-node.js';
110
+ export * from './operation-node/join-node.js';
111
+ export * from './operation-node/limit-node.js';
112
+ export * from './operation-node/list-node.js';
113
+ export * from './operation-node/modify-column-node.js';
114
+ export * from './operation-node/offset-node.js';
115
+ export * from './operation-node/on-conflict-node.js';
116
+ export * from './operation-node/on-duplicate-key-node.js';
117
+ export * from './operation-node/on-node.js';
118
+ export * from './operation-node/operation-node-source.js';
119
+ export * from './operation-node/operation-node-transformer.js';
120
+ export * from './operation-node/operation-node-utils.js';
121
+ export * from './operation-node/operation-node-visitor.js';
122
+ export * from './operation-node/operation-node.js';
123
+ export * from './operation-node/operator-node.js';
124
+ export * from './operation-node/or-node.js';
125
+ export * from './operation-node/order-by-item-node.js';
126
+ export * from './operation-node/order-by-node.js';
127
+ export * from './operation-node/parens-node.js';
128
+ export * from './operation-node/primary-constraint-node.js';
129
+ export * from './operation-node/primitive-value-list-node.js';
130
+ export * from './operation-node/query-node.js';
131
+ export * from './operation-node/raw-node.js';
132
+ export * from './operation-node/reference-node.js';
133
+ export * from './operation-node/references-node.js';
134
+ export * from './operation-node/rename-column-node.js';
135
+ export * from './operation-node/returning-node.js';
136
+ export * from './operation-node/select-all-node.js';
137
+ export * from './operation-node/select-query-node.js';
138
+ export * from './operation-node/select-query-node.js';
139
+ export * from './operation-node/selection-node.js';
140
+ export * from './operation-node/table-node.js';
141
+ export * from './operation-node/union-node.js';
142
+ export * from './operation-node/unique-constraint-node.js';
143
+ export * from './operation-node/update-query-node.js';
144
+ export * from './operation-node/value-list-node.js';
145
+ export * from './operation-node/value-node.js';
146
+ export * from './operation-node/values-node.js';
147
+ export * from './operation-node/where-node.js';
148
+ export * from './operation-node/with-node.js';
149
+ export * from './util/column-type.js';
150
+ export * from './util/compilable.js';
151
+ export * from './util/log.js';
152
+ export { AnyColumn, UnknownRow, AnySelectQueryBuilder, } from './util/type-utils.js';
153
+ export { SelectExpression, SelectExpressionOrList, Selection, } from './parser/select-parser.js';
154
+ export { ReferenceExpression, ReferenceExpressionOrList, } from './parser/reference-parser.js';
155
+ export { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
156
+ export { FilterValueExpression, FilterValueExpressionOrList, ExistsExpression, FilterOperator, } from './parser/filter-parser.js';
157
+ export { TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
158
+ export { JoinReferenceExpression, JoinCallbackExpression, } from './parser/join-parser.js';
159
+ export { InsertObject } from './parser/insert-values-parser.js';
160
+ export { MutationObject } from './parser/update-set-parser.js';
161
+ export { OrderByExpression, OrderByDirectionExpression, } from './parser/order-by-parser.js';
162
+ export { UnionExpression } from './parser/union-parser.js';
package/dist/esm/index.js CHANGED
@@ -1,12 +1,152 @@
1
1
  /// <reference types="./index.d.ts" />
2
- export * from './index-nodeless.js';
3
- export * from './migration/file-migration-provider.js';
2
+ export * from './kysely.js';
3
+ export * from './query-creator.js';
4
+ export * from './query-builder/where-interface.js';
5
+ export * from './query-builder/join-interface.js';
6
+ export * from './query-builder/returning-interface.js';
7
+ export * from './query-builder/having-interface.js';
8
+ export * from './query-builder/select-query-builder.js';
9
+ export * from './query-builder/insert-query-builder.js';
10
+ export * from './query-builder/update-query-builder.js';
11
+ export * from './query-builder/delete-query-builder.js';
12
+ export * from './query-builder/no-result-error.js';
13
+ export * from './query-builder/join-builder.js';
14
+ export * from './query-builder/expression-builder.js';
15
+ export * from './query-builder/function-builder.js';
16
+ export * from './query-builder/insert-result.js';
17
+ export * from './query-builder/delete-result.js';
18
+ export * from './query-builder/update-result.js';
19
+ export * from './query-builder/on-conflict-builder.js';
20
+ export * from './raw-builder/raw-builder.js';
21
+ export * from './raw-builder/sql.js';
22
+ export * from './query-executor/query-executor.js';
23
+ export * from './query-executor/default-query-executor.js';
24
+ export * from './query-executor/noop-query-executor.js';
25
+ export * from './query-executor/query-executor-provider.js';
26
+ export * from './query-compiler/default-query-compiler.js';
27
+ export * from './query-compiler/compiled-query.js';
28
+ export * from './schema/schema.js';
29
+ export * from './schema/create-table-builder.js';
30
+ export * from './schema/drop-table-builder.js';
31
+ export * from './schema/create-index-builder.js';
32
+ export * from './schema/drop-index-builder.js';
33
+ export * from './schema/create-schema-builder.js';
34
+ export * from './schema/drop-schema-builder.js';
35
+ export * from './schema/column-definition-builder.js';
36
+ export * from './schema/foreign-key-constraint-builder.js';
37
+ export * from './schema/alter-table-builder.js';
38
+ export * from './schema/create-view-builder.js';
39
+ export * from './schema/drop-view-builder.js';
40
+ export * from './dynamic/dynamic.js';
41
+ export * from './driver/driver.js';
42
+ export * from './driver/database-connection.js';
43
+ export * from './driver/connection-provider.js';
44
+ export * from './driver/default-connection-provider.js';
45
+ export * from './driver/single-connection-provider.js';
46
+ export * from './driver/dummy-driver.js';
47
+ export * from './dialect/dialect.js';
48
+ export * from './dialect/dialect-adapter.js';
49
+ export * from './dialect/dialect-adapter-base.js';
50
+ export * from './dialect/database-introspector.js';
4
51
  export * from './dialect/sqlite/sqlite-dialect.js';
5
52
  export * from './dialect/sqlite/sqlite-dialect-config.js';
6
53
  export * from './dialect/sqlite/sqlite-driver.js';
54
+ export * from './dialect/postgres/postgres-query-compiler.js';
55
+ export * from './dialect/postgres/postgres-introspector.js';
56
+ export * from './dialect/postgres/postgres-adapter.js';
7
57
  export * from './dialect/mysql/mysql-dialect.js';
8
58
  export * from './dialect/mysql/mysql-dialect-config.js';
9
59
  export * from './dialect/mysql/mysql-driver.js';
60
+ export * from './dialect/mysql/mysql-query-compiler.js';
61
+ export * from './dialect/mysql/mysql-introspector.js';
62
+ export * from './dialect/mysql/mysql-adapter.js';
10
63
  export * from './dialect/postgres/postgres-driver.js';
11
64
  export * from './dialect/postgres/postgres-dialect-config.js';
12
65
  export * from './dialect/postgres/postgres-dialect.js';
66
+ export * from './dialect/sqlite/sqlite-query-compiler.js';
67
+ export * from './dialect/sqlite/sqlite-introspector.js';
68
+ export * from './dialect/sqlite/sqlite-adapter.js';
69
+ export * from './query-compiler/default-query-compiler.js';
70
+ export * from './query-compiler/query-compiler.js';
71
+ export * from './migration/migrator.js';
72
+ export * from './migration/file-migration-provider.js';
73
+ export * from './plugin/kysely-plugin.js';
74
+ export * from './plugin/camel-case/camel-case-plugin.js';
75
+ export * from './plugin/deduplicate-joins/deduplicate-joins-plugin.js';
76
+ export * from './operation-node/add-column-node.js';
77
+ export * from './operation-node/add-constraint-node.js';
78
+ export * from './operation-node/alias-node.js';
79
+ export * from './operation-node/alter-column-node.js';
80
+ export * from './operation-node/alter-table-node.js';
81
+ export * from './operation-node/and-node.js';
82
+ export * from './operation-node/check-constraint-node.js';
83
+ export * from './operation-node/column-definition-node.js';
84
+ export * from './operation-node/column-node.js';
85
+ export * from './operation-node/column-update-node.js';
86
+ export * from './operation-node/common-table-expression-node.js';
87
+ export * from './operation-node/common-table-expression-name-node.js';
88
+ export * from './operation-node/constraint-node.js';
89
+ export * from './operation-node/create-index-node.js';
90
+ export * from './operation-node/create-schema-node.js';
91
+ export * from './operation-node/create-table-node.js';
92
+ export * from './operation-node/create-view-node.js';
93
+ export * from './operation-node/data-type-node.js';
94
+ export * from './operation-node/default-value-node.js';
95
+ export * from './operation-node/delete-query-node.js';
96
+ export * from './operation-node/drop-column-node.js';
97
+ export * from './operation-node/drop-constraint-node.js';
98
+ export * from './operation-node/drop-index-node.js';
99
+ export * from './operation-node/drop-schema-node.js';
100
+ export * from './operation-node/drop-table-node.js';
101
+ export * from './operation-node/drop-view-node.js';
102
+ export * from './operation-node/filter-node.js';
103
+ export * from './operation-node/foreign-key-constraint-node.js';
104
+ export * from './operation-node/from-node.js';
105
+ export * from './operation-node/generated-node.js';
106
+ export * from './operation-node/group-by-item-node.js';
107
+ export * from './operation-node/group-by-node.js';
108
+ export * from './operation-node/having-node.js';
109
+ export * from './operation-node/identifier-node.js';
110
+ export * from './operation-node/insert-query-node.js';
111
+ export * from './operation-node/join-node.js';
112
+ export * from './operation-node/limit-node.js';
113
+ export * from './operation-node/list-node.js';
114
+ export * from './operation-node/modify-column-node.js';
115
+ export * from './operation-node/offset-node.js';
116
+ export * from './operation-node/on-conflict-node.js';
117
+ export * from './operation-node/on-duplicate-key-node.js';
118
+ export * from './operation-node/on-node.js';
119
+ export * from './operation-node/operation-node-source.js';
120
+ export * from './operation-node/operation-node-transformer.js';
121
+ export * from './operation-node/operation-node-utils.js';
122
+ export * from './operation-node/operation-node-visitor.js';
123
+ export * from './operation-node/operation-node.js';
124
+ export * from './operation-node/operator-node.js';
125
+ export * from './operation-node/or-node.js';
126
+ export * from './operation-node/order-by-item-node.js';
127
+ export * from './operation-node/order-by-node.js';
128
+ export * from './operation-node/parens-node.js';
129
+ export * from './operation-node/primary-constraint-node.js';
130
+ export * from './operation-node/primitive-value-list-node.js';
131
+ export * from './operation-node/query-node.js';
132
+ export * from './operation-node/raw-node.js';
133
+ export * from './operation-node/reference-node.js';
134
+ export * from './operation-node/references-node.js';
135
+ export * from './operation-node/rename-column-node.js';
136
+ export * from './operation-node/returning-node.js';
137
+ export * from './operation-node/select-all-node.js';
138
+ export * from './operation-node/select-query-node.js';
139
+ export * from './operation-node/select-query-node.js';
140
+ export * from './operation-node/selection-node.js';
141
+ export * from './operation-node/table-node.js';
142
+ export * from './operation-node/union-node.js';
143
+ export * from './operation-node/unique-constraint-node.js';
144
+ export * from './operation-node/update-query-node.js';
145
+ export * from './operation-node/value-list-node.js';
146
+ export * from './operation-node/value-node.js';
147
+ export * from './operation-node/values-node.js';
148
+ export * from './operation-node/where-node.js';
149
+ export * from './operation-node/with-node.js';
150
+ export * from './util/column-type.js';
151
+ export * from './util/compilable.js';
152
+ export * from './util/log.js';
@@ -1,18 +1,23 @@
1
1
  import { Migration, MigrationProvider } from './migrator.js';
2
2
  /**
3
- * Reads all migrations from a folder.
3
+ * Reads all migrations from a folder in node.js.
4
4
  *
5
5
  * ### Examples
6
6
  *
7
7
  * ```ts
8
- * new FileMigrationProvider(
9
- * 'path/to/migrations/folder'
10
- * )
8
+ * import { promises as fs } from 'fs'
9
+ * import path from 'path'
10
+ *
11
+ * new FileMigrationProvider({
12
+ * fs,
13
+ * path,
14
+ * migrationFolder: 'path/to/migrations/folder'
15
+ * })
11
16
  * ```
12
17
  */
13
18
  export declare class FileMigrationProvider implements MigrationProvider {
14
19
  #private;
15
- constructor(migrationFolderPath: string);
20
+ constructor(props: FileMigrationProviderProps);
16
21
  /**
17
22
  * Returns all migrations, old and new.
18
23
  *
@@ -27,3 +32,14 @@ export declare class FileMigrationProvider implements MigrationProvider {
27
32
  */
28
33
  getMigrations(): Promise<Record<string, Migration>>;
29
34
  }
35
+ export interface FileMigrationProviderFS {
36
+ readdir(path: string): Promise<string[]>;
37
+ }
38
+ export interface FileMigrationProviderPath {
39
+ join(...path: string[]): string;
40
+ }
41
+ export interface FileMigrationProviderProps {
42
+ fs: FileMigrationProviderFS;
43
+ path: FileMigrationProviderPath;
44
+ migrationFolder: string;
45
+ }
@@ -1,32 +1,33 @@
1
1
  /// <reference types="./file-migration-provider.d.ts" />
2
2
  import { isFunction, isObject } from '../util/object-utils.js';
3
3
  /**
4
- * Reads all migrations from a folder.
4
+ * Reads all migrations from a folder in node.js.
5
5
  *
6
6
  * ### Examples
7
7
  *
8
8
  * ```ts
9
- * new FileMigrationProvider(
10
- * 'path/to/migrations/folder'
11
- * )
9
+ * import { promises as fs } from 'fs'
10
+ * import path from 'path'
11
+ *
12
+ * new FileMigrationProvider({
13
+ * fs,
14
+ * path,
15
+ * migrationFolder: 'path/to/migrations/folder'
16
+ * })
12
17
  * ```
13
18
  */
14
19
  export class FileMigrationProvider {
15
- #migrationFolderPath;
16
- constructor(migrationFolderPath) {
17
- this.#migrationFolderPath = migrationFolderPath;
20
+ #props;
21
+ constructor(props) {
22
+ this.#props = props;
18
23
  }
19
24
  async getMigrations() {
20
- // Import these dynamically so that we don't have any top level
21
- // node dependencies.
22
- const fs = await import('fs/promises');
23
- const path = await import('path');
24
25
  const migrations = {};
25
- const files = await fs.readdir(this.#migrationFolderPath);
26
+ const files = await this.#props.fs.readdir(this.#props.migrationFolder);
26
27
  for (const fileName of files) {
27
28
  if ((fileName.endsWith('.js') || fileName.endsWith('.ts')) &&
28
29
  !fileName.endsWith('.d.ts')) {
29
- const migration = await import(path.join(this.#migrationFolderPath, fileName));
30
+ const migration = await import(this.#props.path.join(this.#props.migrationFolder, fileName));
30
31
  if (isMigration(migration)) {
31
32
  migrations[fileName.substring(0, fileName.length - 3)] = migration;
32
33
  }
@@ -1,6 +1,6 @@
1
1
  import { Kysely } from '../kysely.js';
2
- export declare const MIGRATION_TABLE = "kysely_migration";
3
- export declare const MIGRATION_LOCK_TABLE = "kysely_migration_lock";
2
+ export declare const DEFAULT_MIGRATION_TABLE = "kysely_migration";
3
+ export declare const DEFAULT_MIGRATION_LOCK_TABLE = "kysely_migration_lock";
4
4
  export declare const MIGRATION_LOCK_ID = "migration_lock";
5
5
  export declare const NO_MIGRATIONS: NoMigrations;
6
6
  export interface Migration {
@@ -148,6 +148,48 @@ export declare class Migrator {
148
148
  export interface MigratorProps {
149
149
  readonly db: Kysely<any>;
150
150
  readonly provider: MigrationProvider;
151
+ /**
152
+ * The name of the internal migration table. Defaults to `kysely_migration`.
153
+ *
154
+ * If you do specify this, you need to ALWAYS use the same value. Kysely doesn't
155
+ * support changing the table on the fly. If you run the migrator even once with a
156
+ * table name X and then change the table name to Y, kysely will create a new empty
157
+ * migration table and attempt to run the migrations again, which will obviously
158
+ * fail.
159
+ *
160
+ * If you do specify this, ALWAYS ALWAYS use the same value from the beginning of
161
+ * the project, to the end of time or prepare to manually migrate the migration
162
+ * tables.
163
+ */
164
+ readonly migrationTableName?: string;
165
+ /**
166
+ * The name of the internal migration lock table. Defaults to `kysely_migration_lock`.
167
+ *
168
+ * If you do specify this, you need to ALWAYS use the same value. Kysely doesn't
169
+ * support changing the table on the fly. If you run the migrator even once with a
170
+ * table name X and then change the table name to Y, kysely will create a new empty
171
+ * lock table.
172
+ *
173
+ * If you do specify this, ALWAYS ALWAYS use the same value from the beginning of
174
+ * the project, to the end of time or prepare to manually migrate the migration
175
+ * tables.
176
+ */
177
+ readonly migrationLockTableName?: string;
178
+ /**
179
+ * The schema of the internal migration tables. Defaults to the default schema
180
+ * on dialects that support schemas.
181
+ *
182
+ * If you do specify this, you need to ALWAYS use the same value. Kysely doesn't
183
+ * support changing the schema on the fly. If you run the migrator even once with a
184
+ * schema name X and then change the schema name to Y, kysely will create a new empty
185
+ * migration tables in the new schema and attempt to run the migrations again, which
186
+ * will obviously fail.
187
+ *
188
+ * If you do specify this, ALWAYS ALWAYS use the same value from the beginning of
189
+ * the project, to the end of time or prepare to manually migrate the migration
190
+ * tables.
191
+ */
192
+ readonly migrationTableSchema?: string;
151
193
  }
152
194
  /**
153
195
  * All migration methods ({@link Migrator.migrateTo | migrateTo},
@@ -1,7 +1,9 @@
1
1
  /// <reference types="./migrator.d.ts" />
2
+ import { NoopPlugin } from '../plugin/noop-plugin.js';
3
+ import { WithSchemaPlugin } from '../plugin/with-schema/with-schema-plugin.js';
2
4
  import { freeze, getLast } from '../util/object-utils.js';
3
- export const MIGRATION_TABLE = 'kysely_migration';
4
- export const MIGRATION_LOCK_TABLE = 'kysely_migration_lock';
5
+ export const DEFAULT_MIGRATION_TABLE = 'kysely_migration';
6
+ export const DEFAULT_MIGRATION_LOCK_TABLE = 'kysely_migration_lock';
5
7
  export const MIGRATION_LOCK_ID = 'migration_lock';
6
8
  export const NO_MIGRATIONS = freeze({ __noMigrations__: true });
7
9
  /**
@@ -35,9 +37,10 @@ export class Migrator {
35
37
  * The returned array is sorted by migration name.
36
38
  */
37
39
  async getMigrations() {
38
- const executedMigrations = (await this.#doesTableExists(MIGRATION_TABLE))
40
+ const executedMigrations = (await this.#doesTableExists(this.#migrationTable))
39
41
  ? await this.#props.db
40
- .selectFrom(MIGRATION_TABLE)
42
+ .withPlugin(this.#schemaPlugin)
43
+ .selectFrom(this.#migrationTable)
41
44
  .select(['name', 'timestamp'])
42
45
  .execute()
43
46
  : [];
@@ -182,16 +185,61 @@ export class Migrator {
182
185
  return { error };
183
186
  }
184
187
  }
188
+ get #migrationTableSchema() {
189
+ return this.#props.migrationTableSchema;
190
+ }
191
+ get #migrationTable() {
192
+ return this.#props.migrationTableName ?? DEFAULT_MIGRATION_TABLE;
193
+ }
194
+ get #migrationLockTable() {
195
+ return this.#props.migrationLockTableName ?? DEFAULT_MIGRATION_LOCK_TABLE;
196
+ }
197
+ get #schemaPlugin() {
198
+ if (this.#migrationTableSchema) {
199
+ return new WithSchemaPlugin(this.#migrationTableSchema);
200
+ }
201
+ return new NoopPlugin();
202
+ }
185
203
  async #ensureMigrationTablesExists() {
204
+ await this.#ensureMigrationTableSchemaExists();
186
205
  await this.#ensureMigrationTableExists();
187
206
  await this.#ensureMigrationLockTableExists();
188
207
  await this.#ensureLockRowExists();
189
208
  }
209
+ async #ensureMigrationTableSchemaExists() {
210
+ if (!this.#migrationTableSchema) {
211
+ // Use default schema. Nothing to do.
212
+ return;
213
+ }
214
+ if (!(await this.#doesSchemaExists())) {
215
+ try {
216
+ await this.#props.db.schema
217
+ .createSchema(this.#migrationTableSchema)
218
+ .ifNotExists()
219
+ .execute();
220
+ }
221
+ catch (error) {
222
+ // At least on PostgreSQL, `if not exists` doesn't guarantee the `create schema`
223
+ // query doesn't throw if the schema already exits. That's why we check if
224
+ // the schema exist here and ignore the error if it does.
225
+ if (!(await this.#doesSchemaExists())) {
226
+ throw error;
227
+ }
228
+ }
229
+ }
230
+ }
190
231
  async #ensureMigrationTableExists() {
191
- if (!(await this.#doesTableExists(MIGRATION_TABLE))) {
232
+ if (!(await this.#doesTableExists(this.#migrationTable))) {
192
233
  try {
234
+ if (this.#migrationTableSchema) {
235
+ await this.#props.db.schema
236
+ .createSchema(this.#migrationTableSchema)
237
+ .ifNotExists()
238
+ .execute();
239
+ }
193
240
  await this.#props.db.schema
194
- .createTable(MIGRATION_TABLE)
241
+ .withPlugin(this.#schemaPlugin)
242
+ .createTable(this.#migrationTable)
195
243
  .ifNotExists()
196
244
  .addColumn('name', 'varchar(255)', (col) => col.notNull().primaryKey())
197
245
  // The migration run time as ISO string. This is not a real date type as we
@@ -203,17 +251,18 @@ export class Migrator {
203
251
  // At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
204
252
  // query doesn't throw if the table already exits. That's why we check if
205
253
  // the table exist here and ignore the error if it does.
206
- if (!(await this.#doesTableExists(MIGRATION_TABLE))) {
254
+ if (!(await this.#doesTableExists(this.#migrationTable))) {
207
255
  throw error;
208
256
  }
209
257
  }
210
258
  }
211
259
  }
212
260
  async #ensureMigrationLockTableExists() {
213
- if (!(await this.#doesTableExists(MIGRATION_LOCK_TABLE))) {
261
+ if (!(await this.#doesTableExists(this.#migrationLockTable))) {
214
262
  try {
215
263
  await this.#props.db.schema
216
- .createTable(MIGRATION_LOCK_TABLE)
264
+ .withPlugin(this.#schemaPlugin)
265
+ .createTable(this.#migrationLockTable)
217
266
  .ifNotExists()
218
267
  .addColumn('id', 'varchar(255)', (col) => col.notNull().primaryKey())
219
268
  .addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0))
@@ -223,7 +272,7 @@ export class Migrator {
223
272
  // At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
224
273
  // query doesn't throw if the table already exits. That's why we check if
225
274
  // the table exist here and ignore the error if it does.
226
- if (!(await this.#doesTableExists(MIGRATION_LOCK_TABLE))) {
275
+ if (!(await this.#doesTableExists(this.#migrationLockTable))) {
227
276
  throw error;
228
277
  }
229
278
  }
@@ -233,7 +282,8 @@ export class Migrator {
233
282
  if (!(await this.#doesLockRowExists())) {
234
283
  try {
235
284
  await this.#props.db
236
- .insertInto(MIGRATION_LOCK_TABLE)
285
+ .withPlugin(this.#schemaPlugin)
286
+ .insertInto(this.#migrationLockTable)
237
287
  .values({ id: MIGRATION_LOCK_ID, is_locked: 0 })
238
288
  .execute();
239
289
  }
@@ -244,15 +294,21 @@ export class Migrator {
244
294
  }
245
295
  }
246
296
  }
297
+ async #doesSchemaExists() {
298
+ const schemas = await this.#props.db.introspection.getSchemas();
299
+ return schemas.some((it) => it.name === this.#migrationTableSchema);
300
+ }
247
301
  async #doesTableExists(tableName) {
248
- const metadata = await this.#props.db.introspection.getMetadata({
302
+ const schema = this.#migrationTableSchema;
303
+ const tables = await this.#props.db.introspection.getTables({
249
304
  withInternalKyselyTables: true,
250
305
  });
251
- return !!metadata.tables.find((it) => it.name === tableName);
306
+ return tables.some((it) => it.name === tableName && (!schema || it.schema === schema));
252
307
  }
253
308
  async #doesLockRowExists() {
254
309
  const lockRow = await this.#props.db
255
- .selectFrom(MIGRATION_LOCK_TABLE)
310
+ .withPlugin(this.#schemaPlugin)
311
+ .selectFrom(this.#migrationLockTable)
256
312
  .where('id', '=', MIGRATION_LOCK_ID)
257
313
  .select('id')
258
314
  .executeTakeFirst();
@@ -310,7 +366,8 @@ export class Migrator {
310
366
  }
311
367
  async #getExecutedMigrations(db) {
312
368
  const executedMigrations = await db
313
- .selectFrom(MIGRATION_TABLE)
369
+ .withPlugin(this.#schemaPlugin)
370
+ .selectFrom(this.#migrationTable)
314
371
  .select('name')
315
372
  .orderBy('name')
316
373
  .execute();
@@ -346,7 +403,8 @@ export class Migrator {
346
403
  if (migration.down) {
347
404
  await migration.down(db);
348
405
  await db
349
- .deleteFrom(MIGRATION_TABLE)
406
+ .withPlugin(this.#schemaPlugin)
407
+ .deleteFrom(this.#migrationTable)
350
408
  .where('name', '=', migration.name)
351
409
  .execute();
352
410
  results[i] = {
@@ -384,7 +442,8 @@ export class Migrator {
384
442
  try {
385
443
  await migration.up(db);
386
444
  await db
387
- .insertInto(MIGRATION_TABLE)
445
+ .withPlugin(this.#schemaPlugin)
446
+ .insertInto(this.#migrationTable)
388
447
  .values({
389
448
  name: migration.name,
390
449
  timestamp: new Date().toISOString(),