@decocms/mesh 2.20.0 → 2.20.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/dist/client/assets/{AlertCircle-CkNvGXW2.js → AlertCircle-CI2U-jkN.js} +1 -1
- package/dist/client/assets/{ArrowLeft-BsUDOBX0.js → ArrowLeft-B3km7toT.js} +1 -1
- package/dist/client/assets/{ArrowUp-Xq_0RBx_.js → ArrowUp-BF7mM4C2.js} +1 -1
- package/dist/client/assets/{Check-DijrPXQx.js → Check-BQkm1TiP.js} +1 -1
- package/dist/client/assets/{ChevronDown-DASi-DMo.js → ChevronDown-DP6jvip7.js} +1 -1
- package/dist/client/assets/{Code01-C0ZFF6Hl.js → Code01-qXTn9GK9.js} +1 -1
- package/dist/client/assets/{Copy01-BQZg7H8u.js → Copy01-CEYn2daS.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-CjU9uXdh.js → DotsHorizontal-C2Nr-D-f.js} +1 -1
- package/dist/client/assets/{DotsVertical-D6TZm5RT.js → DotsVertical-BPP4U4GQ.js} +1 -1
- package/dist/client/assets/{Download01-BTR8eSV6.js → Download01-BkDXja2z.js} +1 -1
- package/dist/client/assets/{Edit01-BsdLQ-QO.js → Edit01-Cq0mQDLh.js} +1 -1
- package/dist/client/assets/{File06-Bm9rDm48.js → File06-KMD38I-q.js} +1 -1
- package/dist/client/assets/{FilterLines-Dg_ubOas.js → FilterLines-Bojt6HPl.js} +1 -1
- package/dist/client/assets/{FlipBackward-BZkXBjUF.js → FlipBackward-C-K9FamE.js} +1 -1
- package/dist/client/assets/{GitBranch01-DYs19mSG.js → GitBranch01-DGTCzEh5.js} +1 -1
- package/dist/client/assets/{Grid01-CTb93Z2I.js → Grid01-D4lXvveX.js} +1 -1
- package/dist/client/assets/{Home02-CAgSUdC-.js → Home02-DPdZvu8L.js} +1 -1
- package/dist/client/assets/{Image01-CUinB3ac.js → Image01-C0R6SF_P.js} +1 -1
- package/dist/client/assets/{Inbox01-tMW4EgP4.js → Inbox01-BsOUYwQZ.js} +1 -1
- package/dist/client/assets/{InfoCircle-DqeM4n2r.js → InfoCircle-BgIkbjJr.js} +1 -1
- package/dist/client/assets/{Key01-BDVEoltU.js → Key01-DTwk4FpG.js} +1 -1
- package/dist/client/assets/{LinkExternal01-C2ZOZHgx.js → LinkExternal01-DmruqAb9.js} +1 -1
- package/dist/client/assets/{List-jMJevXfS.js → List-BsSZz32j.js} +1 -1
- package/dist/client/assets/{Loading01-6JGza9Vp.js → Loading01-Ae5ezbtD.js} +1 -1
- package/dist/client/assets/{Lock01-DAc7yIAH.js → Lock01-BuQSktMF.js} +1 -1
- package/dist/client/assets/{Play-BWxFDrEk.js → Play-DKlNHVjf.js} +1 -1
- package/dist/client/assets/{Plus-Dcgso5EP.js → Plus-CdG75X26.js} +1 -1
- package/dist/client/assets/{SearchMd-CbnCIalV.js → SearchMd-GFaonOaJ.js} +1 -1
- package/dist/client/assets/{Terminal-DNtUg1U7.js → Terminal-C6mZx-5A.js} +1 -1
- package/dist/client/assets/{Trash01-CzA8mxf_.js → Trash01-BWIN9RL_.js} +1 -1
- package/dist/client/assets/{Upload01-BPJ4Vq2H.js → Upload01-CaBE4VYK.js} +1 -1
- package/dist/client/assets/{X-C7-BOCtk.js → X-C18ho617.js} +1 -1
- package/dist/client/assets/{XClose-COetRF8H.js → XClose-CfwoKknl.js} +1 -1
- package/dist/client/assets/{alert-dialog-Mcf5ObRp.js → alert-dialog-CCJCsKzK.js} +1 -1
- package/dist/client/assets/{auth-catchall-JCvomRO1.js → auth-catchall-C33VWmDE.js} +1 -1
- package/dist/client/assets/{avatar-D0pQKePK.js → avatar-B7xnPXuk.js} +1 -1
- package/dist/client/assets/{badge-9bzwrgbk.js → badge-BVO6I0sW.js} +1 -1
- package/dist/client/assets/{binder-B4r3FJOG.js → binder-By0LBK9Y.js} +1 -1
- package/dist/client/assets/{button-C_Xg9B1B.js → button-CGmrzkpY.js} +1 -1
- package/dist/client/assets/{card-BXLd4InC.js → card-DIjMh1NO.js} +1 -1
- package/dist/client/assets/{checkbox-z9w2qryt.js → checkbox-DYViXeUc.js} +1 -1
- package/dist/client/assets/{collection-detail-zSSQWfP2.js → collection-detail-DtlOJm8P.js} +1 -1
- package/dist/client/assets/{collection-display-button-DNzo_eaI.js → collection-display-button-CtkxsCB_.js} +1 -1
- package/dist/client/assets/{collection-header-DMI-enxo.js → collection-header-B4qcjEt5.js} +1 -1
- package/dist/client/assets/{collection-page-CPVm36im.js → collection-page-s-RR5fU6.js} +1 -1
- package/dist/client/assets/{collection-search-NPXhv3P8.js → collection-search-BVb42O45.js} +1 -1
- package/dist/client/assets/{collection-tab-DoDfK_be.js → collection-tab-CvrhLJCU.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-CH0cDKjW.js → collection-table-wrapper-BohFZqii.js} +1 -1
- package/dist/client/assets/{connection-DoXpv3Ov.js → connection-ChwHK0-S.js} +1 -1
- package/dist/client/assets/{connection-card-zeRxy9uc.js → connection-card-DMMfNQUo.js} +1 -1
- package/dist/client/assets/{connection-detail-vV4L4jYp.js → connection-detail-D9bORT-_.js} +1 -1
- package/dist/client/assets/{connections-DNpwgzUU.js → connections-CRhyn7eO.js} +1 -1
- package/dist/client/assets/constants-J0aH6mLs.js +1 -0
- package/dist/client/assets/{create-organization-dialog-Ro3igzlR.js → create-organization-dialog-CtbMd6S_.js} +1 -1
- package/dist/client/assets/{dialog-C9Agm5JE.js → dialog-DJJ2cvEE.js} +1 -1
- package/dist/client/assets/{dropdown-menu-fQ8f1M5d.js → dropdown-menu-CAeD2aIb.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-B3cv12GM.js → dynamic-plugin-layout-BeSg8wRq.js} +1 -1
- package/dist/client/assets/{empty-state-DdUozeuW.js → empty-state-BkAB-hls.js} +1 -1
- package/dist/client/assets/{empty-state-DBRX3hef.js → empty-state-wP9uukGJ.js} +1 -1
- package/dist/client/assets/{env-vars-editor-BXw6d8cC.js → env-vars-editor-DuH6BBdA.js} +1 -1
- package/dist/client/assets/{error-boundary-yHT4ni_0.js → error-boundary-BUvK8Sry.js} +1 -1
- package/dist/client/assets/{extract-connection-data-PVjaut0P.js → extract-connection-data-BLs0SRok.js} +1 -1
- package/dist/client/assets/{file-browser-Bh7hl3h8.js → file-browser-DuR45yyf.js} +2 -2
- package/dist/client/assets/{form-D_wQlmgT.js → form-DiGzBnRK.js} +1 -1
- package/dist/client/assets/gateway-detail-BCBmyW-G.js +1 -0
- package/dist/client/assets/{gateways-B0QSXg4v.js → gateways-BgSVXbfx.js} +1 -1
- package/dist/client/assets/{grid-view-BsHjiotE.js → grid-view-Db741zGU.js} +1 -1
- package/dist/client/assets/{home-m3uBo7L5.js → home-BtJc_wcZ.js} +1 -1
- package/dist/client/assets/{index-QjJpaT60.js → index-CL_rL7XJ.js} +4 -4
- package/dist/client/assets/{index-Cg8UjPnN.js → index-D4QCsSzb.js} +1 -1
- package/dist/client/assets/index-DUA-vRuy.js +1 -0
- package/dist/client/assets/{index-DZBCLPmz.js → index-Diww4UW3.js} +2 -2
- package/dist/client/assets/{index-3IJwc3nu.js → index-DjRWdLI4.js} +1 -1
- package/dist/client/assets/index-H07QDM93.css +1 -0
- package/dist/client/assets/{infiniteQueryObserver-CB9iuYaY.js → infiniteQueryObserver-BmbQcWdI.js} +1 -1
- package/dist/client/assets/{input-DrOaW48H.js → input-CrURMEZe.js} +1 -1
- package/dist/client/assets/{layout-B4oQiZN6.js → layout-kp8TTJc9.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-CSmD3B45.js → lazy-highlighter-dN3WcL6s.js} +1 -1
- package/dist/client/assets/{localstorage-keys-ColTY5EO.js → localstorage-keys-BVANkONM.js} +1 -1
- package/dist/client/assets/{login-BdRlUNll.js → login-CnuJ6k4x.js} +1 -1
- package/dist/client/assets/{mcp-oauth-CcVuDlog.js → mcp-oauth-CdcIczUJ.js} +1 -1
- package/dist/client/assets/{mcp-server-card-BnclXini.js → mcp-server-card-VZUBDTRj.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-DTSTQPDK.js → mcp-server-detail-CIR0FKMd.js} +1 -1
- package/dist/client/assets/{members-BAse2YpR.js → members-bQTH1spX.js} +1 -1
- package/dist/client/assets/{monaco-editor-BtLswDg1.js → monaco-editor-CDRbE4GY.js} +1 -1
- package/dist/client/assets/{monitoring-FELvrXqN.js → monitoring-Cb41cf-X.js} +1 -1
- package/dist/client/assets/{oauth-callback-sXSk4y6N.js → oauth-callback-z6t0OToi.js} +1 -1
- package/dist/client/assets/{page-IVcVoGr6.js → page-CcKdSzCp.js} +1 -1
- package/dist/client/assets/{page-c25MW39x.js → page-SWPgLEpC.js} +1 -1
- package/dist/client/assets/{pin-to-sidebar-button-D7zfHxC-.js → pin-to-sidebar-button-DIwkO0Tx.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DINK0udh.js → plugin-empty-state-B-glkOMH.js} +1 -1
- package/dist/client/assets/{plugin-header-BaOkI6uW.js → plugin-header-BA0z5mBU.js} +1 -1
- package/dist/client/assets/{plugins-DU28fvG7.js → plugins-Cq62fkYj.js} +1 -1
- package/dist/client/assets/{popover-DDq46px5.js → popover-Bx7diZ86.js} +1 -1
- package/dist/client/assets/{project-context-provider-CwtkfEWe.js → project-context-provider-DulCVL2k.js} +1 -1
- package/dist/client/assets/{registry-utils-nz3H3-qh.js → registry-utils-8Lvx2XTy.js} +1 -1
- package/dist/client/assets/{resizable-ZYLqRZrr.js → resizable-Gk1RjNnW.js} +1 -1
- package/dist/client/assets/{resource-tabs-Dv00g9SH.js → resource-tabs-ACbF96qo.js} +1 -1
- package/dist/client/assets/{select-Cgab7LNB.js → select-C8LOz7vA.js} +1 -1
- package/dist/client/assets/{settings-CUngx_cw.js → settings-BXJ6BGel.js} +1 -1
- package/dist/client/assets/shell-layout-CFRw9Ru3.js +3 -0
- package/dist/client/assets/{spinner-ISlo4YZH.js → spinner-BF56RAKQ.js} +1 -1
- package/dist/client/assets/{switch-BDCe2nGJ.js → switch-DJBd8Fzb.js} +1 -1
- package/dist/client/assets/{textarea-BL4bZEBo.js → textarea-C_zgj3Sp.js} +1 -1
- package/dist/client/assets/{tool-set-selector-CWxawPKU.js → tool-set-selector-B9rTBahU.js} +1 -1
- package/dist/client/assets/{tools-list-BAdvjUaK.js → tools-list-mr-l2d8l.js} +1 -1
- package/dist/client/assets/{tooltip-CpJ7mUzE.js → tooltip-Suu_Gpqh.js} +1 -1
- package/dist/client/assets/{typewriter-title-vVGiDyZ3.js → typewriter-title-DM-oRxie.js} +1 -1
- package/dist/client/assets/{use-binding-DGnotkAI.js → use-binding-D6wv_5fO.js} +1 -1
- package/dist/client/assets/{use-collections-BmF5uRR6.js → use-collections-CXETocKO.js} +1 -1
- package/dist/client/assets/{use-connection-CD3KQhdl.js → use-connection-CCXutWLD.js} +1 -1
- package/dist/client/assets/{use-connection-resources-Bk8Paqb0.js → use-connection-resources-D0st76bP.js} +1 -1
- package/dist/client/assets/{use-create-gateway-Buvj1BPg.js → use-create-gateway-BlLsktgc.js} +1 -1
- package/dist/client/assets/{use-gateway-HT97xIYl.js → use-gateway-DD-xEZju.js} +1 -1
- package/dist/client/assets/{use-gateway-system-prompt-DPiQIOlu.js → use-gateway-system-prompt-zGJSEzce.js} +1 -1
- package/dist/client/assets/{use-list-state-DceT21J-.js → use-list-state-AndcW8aD.js} +1 -1
- package/dist/client/assets/{use-mcp-C2xjgZVM.js → use-mcp-D9llr83X.js} +1 -1
- package/dist/client/assets/{use-members-D-h9QOxK.js → use-members-CB2ebBfn.js} +1 -1
- package/dist/client/assets/{use-mobile-BH2x5CB1.js → use-mobile-DssCtDl6.js} +1 -1
- package/dist/client/assets/{use-organization-settings-BMsrsPvw.js → use-organization-settings-CQXtXtZs.js} +1 -1
- package/dist/client/assets/{use-tool-call-BmQnCqef.js → use-tool-call-BmvKn7jp.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-BttwTOfK.js +1 -0
- package/dist/client/assets/{useMutation-DV6K6Nze.js → useMutation-Dl1MMkEC.js} +1 -1
- package/dist/client/assets/useQuery-Bvk0U2ed.js +1 -0
- package/dist/client/assets/{value-BiYWDF0x.js → value-DaPOjTmC.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-DPk8_aIn.js → view-mode-toggle-BLClM-0g.js} +1 -1
- package/dist/client/assets/{workflow-B_8Qc7GH.js → workflow-CQ7PQ7Dg.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +1 -1
- package/dist/server/node_modules/kysely/README.md +3 -1
- package/dist/server/node_modules/kysely/dist/cjs/index.d.ts +3 -1
- package/dist/server/node_modules/kysely/dist/cjs/migration/migrator.d.ts +1 -1
- package/dist/server/node_modules/kysely/dist/cjs/migration/migrator.js +75 -68
- package/dist/server/node_modules/kysely/dist/esm/index.d.ts +3 -1
- package/dist/server/node_modules/kysely/dist/esm/migration/migrator.d.ts +1 -1
- package/dist/server/node_modules/kysely/dist/esm/migration/migrator.js +75 -68
- package/dist/server/node_modules/kysely/package.json +13 -13
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/constants-CBp9PjFO.js +0 -1
- package/dist/client/assets/gateway-detail-B6I6y-jz.js +0 -1
- package/dist/client/assets/index-Dh9ePU0t.css +0 -1
- package/dist/client/assets/index-DiisCGqz.js +0 -1
- package/dist/client/assets/shell-layout-IdYGAQZJ.js +0 -3
- package/dist/client/assets/useInfiniteQuery-hrzJXDha.js +0 -1
- package/dist/client/assets/useQuery-mZS4-X0F.js +0 -1
|
@@ -58,7 +58,8 @@ class Migrator {
|
|
|
58
58
|
* The returned array is sorted by migration name.
|
|
59
59
|
*/
|
|
60
60
|
async getMigrations() {
|
|
61
|
-
const
|
|
61
|
+
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
62
|
+
const executedMigrations = tableExists
|
|
62
63
|
? await this.#props.db
|
|
63
64
|
.withPlugin(this.#schemaPlugin)
|
|
64
65
|
.selectFrom(this.#migrationTable)
|
|
@@ -265,7 +266,10 @@ class Migrator {
|
|
|
265
266
|
}
|
|
266
267
|
async #migrate(getMigrationDirectionAndStep) {
|
|
267
268
|
try {
|
|
268
|
-
await this.#
|
|
269
|
+
await this.#ensureMigrationTableSchemaExists();
|
|
270
|
+
await this.#ensureMigrationTableExists();
|
|
271
|
+
await this.#ensureMigrationLockTableExists();
|
|
272
|
+
await this.#ensureLockRowExists();
|
|
269
273
|
return await this.#runMigrations(getMigrationDirectionAndStep);
|
|
270
274
|
}
|
|
271
275
|
catch (error) {
|
|
@@ -293,95 +297,98 @@ class Migrator {
|
|
|
293
297
|
}
|
|
294
298
|
return new noop_plugin_js_1.NoopPlugin();
|
|
295
299
|
}
|
|
296
|
-
async #ensureMigrationTablesExists() {
|
|
297
|
-
await this.#ensureMigrationTableSchemaExists();
|
|
298
|
-
await this.#ensureMigrationTableExists();
|
|
299
|
-
await this.#ensureMigrationLockTableExists();
|
|
300
|
-
await this.#ensureLockRowExists();
|
|
301
|
-
}
|
|
302
300
|
async #ensureMigrationTableSchemaExists() {
|
|
303
301
|
if (!this.#migrationTableSchema) {
|
|
304
302
|
// Use default schema. Nothing to do.
|
|
305
303
|
return;
|
|
306
304
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
305
|
+
const schemaExists = await this.#doesSchemaExist();
|
|
306
|
+
if (schemaExists) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
await this.#createIfNotExists(this.#props.db.schema.createSchema(this.#migrationTableSchema));
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
const schemaExists = await this.#doesSchemaExist();
|
|
314
|
+
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create schema`
|
|
315
|
+
// query doesn't throw if the schema already exits. That's why we check if
|
|
316
|
+
// the schema exist here and ignore the error if it does.
|
|
317
|
+
if (!schemaExists) {
|
|
318
|
+
throw error;
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
async #ensureMigrationTableExists() {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
323
|
+
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
324
|
+
if (tableExists) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
await this.#createIfNotExists(this.#props.db.schema
|
|
329
|
+
.withPlugin(this.#schemaPlugin)
|
|
330
|
+
.createTable(this.#migrationTable)
|
|
331
|
+
.addColumn('name', 'varchar(255)', (col) => col.notNull().primaryKey())
|
|
332
|
+
// The migration run time as ISO string. This is not a real date type as we
|
|
333
|
+
// can't know which data type is supported by all future dialects.
|
|
334
|
+
.addColumn('timestamp', 'varchar(255)', (col) => col.notNull()));
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
338
|
+
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
|
|
339
|
+
// query doesn't throw if the table already exits. That's why we check if
|
|
340
|
+
// the table exist here and ignore the error if it does.
|
|
341
|
+
if (!tableExists) {
|
|
342
|
+
throw error;
|
|
342
343
|
}
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
async #ensureMigrationLockTableExists() {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
347
|
+
const tableExists = await this.#doesTableExist(this.#migrationLockTable);
|
|
348
|
+
if (tableExists) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
await this.#createIfNotExists(this.#props.db.schema
|
|
353
|
+
.withPlugin(this.#schemaPlugin)
|
|
354
|
+
.createTable(this.#migrationLockTable)
|
|
355
|
+
.addColumn('id', 'varchar(255)', (col) => col.notNull().primaryKey())
|
|
356
|
+
.addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0)));
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
const tableExists = await this.#doesTableExist(this.#migrationLockTable);
|
|
360
|
+
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
|
|
361
|
+
// query doesn't throw if the table already exits. That's why we check if
|
|
362
|
+
// the table exist here and ignore the error if it does.
|
|
363
|
+
if (!tableExists) {
|
|
364
|
+
throw error;
|
|
361
365
|
}
|
|
362
366
|
}
|
|
363
367
|
}
|
|
364
368
|
async #ensureLockRowExists() {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
const lockRowExists = await this.#doesLockRowExists();
|
|
370
|
+
if (lockRowExists) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
await this.#props.db
|
|
375
|
+
.withPlugin(this.#schemaPlugin)
|
|
376
|
+
.insertInto(this.#migrationLockTable)
|
|
377
|
+
.values({ id: exports.MIGRATION_LOCK_ID, is_locked: 0 })
|
|
378
|
+
.execute();
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
const lockRowExists = await this.#doesLockRowExists();
|
|
382
|
+
if (!lockRowExists) {
|
|
383
|
+
throw error;
|
|
377
384
|
}
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
|
-
async #
|
|
387
|
+
async #doesSchemaExist() {
|
|
381
388
|
const schemas = await this.#props.db.introspection.getSchemas();
|
|
382
389
|
return schemas.some((it) => it.name === this.#migrationTableSchema);
|
|
383
390
|
}
|
|
384
|
-
async #
|
|
391
|
+
async #doesTableExist(tableName) {
|
|
385
392
|
const schema = this.#migrationTableSchema;
|
|
386
393
|
const tables = await this.#props.db.introspection.getTables({
|
|
387
394
|
withInternalKyselyTables: true,
|
|
@@ -206,10 +206,11 @@ export * from './util/compilable.js';
|
|
|
206
206
|
export * from './util/explainable.js';
|
|
207
207
|
export * from './util/streamable.js';
|
|
208
208
|
export * from './util/log.js';
|
|
209
|
-
export type { AnyAliasedColumn, AnyAliasedColumnWithTable, AnyColumn, AnyColumnWithTable, Equals, UnknownRow, Simplify, SqlBool, Nullable, NumbersWhenDataTypeNotAvailable, NotNull, NumericString, ShallowDehydrateObject, ShallowDehydrateValue, StringsWhenDataTypeNotAvailable, } from './util/type-utils.js';
|
|
209
|
+
export type { AnyAliasedColumn, AnyAliasedColumnWithTable, AnyColumn, AnyColumnWithTable, DrainOuterGeneric, Equals, ExtractColumnType, UnknownRow, Simplify, SqlBool, Nullable, NumbersWhenDataTypeNotAvailable, NotNull, NumericString, ShallowDehydrateObject, ShallowDehydrateValue, SimplifyResult, SimplifySingleResult, StringsWhenDataTypeNotAvailable, } from './util/type-utils.js';
|
|
210
210
|
export * from './util/infer-result.js';
|
|
211
211
|
export { logOnce } from './util/log-once.js';
|
|
212
212
|
export { createQueryId, type QueryId } from './util/query-id.js';
|
|
213
|
+
export type { KyselyTypeError } from './util/type-error.js';
|
|
213
214
|
export type { SelectExpression, SelectCallback, SelectArg, Selection, CallbackSelection, } from './parser/select-parser.js';
|
|
214
215
|
export type { ReferenceExpression, ReferenceExpressionOrList, SimpleReferenceExpression, StringReference, ExtractTypeFromStringReference, ExtractTypeFromReferenceExpression, } from './parser/reference-parser.js';
|
|
215
216
|
export type { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
|
|
@@ -222,3 +223,4 @@ export type { ComparisonOperatorExpression, OperandValueExpression, OperandValue
|
|
|
222
223
|
export type { ExistsExpression } from './parser/unary-operation-parser.js';
|
|
223
224
|
export type { OperandExpression, ExpressionOrFactory, } from './parser/expression-parser.js';
|
|
224
225
|
export type { Collation } from './parser/collate-parser.js';
|
|
226
|
+
export type { QueryCreatorWithCommonTableExpression } from './parser/with-parser.js';
|
|
@@ -263,7 +263,7 @@ export interface MigratorProps {
|
|
|
263
263
|
* the project, to the end of time or prepare to manually migrate the migration
|
|
264
264
|
* tables.
|
|
265
265
|
*
|
|
266
|
-
* This only works on postgres.
|
|
266
|
+
* This only works on postgres and mssql.
|
|
267
267
|
*/
|
|
268
268
|
readonly migrationTableSchema?: string;
|
|
269
269
|
/**
|
|
@@ -56,7 +56,8 @@ export class Migrator {
|
|
|
56
56
|
* The returned array is sorted by migration name.
|
|
57
57
|
*/
|
|
58
58
|
async getMigrations() {
|
|
59
|
-
const
|
|
59
|
+
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
60
|
+
const executedMigrations = tableExists
|
|
60
61
|
? await this.#props.db
|
|
61
62
|
.withPlugin(this.#schemaPlugin)
|
|
62
63
|
.selectFrom(this.#migrationTable)
|
|
@@ -263,7 +264,10 @@ export class Migrator {
|
|
|
263
264
|
}
|
|
264
265
|
async #migrate(getMigrationDirectionAndStep) {
|
|
265
266
|
try {
|
|
266
|
-
await this.#
|
|
267
|
+
await this.#ensureMigrationTableSchemaExists();
|
|
268
|
+
await this.#ensureMigrationTableExists();
|
|
269
|
+
await this.#ensureMigrationLockTableExists();
|
|
270
|
+
await this.#ensureLockRowExists();
|
|
267
271
|
return await this.#runMigrations(getMigrationDirectionAndStep);
|
|
268
272
|
}
|
|
269
273
|
catch (error) {
|
|
@@ -291,95 +295,98 @@ export class Migrator {
|
|
|
291
295
|
}
|
|
292
296
|
return new NoopPlugin();
|
|
293
297
|
}
|
|
294
|
-
async #ensureMigrationTablesExists() {
|
|
295
|
-
await this.#ensureMigrationTableSchemaExists();
|
|
296
|
-
await this.#ensureMigrationTableExists();
|
|
297
|
-
await this.#ensureMigrationLockTableExists();
|
|
298
|
-
await this.#ensureLockRowExists();
|
|
299
|
-
}
|
|
300
298
|
async #ensureMigrationTableSchemaExists() {
|
|
301
299
|
if (!this.#migrationTableSchema) {
|
|
302
300
|
// Use default schema. Nothing to do.
|
|
303
301
|
return;
|
|
304
302
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
303
|
+
const schemaExists = await this.#doesSchemaExist();
|
|
304
|
+
if (schemaExists) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
await this.#createIfNotExists(this.#props.db.schema.createSchema(this.#migrationTableSchema));
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
const schemaExists = await this.#doesSchemaExist();
|
|
312
|
+
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create schema`
|
|
313
|
+
// query doesn't throw if the schema already exits. That's why we check if
|
|
314
|
+
// the schema exist here and ignore the error if it does.
|
|
315
|
+
if (!schemaExists) {
|
|
316
|
+
throw error;
|
|
316
317
|
}
|
|
317
318
|
}
|
|
318
319
|
}
|
|
319
320
|
async #ensureMigrationTableExists() {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
321
|
+
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
322
|
+
if (tableExists) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
await this.#createIfNotExists(this.#props.db.schema
|
|
327
|
+
.withPlugin(this.#schemaPlugin)
|
|
328
|
+
.createTable(this.#migrationTable)
|
|
329
|
+
.addColumn('name', 'varchar(255)', (col) => col.notNull().primaryKey())
|
|
330
|
+
// The migration run time as ISO string. This is not a real date type as we
|
|
331
|
+
// can't know which data type is supported by all future dialects.
|
|
332
|
+
.addColumn('timestamp', 'varchar(255)', (col) => col.notNull()));
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
336
|
+
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
|
|
337
|
+
// query doesn't throw if the table already exits. That's why we check if
|
|
338
|
+
// the table exist here and ignore the error if it does.
|
|
339
|
+
if (!tableExists) {
|
|
340
|
+
throw error;
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
}
|
|
343
344
|
async #ensureMigrationLockTableExists() {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
345
|
+
const tableExists = await this.#doesTableExist(this.#migrationLockTable);
|
|
346
|
+
if (tableExists) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
try {
|
|
350
|
+
await this.#createIfNotExists(this.#props.db.schema
|
|
351
|
+
.withPlugin(this.#schemaPlugin)
|
|
352
|
+
.createTable(this.#migrationLockTable)
|
|
353
|
+
.addColumn('id', 'varchar(255)', (col) => col.notNull().primaryKey())
|
|
354
|
+
.addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0)));
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
const tableExists = await this.#doesTableExist(this.#migrationLockTable);
|
|
358
|
+
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
|
|
359
|
+
// query doesn't throw if the table already exits. That's why we check if
|
|
360
|
+
// the table exist here and ignore the error if it does.
|
|
361
|
+
if (!tableExists) {
|
|
362
|
+
throw error;
|
|
359
363
|
}
|
|
360
364
|
}
|
|
361
365
|
}
|
|
362
366
|
async #ensureLockRowExists() {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
367
|
+
const lockRowExists = await this.#doesLockRowExists();
|
|
368
|
+
if (lockRowExists) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
await this.#props.db
|
|
373
|
+
.withPlugin(this.#schemaPlugin)
|
|
374
|
+
.insertInto(this.#migrationLockTable)
|
|
375
|
+
.values({ id: MIGRATION_LOCK_ID, is_locked: 0 })
|
|
376
|
+
.execute();
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
const lockRowExists = await this.#doesLockRowExists();
|
|
380
|
+
if (!lockRowExists) {
|
|
381
|
+
throw error;
|
|
375
382
|
}
|
|
376
383
|
}
|
|
377
384
|
}
|
|
378
|
-
async #
|
|
385
|
+
async #doesSchemaExist() {
|
|
379
386
|
const schemas = await this.#props.db.introspection.getSchemas();
|
|
380
387
|
return schemas.some((it) => it.name === this.#migrationTableSchema);
|
|
381
388
|
}
|
|
382
|
-
async #
|
|
389
|
+
async #doesTableExist(tableName) {
|
|
383
390
|
const schema = this.#migrationTableSchema;
|
|
384
391
|
const tables = await this.#props.db.introspection.getTables({
|
|
385
392
|
withInternalKyselyTables: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kysely",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.10",
|
|
4
4
|
"description": "Type safe SQL query builder",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -76,35 +76,35 @@
|
|
|
76
76
|
],
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
79
|
-
"@ark/attest": "^0.
|
|
79
|
+
"@ark/attest": "^0.56.0",
|
|
80
80
|
"@types/better-sqlite3": "^7.6.13",
|
|
81
81
|
"@types/chai": "^5.2.3",
|
|
82
82
|
"@types/chai-as-promised": "^8.0.2",
|
|
83
83
|
"@types/mocha": "^10.0.10",
|
|
84
84
|
"@types/node": "^24.10.1",
|
|
85
|
-
"@types/pg": "^8.
|
|
85
|
+
"@types/pg": "^8.16.0",
|
|
86
86
|
"@types/pg-cursor": "^2.7.2",
|
|
87
87
|
"@types/semver": "^7.7.1",
|
|
88
|
-
"@types/sinon": "^
|
|
89
|
-
"better-sqlite3": "^12.
|
|
90
|
-
"chai": "^6.2.
|
|
88
|
+
"@types/sinon": "^21.0.0",
|
|
89
|
+
"better-sqlite3": "^12.6.0",
|
|
90
|
+
"chai": "^6.2.2",
|
|
91
91
|
"chai-as-promised": "^8.0.2",
|
|
92
|
-
"esbuild": "^0.27.
|
|
92
|
+
"esbuild": "^0.27.2",
|
|
93
93
|
"jsr": "^0.13.4",
|
|
94
94
|
"lodash": "^4.17.21",
|
|
95
95
|
"mocha": "^11.7.5",
|
|
96
|
-
"mysql2": "^3.
|
|
96
|
+
"mysql2": "^3.16.1",
|
|
97
97
|
"pathe": "^2.0.3",
|
|
98
|
-
"pg": "^8.
|
|
99
|
-
"pg-cursor": "^2.
|
|
98
|
+
"pg": "^8.17.1",
|
|
99
|
+
"pg-cursor": "^2.16.1",
|
|
100
100
|
"pkg-types": "^2.3.0",
|
|
101
101
|
"playwright": "^1.57.0",
|
|
102
|
-
"prettier": "^3.
|
|
102
|
+
"prettier": "^3.8.0",
|
|
103
103
|
"semver": "^7.7.3",
|
|
104
|
-
"sinon": "^21.0.
|
|
104
|
+
"sinon": "^21.0.1",
|
|
105
105
|
"std-env": "^3.10.0",
|
|
106
106
|
"tarn": "^3.0.2",
|
|
107
|
-
"tedious": "^19.
|
|
107
|
+
"tedious": "^19.2.0",
|
|
108
108
|
"tsd": "^0.33.0",
|
|
109
109
|
"typescript": "~5.9.3"
|
|
110
110
|
},
|