diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a09a3c1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + db: + image: postgres:13 + container_name: my_postgres + environment: + POSTGRES_DB: mydb + POSTGRES_USER: myuser + POSTGRES_PASSWORD: mypassword + ports: + - "5434:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: diff --git a/drizzle.config.ts b/drizzle.config.ts index bc353ed..36d3a43 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -2,12 +2,12 @@ import "dotenv/config"; import type { Config } from "drizzle-kit"; export default { - dialect: "sqlite", + dialect: "postgresql", schema: "./src/database/schema.ts", out: "./src/database/migrations", verbose: true, strict: true, dbCredentials: { - url: "workbench.db", + url: "postgresql://myuser:mypassword@localhost:5434/mydb", }, } satisfies Config; diff --git a/package.json b/package.json index a3f4be3..79e5034 100644 --- a/package.json +++ b/package.json @@ -26,13 +26,12 @@ "@tailwindcss/typography": "^0.5.13", "@testing-library/jest-dom": "^6.4.5", "@testing-library/svelte": "^5.2.0", - "@types/better-sqlite3": "^7.6.11", "@types/lodash": "^4.17.1", + "@types/pg": "^8.11.6", "@vitest/browser": "^1.6.0", "@vitest/ui": "^1.6.0", "autoprefixer": "^10.4.19", - "better-sqlite3": "^10.0.0", - "drizzle-kit": "^0.21.2", + "drizzle-kit": "^0.24.0", "jsdom": "^24.0.0", "postcss": "^8.4.38", "prettier": "^3.2.5", @@ -60,6 +59,7 @@ "@ai-sdk/mistral": "^0.0.26", "@ai-sdk/openai": "^0.0.10", "@ai-sdk/ui-utils": "^0.0.24", + "@electric-sql/pglite": "^0.2.0", "@fontsource-variable/inter": "^5.0.18", "@lexical/history": "^0.16.0", "@lexical/plain-text": "^0.16.0", @@ -81,7 +81,7 @@ "marked-katex-extension": "^5.0.1", "msw": "^2.3.1", "nanoid": "^5.0.7", - "sqlocal": "^0.9.0", + "pg": "^8.12.0", "svelte-filepond": "^0.2.2", "svelte-french-toast": "^1.2.0", "tailwind-merge": "^2.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49fa55d..2db36f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,9 @@ importers: '@ai-sdk/ui-utils': specifier: ^0.0.24 version: 0.0.24(zod@3.23.8) + '@electric-sql/pglite': + specifier: ^0.2.0 + version: 0.2.0 '@fontsource-variable/inter': specifier: ^5.0.18 version: 5.0.18 @@ -67,7 +70,7 @@ importers: version: 16.4.5 drizzle-orm: specifier: ^0.33.0 - version: 0.33.0(@cloudflare/workers-types@4.20240502.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(react@18.3.1)(sql.js@1.10.3) + version: 0.33.0(@cloudflare/workers-types@4.20240502.0)(@electric-sql/pglite@0.2.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/pg@8.11.6)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(pg@8.12.0)(react@18.3.1)(sql.js@1.10.3) filepond: specifier: ^4.31.1 version: 4.31.1 @@ -98,9 +101,9 @@ importers: nanoid: specifier: ^5.0.7 version: 5.0.7 - sqlocal: - specifier: ^0.9.0 - version: 0.9.0(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240502.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(react@18.3.1)(sql.js@1.10.3))(kysely@0.27.3) + pg: + specifier: ^8.12.0 + version: 8.12.0 svelte-filepond: specifier: ^0.2.2 version: 0.2.2(filepond@4.31.1) @@ -150,12 +153,12 @@ importers: '@testing-library/svelte': specifier: ^5.2.0 version: 5.2.0(svelte@5.0.0-next.208)(vite@5.2.11(@types/node@20.14.9))(vitest@1.6.0(@types/node@20.14.9)(@vitest/browser@1.6.0)(@vitest/ui@1.6.0)(jsdom@24.0.0)) - '@types/better-sqlite3': - specifier: ^7.6.11 - version: 7.6.11 '@types/lodash': specifier: ^4.17.1 version: 4.17.1 + '@types/pg': + specifier: ^8.11.6 + version: 8.11.6 '@vitest/browser': specifier: ^1.6.0 version: 1.6.0(playwright@1.44.0)(vitest@1.6.0)(webdriverio@8.36.1(typescript@5.4.5)) @@ -165,12 +168,9 @@ importers: autoprefixer: specifier: ^10.4.19 version: 10.4.19(postcss@8.4.38) - better-sqlite3: - specifier: ^10.0.0 - version: 10.0.0 drizzle-kit: - specifier: ^0.21.2 - version: 0.21.2 + specifier: ^0.24.0 + version: 0.24.0 jsdom: specifier: ^24.0.0 version: 24.0.0 @@ -562,6 +562,12 @@ packages: resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} + '@drizzle-team/brocli@0.8.2': + resolution: {integrity: sha512-zTrFENsqGvOkBOuHDC1pXCkDXNd2UhP4lI3gYGhQ1R1SPeAAfqzPsV1dcpMy4uNU6kB5VpU5NGhvwxVNETR02A==} + + '@electric-sql/pglite@0.2.0': + resolution: {integrity: sha512-9ckSTnr9ChwY03lojiHM3HIOKFen72koxo44hb94Qz/L9fNejg1riwbfl2ROghA/z4ntCuyT+Zwl5pkbrSX3Aw==} + '@esbuild-kit/core-utils@3.3.2': resolution: {integrity: sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ==} @@ -1600,10 +1606,6 @@ packages: '@sodaru/yup-to-json-schema@2.0.1': resolution: {integrity: sha512-lWb0Wiz8KZ9ip/dY1eUqt7fhTPmL24p6Hmv5Fd9pzlzAdw/YNcWZr+tiCT4oZ4Zyxzi9+1X4zv82o7jYvcFxYA==} - '@sqlite.org/sqlite-wasm@3.45.3-build1': - resolution: {integrity: sha512-/eLqlKmyPoHpYZkg5VmEZpknisOShPX59Rm//zKHFVqqCk/7/mYT/i5CrooRQDqzfhq0Bm8IDynC+fbL0C1WfQ==} - hasBin: true - '@sveltejs/adapter-auto@3.2.0': resolution: {integrity: sha512-She5nKT47kwHE18v9NMe6pbJcvULr82u0V3yZ0ej3n1laWKGgkgdEABE9/ak5iDPs93LqsBkuIo51kkwCLBjJA==} peerDependencies: @@ -1734,6 +1736,9 @@ packages: '@types/node@20.14.9': resolution: {integrity: sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==} + '@types/pg@8.11.6': + resolution: {integrity: sha512-/2WmmBXHLsfRqzfHW7BNZ8SbYzE8OSk7i3WjFYvfgRHj7S1xj+16Je5fUKv3lVdVzk/zn9TXOqf+avFCFIE0yQ==} + '@types/pug@2.0.10': resolution: {integrity: sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==} @@ -1758,12 +1763,6 @@ packages: '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} - '@ungap/structured-clone@1.2.0': - resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} - - '@ungap/with-resolvers@0.1.0': - resolution: {integrity: sha512-g7f0IkJdPW2xhY7H4iE72DAsIyfuwEFc6JWc2tYFwKDMWWAF699vGjrM348cwQuOXgHpe1gWFe+Eiyjx/ewvvw==} - '@vinejs/compiler@2.5.0': resolution: {integrity: sha512-hg4ekaB5Y2zh+IWzBiC/WCDWrIfpVnKu/ubUvelKlidc/VbulsexoFRw5kJGHZenPVI5YzNnDeTdYSALkTV7jQ==} engines: {node: '>=18.0.0'} @@ -2144,10 +2143,6 @@ packages: class-variance-authority@0.7.0: resolution: {integrity: sha512-jFI8IQw4hczaL4ALINxqLEXQbWcNjoSkloa4IaufXCJr6QawJyw7tuRysRsrE8w2p/4gGaxKIt/hX3qz/IbD1A==} - cli-color@2.0.4: - resolution: {integrity: sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==} - engines: {node: '>=0.10'} - cli-spinners@2.9.2: resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==} engines: {node: '>=6'} @@ -2171,9 +2166,6 @@ packages: resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} engines: {node: '>=6'} - coincident@1.2.3: - resolution: {integrity: sha512-Uxz3BMTWIslzeWjuQnizGWVg0j6khbvHUQ8+5BdM7WuJEm4ALXwq3wluYoB+uF68uPBz/oUOeJnYURKyfjexlA==} - color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -2261,10 +2253,6 @@ packages: csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} - d@1.0.2: - resolution: {integrity: sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==} - engines: {node: '>=0.12'} - data-uri-to-buffer@2.0.2: resolution: {integrity: sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==} @@ -2362,9 +2350,6 @@ packages: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - difflib@0.2.4: - resolution: {integrity: sha512-9YVwmMb0wQHQNr5J9m6BSj6fk4pfGITGQOOs+D9Fl+INODWFOfvhIU1hNv6GgR1RBoC/9NJcwu77zShxV0kT7w==} - dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} @@ -2378,12 +2363,8 @@ packages: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} - dreamopt@0.8.0: - resolution: {integrity: sha512-vyJTp8+mC+G+5dfgsY+r3ckxlz+QMX40VjPQsZc5gxVAxLmi64TBoVkP54A/pRAXMXsbu2GMMBrZPxNv23waMg==} - engines: {node: '>=0.4.0'} - - drizzle-kit@0.21.2: - resolution: {integrity: sha512-U87IhZyCt/9d0ZT/Na3KFJVY31tSxtTx/n9UMcWFpW/5c2Ede39xiCG5efNV/0iimsv97UIRtDI0ldLBW5lbcg==} + drizzle-kit@0.24.0: + resolution: {integrity: sha512-rUl5Rf5HLOVkAwHEVEi8xgulIRWzoys0q77RHGCxv5e9v8AI3JGFg7Ug5K1kn513RwNZbuNJMUKOXo0j8kPRgg==} hasBin: true drizzle-orm@0.33.0: @@ -2508,27 +2489,9 @@ packages: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} - env-paths@3.0.0: - resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - - es5-ext@0.10.64: - resolution: {integrity: sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==} - engines: {node: '>=0.10'} - - es6-iterator@2.0.3: - resolution: {integrity: sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==} - es6-promise@3.3.1: resolution: {integrity: sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==} - es6-symbol@3.1.4: - resolution: {integrity: sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==} - engines: {node: '>=0.12'} - - es6-weak-map@2.0.3: - resolution: {integrity: sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==} - esbuild-register@3.5.0: resolution: {integrity: sha512-+4G/XmakeBAsvJuDugJvtyF1x+XJT4FMocynNpxrvEBViirpfUn2PgNpCHedfWhF4WokNsO/OvMKrmJOIJsI5A==} peerDependencies: @@ -2580,10 +2543,6 @@ packages: esm-env@1.0.0: resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==} - esniff@2.0.1: - resolution: {integrity: sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==} - engines: {node: '>=0.10'} - esprima@4.0.1: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} @@ -2609,9 +2568,6 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - event-emitter@0.3.5: - resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} - event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} @@ -2636,9 +2592,6 @@ packages: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} engines: {node: '>=6'} - ext@1.7.0: - resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==} - extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -2747,9 +2700,6 @@ packages: resolution: {integrity: sha512-DSrkyMTfAnAm4ks9Go20QGOcXEyW/NmZhvTYBU2rb4afBB393WIMQPWPEDMl/k8xqiNN9HYq2zao3oWXsdl2Tg==} engines: {node: '>=14'} - gc-hook@0.3.1: - resolution: {integrity: sha512-E5M+O/h2o7eZzGhzRZGex6hbB3k4NWqO0eA+OzLRLXxhdbYPajZnynPwAtphnh+cRHPwsj5Z80dqZlfI4eK55A==} - gcp-metadata@6.1.0: resolution: {integrity: sha512-Jh/AIwwgaxan+7ZUUmRLCjtchyDiqh4KjBJ5tW3plBZb5iL/BPcso8A5DlzeD9qlw0duCamnNdpFjxwaT0KyKg==} engines: {node: '>=14'} @@ -2814,10 +2764,6 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - glob@8.1.0: - resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} - engines: {node: '>=12'} - globalyzer@0.1.0: resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} @@ -2846,9 +2792,6 @@ packages: resolution: {integrity: sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==} engines: {node: '>=14.0.0'} - hanji@0.0.5: - resolution: {integrity: sha512-Abxw1Lq+TnYiL4BueXqMau222fPSPMFtya8HdpWsz/xVAhifXou71mPh/kY2+08RgFcVccjG3uZHs6K5HAe3zw==} - has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} @@ -2864,9 +2807,6 @@ packages: headers-polyfill@4.0.3: resolution: {integrity: sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==} - heap@0.2.7: - resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} - highlight.js@11.9.0: resolution: {integrity: sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==} engines: {node: '>=12.0.0'} @@ -2958,9 +2898,6 @@ packages: is-potential-custom-element-name@1.0.1: resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==} - is-promise@2.2.2: - resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==} - is-reference@3.0.2: resolution: {integrity: sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==} @@ -3017,10 +2954,6 @@ packages: json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} - json-diff@0.9.0: - resolution: {integrity: sha512-cVnggDrVkAAA3OvFfHpFEhOnmcsUpleEKq4d4O8sQWWSH40MBrWstKigVB1kGrgLWzuom+7rRdaCsnBD6VyObQ==} - hasBin: true - json-schema-to-ts@3.1.0: resolution: {integrity: sha512-UeVN/ery4/JeXI8h4rM8yZPxsH+KqPi/84qFxHfTGHZnWnK9D0UU9ZGYO+6XAaJLqCWMiks+ARuFOKAiSxJCHA==} engines: {node: '>=16'} @@ -3104,9 +3037,6 @@ packages: lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - lodash.throttle@4.1.1: - resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} - lodash.zip@4.2.0: resolution: {integrity: sha512-C7IOaBBK/0gMORRBd8OETNx3kmOkgIWIPvyDpZSCTwUrpYmgZwJkjZeOD8ww4xbOUOs4/attY+pciKvadNfFbg==} @@ -3139,9 +3069,6 @@ packages: resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} engines: {node: '>=12'} - lru-queue@0.1.0: - resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==} - lucide-svelte@0.378.0: resolution: {integrity: sha512-T7hV1sfOc94AWE5GOJ6r9wGEsR4h4TJr8d4Z0sM8O0e3IBcmeIvEGRAA6jCp7NGy4PeGrn5Tju6Y2JwJQntNrQ==} peerDependencies: @@ -3171,9 +3098,6 @@ packages: memoize-weak@1.0.2: resolution: {integrity: sha512-gj39xkrjEw7nCn4nJ1M5ms6+MyMlyiGmttzsqAUsAKn6bYKwuTHh/AO3cKPF8IBrTIYTxb0wWXFs3E//Y8VoWQ==} - memoizee@0.4.15: - resolution: {integrity: sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==} - merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} @@ -3307,9 +3231,6 @@ packages: resolution: {integrity: sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==} engines: {node: '>= 0.4.0'} - next-tick@1.1.0: - resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} - node-abi@3.62.0: resolution: {integrity: sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==} engines: {node: '>=10'} @@ -3365,6 +3286,9 @@ packages: resolution: {integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==} engines: {node: '>= 6'} + obuf@1.1.2: + resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -3435,6 +3359,48 @@ packages: pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} + pg-cloudflare@1.1.1: + resolution: {integrity: sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==} + + pg-connection-string@2.6.4: + resolution: {integrity: sha512-v+Z7W/0EO707aNMaAEfiGnGL9sxxumwLl2fJvCQtMn9Fxsg+lPpPkdcyBSv/KFgpGdYkMfn+EI1Or2EHjpgLCA==} + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-numeric@1.0.2: + resolution: {integrity: sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw==} + engines: {node: '>=4'} + + pg-pool@3.6.2: + resolution: {integrity: sha512-Htjbg8BlwXqSBQ9V8Vjtc+vzf/6fVUuak/3/XXKA9oxZprwW3IMDQTGHP+KDmVL7rtd+R1QjbnCFPuTHm3G4hg==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.6.1: + resolution: {integrity: sha512-jPIlvgoD63hrEuihvIg+tJhoGjUsLPn6poJY9N5CnlPd91c2T18T/9zBtLxZSb1EhYxBRoZJtzScCaWlYLtktg==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg-types@4.0.2: + resolution: {integrity: sha512-cRL3JpS3lKMGsKaWndugWQoLOCoP+Cic8oseVcbr0qhPzYD5DWXK+RZ9LY9wxRf7RQia4SCwQlXk0q6FCPrVng==} + engines: {node: '>=10'} + + pg@8.12.0: + resolution: {integrity: sha512-A+LHUSnwnxrnL/tZ+OLfqR1SxLN3c/pgDztZ47Rpbsd4jUytsTtwQo/TLPRzPJMp/1pbhYVhH9cuSZLAajNfjQ==} + engines: {node: '>= 8.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} @@ -3508,6 +3474,41 @@ packages: resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} engines: {node: ^10 || ^12 || >=14} + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-array@3.0.2: + resolution: {integrity: sha512-6faShkdFugNQCLwucjPcY5ARoW1SlbnrZjmGl0IrrqewpvxvhSLHimCVzqeuULCbG0fQv7Dtk1yDbG3xv7Veog==} + engines: {node: '>=12'} + + postgres-bytea@1.0.0: + resolution: {integrity: sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==} + engines: {node: '>=0.10.0'} + + postgres-bytea@3.0.0: + resolution: {integrity: sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw==} + engines: {node: '>= 6'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-date@2.1.0: + resolution: {integrity: sha512-K7Juri8gtgXVcDfZttFKVmhglp7epKb1K4pgrkLxehjqkrgPhfG6OO8LHLkfaqkbpjNRnra018XwAr1yQFWGcA==} + engines: {node: '>=12'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + + postgres-interval@3.0.0: + resolution: {integrity: sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==} + engines: {node: '>=12'} + + postgres-range@1.1.4: + resolution: {integrity: sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==} + prebuild-install@7.1.2: resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==} engines: {node: '>=10'} @@ -3617,9 +3618,6 @@ packages: proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - proxy-target@3.0.2: - resolution: {integrity: sha512-FFE1XNwXX/FNC3/P8HiKaJSy/Qk68RitG/QEcLy/bVnTAPlgTAWPZKh0pARLAnpfXQPKyalBhk009NRTgsk8vQ==} - psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} @@ -3842,9 +3840,6 @@ packages: resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} engines: {node: '>= 10'} - sisteransi@1.0.5: - resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - smart-buffer@4.2.0: resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} @@ -3892,17 +3887,6 @@ packages: sql.js@1.10.3: resolution: {integrity: sha512-H46aWtQkdyjZwFQgraUruy5h/DyJBbAK3EA/WEMqiqF6PGPfKBSKBj/er3dVyYqVIoYfRf5TFM/loEjtQIrqJg==} - sqlocal@0.9.0: - resolution: {integrity: sha512-/NiXQFa2+H5zkKr06SkIwjeItz5+GJerZh/rGjiT+X21k/J/29HeYd6a++iIeOtZHBd4qI4eSi8iOYq+yNk1YQ==} - peerDependencies: - drizzle-orm: '*' - kysely: '*' - peerDependenciesMeta: - drizzle-orm: - optional: true - kysely: - optional: true - sswr@2.1.0: resolution: {integrity: sha512-Cqc355SYlTAaUt8iDPaC/4DPPXK925PePLMxyBKuWd5kKc5mwsG3nT9+Mq2tyguL5s7b4Jg+IRMpTRsNTAfpSQ==} peerDependencies: @@ -4125,9 +4109,6 @@ packages: through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} - timers-ext@0.1.7: - resolution: {integrity: sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==} - tiny-case@1.0.3: resolution: {integrity: sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==} @@ -4213,9 +4194,6 @@ packages: resolution: {integrity: sha512-R6wDsVsoS9xYOpy8vgeBlqpdOyzJ12HNfQhC/aAKWM3YoCV9TtunJzh/QpkMgeDhkoynDcw5f1y+qF9yc/HHyg==} engines: {node: '>=16'} - type@2.7.2: - resolution: {integrity: sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==} - typescript@5.4.5: resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} engines: {node: '>=14.17'} @@ -4426,9 +4404,6 @@ packages: engines: {node: '>=8'} hasBin: true - wordwrap@1.0.0: - resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} - workerd@1.20240419.0: resolution: {integrity: sha512-9yV98KpkQgG+bdEsKEW8i1AYZgxns6NVSfdOVEB2Ue1pTMtIEYfUyqUE+O2amisRrfaC3Pw4EvjtTmVaoetfeg==} engines: {node: '>=16'} @@ -4494,6 +4469,10 @@ packages: xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + xxhash-wasm@1.0.2: resolution: {integrity: sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==} @@ -5158,6 +5137,10 @@ snapshots: dependencies: '@jridgewell/trace-mapping': 0.3.9 + '@drizzle-team/brocli@0.8.2': {} + + '@electric-sql/pglite@0.2.0': {} + '@esbuild-kit/core-utils@3.3.2': dependencies: esbuild: 0.18.20 @@ -6087,8 +6070,6 @@ snapshots: '@sodaru/yup-to-json-schema@2.0.1': optional: true - '@sqlite.org/sqlite-wasm@3.45.3-build1': {} - '@sveltejs/adapter-auto@3.2.0(@sveltejs/kit@2.5.7(@sveltejs/vite-plugin-svelte@3.1.0(svelte@5.0.0-next.208)(vite@5.2.11(@types/node@20.14.9)))(svelte@5.0.0-next.208)(vite@5.2.11(@types/node@20.14.9)))': dependencies: '@sveltejs/kit': 2.5.7(@sveltejs/vite-plugin-svelte@3.1.0(svelte@5.0.0-next.208)(vite@5.2.11(@types/node@20.14.9)))(svelte@5.0.0-next.208)(vite@5.2.11(@types/node@20.14.9)) @@ -6200,6 +6181,7 @@ snapshots: '@types/better-sqlite3@7.6.11': dependencies: '@types/node': 20.14.9 + optional: true '@types/cookie@0.6.0': {} @@ -6236,6 +6218,12 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/pg@8.11.6': + dependencies: + '@types/node': 20.14.9 + pg-protocol: 1.6.1 + pg-types: 4.0.2 + '@types/pug@2.0.10': {} '@types/sql.js@1.4.9': @@ -6264,10 +6252,6 @@ snapshots: '@types/node': 20.14.9 optional: true - '@ungap/structured-clone@1.2.0': {} - - '@ungap/with-resolvers@0.1.0': {} - '@vinejs/compiler@2.5.0': optional: true @@ -6610,6 +6594,7 @@ snapshots: dependencies: bindings: 1.5.0 prebuild-install: 7.1.2 + optional: true big-integer@1.6.52: optional: true @@ -6621,6 +6606,7 @@ snapshots: bindings@1.5.0: dependencies: file-uri-to-path: 1.0.0 + optional: true bits-ui@0.21.7(svelte@5.0.0-next.208): dependencies: @@ -6634,6 +6620,7 @@ snapshots: buffer: 5.7.1 inherits: 2.0.4 readable-stream: 3.6.2 + optional: true blake3-wasm@2.1.5: {} @@ -6675,6 +6662,7 @@ snapshots: dependencies: base64-js: 1.5.1 ieee754: 1.2.1 + optional: true buffer@6.0.3: dependencies: @@ -6758,7 +6746,8 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chownr@1.1.4: {} + chownr@1.1.4: + optional: true chromium-bidi@0.4.16(devtools-protocol@0.0.1147663): dependencies: @@ -6770,14 +6759,6 @@ snapshots: dependencies: clsx: 2.0.0 - cli-color@2.0.4: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-iterator: 2.0.3 - memoizee: 0.4.15 - timers-ext: 0.1.7 - cli-spinners@2.9.2: {} cli-width@4.1.0: {} @@ -6794,18 +6775,6 @@ snapshots: clsx@2.1.1: {} - coincident@1.2.3: - dependencies: - '@ungap/structured-clone': 1.2.0 - '@ungap/with-resolvers': 0.1.0 - gc-hook: 0.3.1 - proxy-target: 3.0.2 - optionalDependencies: - ws: 8.17.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - color-convert@1.9.3: dependencies: color-name: 1.1.3 @@ -6826,7 +6795,8 @@ snapshots: commander@8.3.0: {} - commander@9.5.0: {} + commander@9.5.0: + optional: true compress-commons@6.0.2: dependencies: @@ -6886,11 +6856,6 @@ snapshots: csstype@3.1.3: {} - d@1.0.2: - dependencies: - es5-ext: 0.10.64 - type: 2.7.2 - data-uri-to-buffer@2.0.2: {} data-uri-to-buffer@4.0.1: @@ -6919,12 +6884,14 @@ snapshots: decompress-response@6.0.0: dependencies: mimic-response: 3.1.0 + optional: true deep-eql@4.1.3: dependencies: type-detect: 4.0.8 - deep-extend@0.6.0: {} + deep-extend@0.6.0: + optional: true deepmerge-ts@5.1.0: optional: true @@ -6947,7 +6914,8 @@ snapshots: detect-indent@6.1.0: {} - detect-libc@2.0.3: {} + detect-libc@2.0.3: + optional: true devalue@5.0.0: {} @@ -6963,10 +6931,6 @@ snapshots: diff-sequences@29.6.3: {} - difflib@0.2.4: - dependencies: - heap: 0.2.7 - dlv@1.1.3: {} dom-accessibility-api@0.5.16: {} @@ -6975,32 +6939,26 @@ snapshots: dotenv@16.4.5: {} - dreamopt@0.8.0: - dependencies: - wordwrap: 1.0.0 - - drizzle-kit@0.21.2: + drizzle-kit@0.24.0: dependencies: + '@drizzle-team/brocli': 0.8.2 '@esbuild-kit/esm-loader': 2.6.5 - commander: 9.5.0 - env-paths: 3.0.0 esbuild: 0.19.12 esbuild-register: 3.5.0(esbuild@0.19.12) - glob: 8.1.0 - hanji: 0.0.5 - json-diff: 0.9.0 - zod: 3.23.8 transitivePeerDependencies: - supports-color - drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240502.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(react@18.3.1)(sql.js@1.10.3): + drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240502.0)(@electric-sql/pglite@0.2.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/pg@8.11.6)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(pg@8.12.0)(react@18.3.1)(sql.js@1.10.3): optionalDependencies: '@cloudflare/workers-types': 4.20240502.0 + '@electric-sql/pglite': 0.2.0 '@opentelemetry/api': 1.9.0 '@types/better-sqlite3': 7.6.11 + '@types/pg': 8.11.6 '@types/sql.js': 1.4.9 better-sqlite3: 10.0.0 kysely: 0.27.3 + pg: 8.12.0 react: 18.3.1 sql.js: 1.10.3 @@ -7040,38 +6998,12 @@ snapshots: end-of-stream@1.4.4: dependencies: once: 1.4.0 + optional: true entities@4.5.0: {} - env-paths@3.0.0: {} - - es5-ext@0.10.64: - dependencies: - es6-iterator: 2.0.3 - es6-symbol: 3.1.4 - esniff: 2.0.1 - next-tick: 1.1.0 - - es6-iterator@2.0.3: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-symbol: 3.1.4 - es6-promise@3.3.1: {} - es6-symbol@3.1.4: - dependencies: - d: 1.0.2 - ext: 1.7.0 - - es6-weak-map@2.0.3: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-iterator: 2.0.3 - es6-symbol: 3.1.4 - esbuild-register@3.5.0(esbuild@0.19.12): dependencies: debug: 4.3.4 @@ -7205,13 +7137,6 @@ snapshots: esm-env@1.0.0: {} - esniff@2.0.1: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - event-emitter: 0.3.5 - type: 2.7.2 - esprima@4.0.1: optional: true @@ -7234,11 +7159,6 @@ snapshots: esutils@2.0.3: optional: true - event-emitter@0.3.5: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - event-target-shim@5.0.1: optional: true @@ -7261,11 +7181,8 @@ snapshots: exit-hook@2.2.1: {} - expand-template@2.0.3: {} - - ext@1.7.0: - dependencies: - type: 2.7.2 + expand-template@2.0.3: + optional: true extend@3.0.2: {} @@ -7315,7 +7232,8 @@ snapshots: fflate@0.8.2: {} - file-uri-to-path@1.0.0: {} + file-uri-to-path@1.0.0: + optional: true filepond@4.31.1: {} @@ -7356,7 +7274,8 @@ snapshots: fraction.js@4.3.7: {} - fs-constants@1.0.0: {} + fs-constants@1.0.0: + optional: true fs-extra@11.2.0: dependencies: @@ -7394,8 +7313,6 @@ snapshots: - encoding - supports-color - gc-hook@0.3.1: {} - gcp-metadata@6.1.0: dependencies: gaxios: 6.7.0 @@ -7454,7 +7371,8 @@ snapshots: - supports-color optional: true - github-from-package@0.0.0: {} + github-from-package@0.0.0: + optional: true glob-parent@5.1.2: dependencies: @@ -7483,14 +7401,6 @@ snapshots: once: 1.4.0 path-is-absolute: 1.0.1 - glob@8.1.0: - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 5.1.6 - once: 1.4.0 - globalyzer@0.1.0: {} globrex@0.1.2: {} @@ -7537,11 +7447,6 @@ snapshots: - encoding - supports-color - hanji@0.0.5: - dependencies: - lodash.throttle: 4.1.1 - sisteransi: 1.0.5 - has-flag@3.0.0: {} has-flag@4.0.0: {} @@ -7552,8 +7457,6 @@ snapshots: headers-polyfill@4.0.3: {} - heap@0.2.7: {} - highlight.js@11.9.0: {} html-encoding-sniffer@4.0.0: @@ -7589,7 +7492,8 @@ snapshots: dependencies: safer-buffer: 2.1.2 - ieee754@1.2.1: {} + ieee754@1.2.1: + optional: true import-fresh@3.3.0: dependencies: @@ -7607,7 +7511,8 @@ snapshots: inherits@2.0.4: {} - ini@1.3.8: {} + ini@1.3.8: + optional: true ip-address@9.0.5: dependencies: @@ -7640,8 +7545,6 @@ snapshots: is-potential-custom-element-name@1.0.1: {} - is-promise@2.2.2: {} - is-reference@3.0.2: dependencies: '@types/estree': 1.0.5 @@ -7717,12 +7620,6 @@ snapshots: json-buffer@3.0.1: optional: true - json-diff@0.9.0: - dependencies: - cli-color: 2.0.4 - difflib: 0.2.4 - dreamopt: 0.8.0 - json-schema-to-ts@3.1.0: dependencies: '@babel/runtime': 7.24.5 @@ -7810,8 +7707,6 @@ snapshots: lodash.merge@4.6.2: {} - lodash.throttle@4.1.1: {} - lodash.zip@4.2.0: optional: true @@ -7839,10 +7734,6 @@ snapshots: lru-cache@7.18.3: optional: true - lru-queue@0.1.0: - dependencies: - es5-ext: 0.10.64 - lucide-svelte@0.378.0(svelte@5.0.0-next.208): dependencies: svelte: 5.0.0-next.208 @@ -7867,17 +7758,6 @@ snapshots: memoize-weak@1.0.2: {} - memoizee@0.4.15: - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-weak-map: 2.0.3 - event-emitter: 0.3.5 - is-promise: 2.2.2 - lru-queue: 0.1.0 - next-tick: 1.1.0 - timers-ext: 0.1.7 - merge-stream@2.0.0: {} merge2@1.4.1: {} @@ -7897,7 +7777,8 @@ snapshots: mimic-fn@4.0.0: {} - mimic-response@3.1.0: {} + mimic-response@3.1.0: + optional: true mimic-response@4.0.0: optional: true @@ -7930,6 +7811,7 @@ snapshots: minimatch@5.1.6: dependencies: brace-expansion: 2.0.1 + optional: true minimatch@9.0.4: dependencies: @@ -7942,7 +7824,8 @@ snapshots: mitt@3.0.0: optional: true - mkdirp-classic@0.5.3: {} + mkdirp-classic@0.5.3: + optional: true mkdirp@0.5.6: dependencies: @@ -8002,16 +7885,16 @@ snapshots: nanoid@5.0.7: {} - napi-build-utils@1.0.2: {} + napi-build-utils@1.0.2: + optional: true netmask@2.0.2: optional: true - next-tick@1.1.0: {} - node-abi@3.62.0: dependencies: semver: 7.6.2 + optional: true node-domexception@1.0.0: optional: true @@ -8048,6 +7931,8 @@ snapshots: object-hash@3.0.0: {} + obuf@1.1.2: {} + once@1.4.0: dependencies: wrappy: 1.0.2 @@ -8124,6 +8009,53 @@ snapshots: pend@1.2.0: optional: true + pg-cloudflare@1.1.1: + optional: true + + pg-connection-string@2.6.4: {} + + pg-int8@1.0.1: {} + + pg-numeric@1.0.2: {} + + pg-pool@3.6.2(pg@8.12.0): + dependencies: + pg: 8.12.0 + + pg-protocol@1.6.1: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.0 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg-types@4.0.2: + dependencies: + pg-int8: 1.0.1 + pg-numeric: 1.0.2 + postgres-array: 3.0.2 + postgres-bytea: 3.0.0 + postgres-date: 2.1.0 + postgres-interval: 3.0.0 + postgres-range: 1.1.4 + + pg@8.12.0: + dependencies: + pg-connection-string: 2.6.4 + pg-pool: 3.6.2(pg@8.12.0) + pg-protocol: 1.6.1 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.1.1 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + picocolors@1.0.0: {} picomatch@2.3.1: {} @@ -8188,6 +8120,28 @@ snapshots: picocolors: 1.0.0 source-map-js: 1.2.0 + postgres-array@2.0.0: {} + + postgres-array@3.0.2: {} + + postgres-bytea@1.0.0: {} + + postgres-bytea@3.0.0: + dependencies: + obuf: 1.1.2 + + postgres-date@1.0.7: {} + + postgres-date@2.1.0: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + + postgres-interval@3.0.0: {} + + postgres-range@1.1.4: {} + prebuild-install@7.1.2: dependencies: detect-libc: 2.0.3 @@ -8202,6 +8156,7 @@ snapshots: simple-get: 4.0.1 tar-fs: 2.1.1 tunnel-agent: 0.6.0 + optional: true prettier-plugin-svelte@3.2.3(prettier@3.2.5)(svelte@5.0.0-next.208): dependencies: @@ -8276,14 +8231,13 @@ snapshots: proxy-from-env@1.1.0: optional: true - proxy-target@3.0.2: {} - psl@1.9.0: {} pump@3.0.0: dependencies: end-of-stream: 1.4.4 once: 1.4.0 + optional: true punycode@2.3.1: {} @@ -8323,6 +8277,7 @@ snapshots: ini: 1.3.8 minimist: 1.2.8 strip-json-comments: 2.0.1 + optional: true react-is@17.0.2: {} @@ -8352,6 +8307,7 @@ snapshots: inherits: 2.0.4 string_decoder: 1.3.0 util-deprecate: 1.0.2 + optional: true readable-stream@4.5.2: dependencies: @@ -8492,7 +8448,8 @@ snapshots: '@types/node-forge': 1.3.11 node-forge: 1.3.1 - semver@7.6.2: {} + semver@7.6.2: + optional: true serialize-error@11.0.3: dependencies: @@ -8519,13 +8476,15 @@ snapshots: signal-exit@4.1.0: {} - simple-concat@1.0.1: {} + simple-concat@1.0.1: + optional: true simple-get@4.0.1: dependencies: decompress-response: 6.0.0 once: 1.4.0 simple-concat: 1.0.1 + optional: true sirv@2.0.4: dependencies: @@ -8533,8 +8492,6 @@ snapshots: mrmime: 2.0.0 totalist: 3.0.1 - sisteransi@1.0.5: {} - smart-buffer@4.2.0: optional: true @@ -8581,8 +8538,7 @@ snapshots: spacetrim@0.11.24: optional: true - split2@4.2.0: - optional: true + split2@4.2.0: {} sprintf-js@1.1.3: optional: true @@ -8590,18 +8546,6 @@ snapshots: sql.js@1.10.3: optional: true - sqlocal@0.9.0(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240502.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(react@18.3.1)(sql.js@1.10.3))(kysely@0.27.3): - dependencies: - '@sqlite.org/sqlite-wasm': 3.45.3-build1 - coincident: 1.2.3 - nanoid: 5.0.7 - optionalDependencies: - drizzle-orm: 0.33.0(@cloudflare/workers-types@4.20240502.0)(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.11)(@types/sql.js@1.4.9)(better-sqlite3@10.0.0)(kysely@0.27.3)(react@18.3.1)(sql.js@1.10.3) - kysely: 0.27.3 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - sswr@2.1.0(svelte@5.0.0-next.208): dependencies: svelte: 5.0.0-next.208 @@ -8650,6 +8594,7 @@ snapshots: string_decoder@1.3.0: dependencies: safe-buffer: 5.2.1 + optional: true strip-ansi@6.0.1: dependencies: @@ -8665,7 +8610,8 @@ snapshots: dependencies: min-indent: 1.0.1 - strip-json-comments@2.0.1: {} + strip-json-comments@2.0.1: + optional: true strip-literal@2.1.0: dependencies: @@ -8845,6 +8791,7 @@ snapshots: mkdirp-classic: 0.5.3 pump: 3.0.0 tar-stream: 2.2.0 + optional: true tar-fs@3.0.4: dependencies: @@ -8869,6 +8816,7 @@ snapshots: fs-constants: 1.0.0 inherits: 2.0.4 readable-stream: 3.6.2 + optional: true tar-stream@3.1.7: dependencies: @@ -8888,11 +8836,6 @@ snapshots: through@2.3.8: optional: true - timers-ext@0.1.7: - dependencies: - es5-ext: 0.10.64 - next-tick: 1.1.0 - tiny-case@1.0.3: optional: true @@ -8948,6 +8891,7 @@ snapshots: tunnel-agent@0.6.0: dependencies: safe-buffer: 5.2.1 + optional: true type-detect@4.0.8: {} @@ -8961,8 +8905,6 @@ snapshots: type-fest@4.20.1: {} - type@2.7.2: {} - typescript@5.4.5: {} ufo@1.5.3: {} @@ -9211,8 +9153,6 @@ snapshots: siginfo: 2.0.0 stackback: 0.0.2 - wordwrap@1.0.0: {} - workerd@1.20240419.0: optionalDependencies: '@cloudflare/workerd-darwin-64': 1.20240419.0 @@ -9279,6 +9219,8 @@ snapshots: xmlchars@2.2.0: {} + xtend@4.0.2: {} + xxhash-wasm@1.0.2: {} y18n@5.0.8: {} diff --git a/src/database/client.ts b/src/database/client.ts index 2f39e40..b6196e6 100644 --- a/src/database/client.ts +++ b/src/database/client.ts @@ -1,21 +1,18 @@ -import { SQLocalDrizzle } from "sqlocal/drizzle"; -import { drizzle, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy"; +import { drizzle, type PgliteDatabase } from "drizzle-orm/pglite"; +import { PGlite } from "@electric-sql/pglite"; import * as schema from "./schema"; -import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core"; -export const SQLITE_FILENAME = "workbench.db"; +let db: PgliteDatabase | undefined = undefined; -let db: SqliteRemoteDatabase | undefined = undefined; - -export function useDb(): BaseSQLiteDatabase { +export function useDb(): PgliteDatabase { if (!db) { - const { driver, batchDriver } = new SQLocalDrizzle(SQLITE_FILENAME); - db = drizzle(driver, batchDriver, { schema }); + const client = new PGlite("idb://workbench-data"); + db = drizzle(client, { schema }); } return db; } -export function useDbFile() { - const { getDatabaseFile, overwriteDatabaseFile } = new SQLocalDrizzle(SQLITE_FILENAME); - return { getDatabaseFile, overwriteDatabaseFile }; -} +// export function useDbFile() { +// const { getDatabaseFile, overwriteDatabaseFile } = new SQLocalDrizzle(SQLITE_FILENAME); +// return { getDatabaseFile, overwriteDatabaseFile }; +// } diff --git a/src/database/index.ts b/src/database/index.ts index 6433ac1..2414db0 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -1,32 +1,33 @@ -import { useDb, useDbFile } from "./client.js"; +import { useDb } from "./client.js"; import * as schema from "./schema.js"; import { sql } from "drizzle-orm/sql"; +import type { PgliteDatabase } from "drizzle-orm/pglite"; export { registerModel, invalidateModel } from "./model.js"; export * from "./schema.js"; export { schema, useDb }; -export async function overwriteDb() { - const { overwriteDatabaseFile } = useDbFile(); -} - -export async function exportDb() { - const { getDatabaseFile } = useDbFile(); - const databaseFile = await getDatabaseFile(); - const fileUrl = URL.createObjectURL(databaseFile); - - const now = new Date(); - const timestamp = now.toISOString().split(".")[0].replace(/\:/g, "-"); - - const a = document.createElement("a"); - a.href = fileUrl; - a.download = `workbench-${timestamp}.db`; - a.click(); - a.remove(); - - URL.revokeObjectURL(fileUrl); -} +// export async function overwriteDb() { +// const { overwriteDatabaseFile } = useDbFile(); +// } +// +// export async function exportDb() { +// const { getDatabaseFile } = useDbFile(); +// const databaseFile = await getDatabaseFile(); +// const fileUrl = URL.createObjectURL(databaseFile); +// +// const now = new Date(); +// const timestamp = now.toISOString().split(".")[0].replace(/\:/g, "-"); +// +// const a = document.createElement("a"); +// a.href = fileUrl; +// a.download = `workbench-${timestamp}.db`; +// a.click(); +// a.remove(); +// +// URL.revokeObjectURL(fileUrl); +// } export function exposeDb() { const db = useDb(); @@ -36,45 +37,61 @@ export function exposeDb() { window.sql = sql; // @ts-expect-error window.db_destroy = async function () { - const rows = await db.all(sql`SELECT name FROM sqlite_master WHERE type='table';`); - console.log("Dropping all tables", rows); - for (const record of rows) { - // drop table - // @ts-ignore - await db.run(sql.raw(`DROP TABLE ${record[0]};`)); - } - }; - // @ts-expect-error - window.db_listTables = async function () { - const rows = await db.all(sql`SELECT name FROM sqlite_master WHERE type='table';`); - console.log("Tables", rows); - for (const record of rows) { - // list count of rows - // @ts-ignore - const count = await db.get(sql.raw(`SELECT COUNT(*) FROM ${record[0]};`)); - // @ts-ignore - console.log(record[0], count); - } - }; - // @ts-expect-error - window.db_download = exportDb; - // @ts-expect-error - window.db_overwrite = function () { - const input = document.createElement("input"); - input.type = "file"; - input.accept = ".db"; - input.onchange = async function (e: any) { - console.log("overwrite", e); - if (!e.target) { - return; - } - const file = e.target.files[0]; - if (!file) { - return; + const db = useDb() as PgliteDatabase; + + // Get all tables in the public schema + const results = await db.execute<{ tablename: string }>(sql` + SELECT tablename + FROM pg_tables + WHERE schemaname = 'public'; + `); + + console.log("Dropping all tables", results.rows); + + // Drop all tables + for (const record of results.rows) { + try { + await db.execute(sql.raw(`DROP TABLE IF EXISTS "${record.tablename}" CASCADE;`)); + console.log(`Dropped table: ${record.tablename}`); + } catch (error) { + console.error(`Error dropping table ${record.tablename}:`, error); } - const { overwriteDatabaseFile } = useDbFile(); - await overwriteDatabaseFile(file); - }; - document.body.appendChild(input); + } + + console.log("All tables dropped"); }; + + // // @ts-expect-error + // window.db_listTables = async function () { + // const rows = await db.all(sql`SELECT name FROM sqlite_master WHERE type='table';`); + // console.log("Tables", rows); + // for (const record of rows) { + // // list count of rows + // // @ts-ignore + // const count = await db.get(sql.raw(`SELECT COUNT(*) FROM ${record[0]};`)); + // // @ts-ignore + // console.log(record[0], count); + // } + // }; + // // @ts-expect-error + // window.db_download = exportDb; + // // @ts-expect-error + // window.db_overwrite = function () { + // const input = document.createElement("input"); + // input.type = "file"; + // input.accept = ".db"; + // input.onchange = async function (e: any) { + // console.log("overwrite", e); + // if (!e.target) { + // return; + // } + // const file = e.target.files[0]; + // if (!file) { + // return; + // } + // const { overwriteDatabaseFile } = useDbFile(); + // await overwriteDatabaseFile(file); + // }; + // document.body.appendChild(input); + // }; } diff --git a/src/database/migrations.test.ts b/src/database/migrations.test.ts deleted file mode 100644 index 75dd12d..0000000 --- a/src/database/migrations.test.ts +++ /dev/null @@ -1,1019 +0,0 @@ -import { - expect, - describe, - it, - beforeAll, - afterAll, - vi, - onTestFailed, - beforeEach, - afterEach, -} from "vitest"; -import { drizzle } from "drizzle-orm/better-sqlite3"; -import Database from "better-sqlite3"; -import { sql } from "drizzle-orm"; -import { useDb } from "@/database/client"; -import journal from "@/database/migrations/meta/_journal.json"; -import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3"; -import * as schema from "@/database/schema"; - -describe("Migration Tests", () => { - let sqlite: Database.Database; - let db: BetterSQLite3Database; - - /* - * Test data for all tables. This data will be used to populate the database - * after the initial migration and to verify the data integrity after subsequent migrations. - */ - const testData = { - projects: [ - { - id: "project1", - name: "Test Project 1", - prompt: "Test prompt 1", - createdAt: "2023-01-01T00:00:00Z", - }, - { - id: "project2", - name: "Test Project 2", - prompt: "Test prompt 2", - createdAt: "2023-01-02T00:00:00Z", - }, - { - id: "project3", - name: "Test Project 3", - prompt: "Test prompt 3", - createdAt: "2023-01-03T00:00:00Z", - }, - ], - services: [ - { - id: "service1", - name: "Test Service 1", - providerId: "provider1", - baseURL: "http://test1.com", - apiKey: "testkey1", - createdAt: "2023-01-01T00:00:00Z", - }, - { - id: "service2", - name: "Test Service 2", - providerId: "provider2", - baseURL: "http://test2.com", - apiKey: "testkey2", - createdAt: "2023-01-02T00:00:00Z", - }, - ], - models: [ - { - id: "model1", - serviceId: "service1", - name: "Test Model 1", - visible: 1, - createdAt: "2023-01-01T00:00:00Z", - }, - { - id: "model2", - serviceId: "service1", - name: "Test Model 2", - visible: 0, - createdAt: "2023-01-02T00:00:00Z", - }, - { - id: "model3", - serviceId: "service2", - name: "Test Model 3", - visible: 1, - createdAt: "2023-01-03T00:00:00Z", - }, - ], - responses: [ - { - id: "response1", - projectId: "project1", - modelId: "model1", - createdAt: "2023-01-01T00:00:00Z", - }, - { - id: "response2", - projectId: "project1", - modelId: "model2", - createdAt: "2023-01-02T00:00:00Z", - }, - { - id: "response3", - projectId: "project2", - modelId: "model1", - createdAt: "2023-01-03T00:00:00Z", - }, - { - id: "response4", - projectId: "project3", - modelId: "model3", - createdAt: "2023-01-04T00:00:00Z", - }, - ], - responseMessages: [ - { - id: "message1", - index: 0, - responseId: "response1", - role: "user", - content: "Test message 1", - createdAt: "2023-01-01T00:00:00Z", - }, - { - id: "message2", - index: 1, - responseId: "response1", - role: "assistant", - content: "Test reply 1", - createdAt: "2023-01-01T00:00:01Z", - }, - { - id: "message3", - index: 0, - responseId: "response2", - role: "user", - content: "Test message 2", - createdAt: "2023-01-02T00:00:00Z", - }, - { - id: "message4", - index: 0, - responseId: "response3", - role: "user", - content: "Test message 3", - createdAt: "2023-01-03T00:00:00Z", - }, - { - id: "message5", - index: 1, - responseId: "response3", - role: "assistant", - content: "Test reply 3", - createdAt: "2023-01-03T00:00:01Z", - }, - ], - documents: [ - { - id: "doc1", - name: "Document 1", - description: "Test doc", - content: "Test content", - createdAt: "2023-01-01T00:00:00Z", - }, - { - id: "doc2", - name: "Pasted", - description: "Pasted doc", - content: "Pasted content", - createdAt: "2023-01-02T00:00:00Z", - }, - ], - }; - - let initialProjectCount: number; - let initialServiceCount: number; - let initialModelCount: number; - let initialResponseCount: number; - let initialMessageCount: number; - let initialDocumentCount: number; - - function insertTestData() { - for (const project of testData.projects) { - db.run( - sql`INSERT INTO project (id, name, prompt, createdAt) VALUES (${project.id}, ${project.name}, ${project.prompt}, ${project.createdAt})`, - ); - } - for (const service of testData.services) { - db.run( - sql`INSERT INTO service (id, name, providerId, baseURL, apiKey, createdAt) VALUES (${service.id}, ${service.name}, ${service.providerId}, ${service.baseURL}, ${service.apiKey}, ${service.createdAt})`, - ); - } - for (const model of testData.models) { - db.run( - sql`INSERT INTO model (id, serviceId, name, visible, createdAt) VALUES (${model.id}, ${model.serviceId}, ${model.name}, ${model.visible}, ${model.createdAt})`, - ); - } - for (const response of testData.responses) { - db.run( - sql`INSERT INTO response (id, projectId, modelId, createdAt) VALUES (${response.id}, ${response.projectId}, ${response.modelId}, ${response.createdAt})`, - ); - } - for (const message of testData.responseMessages) { - db.run( - sql`INSERT INTO responseMessage (id, "index", responseId, role, content, createdAt) VALUES (${message.id}, ${message.index}, ${message.responseId}, ${message.role}, ${message.content}, ${message.createdAt})`, - ); - } - for (const document of testData.documents) { - db.run( - sql`INSERT INTO document (id, name, description, content, createdAt) VALUES (${document.id}, ${document.name}, ${document.description}, ${document.content}, ${document.createdAt})`, - ); - } - /* - * Verify that the initial data was inserted correctly. - * This establishes a baseline for comparison after migrations. - */ - initialProjectCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM project`, - ).count; - initialServiceCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM service`, - ).count; - initialModelCount = db.get<{ count: number }>(sql`SELECT COUNT(*) as count FROM model`).count; - initialResponseCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM response`, - ).count; - initialMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM responseMessage`, - ).count; - initialDocumentCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM document`, - ).count; - - expect(initialProjectCount).toBe(testData.projects.length); - expect(initialServiceCount).toBe(testData.services.length); - expect(initialModelCount).toBe(testData.models.length); - expect(initialResponseCount).toBe(testData.responses.length); - expect(initialMessageCount).toBe(testData.responseMessages.length); - expect(initialDocumentCount).toBe(testData.documents.length); - } - - async function applyMigrationsUpTo(targetMigration: string) { - let isFirstMigration = true; - for (const entry of journal.entries) { - if (isFirstMigration) { - await runMigration(entry.tag); - insertTestData(); - isFirstMigration = false; - } else { - await runMigration(entry.tag); - } - if (entry.tag === targetMigration) { - break; - } - } - } - - vi.mock("@/database/client"); - - beforeEach(async () => { - sqlite = new Database(":memory:"); - db = drizzle(sqlite); - vi.mocked(useDb).mockReturnValue(db); - }); - - afterEach(() => { - sqlite.close(); - vi.resetAllMocks(); - }); - - async function runMigration(migration: string) { - const migrationSql = (await import(`@/database/migrations/${migration}.sql?raw`)).default; - db.run(sql`PRAGMA foreign_keys = OFF;`); - await Promise.all( - migrationSql.split("--> statement-breakpoint").map((s: string) => db.run(sql.raw(s))), - ); - db.run(sql`PRAGMA foreign_keys = ON;`); - } - - it("0000_careful_smiling_tiger", async () => { - await applyMigrationsUpTo("0000_careful_smiling_tiger"); - - /* - * Check for unique and other indexes after the first migration - * This ensures that the initial schema is set up correctly with all necessary constraints - */ - const documentNameUniqueIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='document_name_unique'`, - ); - expect(documentNameUniqueIndex).toBeTruthy(); - - const serviceNameUniqueIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='serviceName_unique'`, - ); - expect(serviceNameUniqueIndex).toBeTruthy(); - }); - - it("0001_nosy_earthquake", async () => { - await applyMigrationsUpTo("0001_nosy_earthquake"); - - /* - * Verify data integrity after the second migration. - * The record counts should remain the same as no data was added or removed. - */ - const secondMigrationResponseCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM response`, - ).count; - const secondMigrationMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM responseMessage`, - ).count; - const secondMigrationModelCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM model`, - ).count; - - expect(secondMigrationResponseCount).toBe(initialResponseCount); - expect(secondMigrationMessageCount).toBe(initialMessageCount); - expect(secondMigrationModelCount).toBe(initialModelCount); - - /* - * Verify that the new indexes were created. - * This is crucial for ensuring the migration successfully improved query performance. - */ - const responseIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='projectId_idx'`, - ); - const messageIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='responseId_idx'`, - ); - const modelIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='serviceId_idx'`, - ); - - expect(responseIndex).toBeTruthy(); - expect(messageIndex).toBeTruthy(); - expect(modelIndex).toBeTruthy(); - - /* - * Check the structure of the new tables after the second migration - * This verifies that the tables were recreated with the correct structure - */ - const responseColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(response)`, - ); - expect(responseColumns).toContainEqual( - expect.objectContaining({ name: "error", type: "TEXT" }), - ); - - const responseMessageColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(responseMessage)`, - ); - expect(responseMessageColumns).toContainEqual( - expect.objectContaining({ name: "index", type: "INTEGER" }), - ); - - const modelColumns = db.all<{ name: string; type: string }>(sql`PRAGMA table_info(model)`); - expect(modelColumns).toContainEqual( - expect.objectContaining({ name: "visible", type: "INTEGER" }), - ); - - /* - * Test the UNIQUE constraint on the model table - * This ensures that the unique constraint on (serviceId, name) is working correctly - */ - expect(() => - db.run(sql` - INSERT INTO model (id, serviceId, name, visible, createdAt) - VALUES ('model4', 'service1', 'Test Model 1', 1, '2023-01-04T00:00:00Z') - `), - ).toThrow(); - }); - - it("0002_overjoyed_mordo", async () => { - await applyMigrationsUpTo("0002_overjoyed_mordo"); - - /* - * Verify that the 'project' table was successfully renamed to 'chat'. - * The count of records in 'chat' should match the original 'project' count. - */ - const thirdMigrationChatCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM chat`, - ).count; - expect(thirdMigrationChatCount).toBe(initialProjectCount); - - /* - * Confirm that the 'project' table no longer exists. - * This ensures the renaming was done correctly and didn't leave behind the old table. - */ - const projectTableExists = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='project'`, - ); - expect(projectTableExists).toBeFalsy(); - - /* - * Verify that the 'response' table wasn't affected by the renaming. - * Its record count should remain the same. - */ - const thirdMigrationResponseCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM response`, - ).count; - expect(thirdMigrationResponseCount).toBe(initialResponseCount); - - /* - * Check that the 'response' table now has a 'chatId' column instead of 'projectId'. - * This verifies that the foreign key was updated correctly. - */ - const chatIdColumn = db.get<{ name: string; type: string } | undefined>( - sql`PRAGMA table_info(response)`, - ); - expect(chatIdColumn).toBeTruthy(); - expect(chatIdColumn?.type).toBe("TEXT"); - - /* - * Verify that the index on 'response' was updated to use 'chatId'. - * This ensures that query performance is maintained after the schema change. - */ - const chatIdIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='chatId_idx'`, - ); - expect(chatIdIndex).toBeTruthy(); - - /* - * Verify that the data in the 'chat' table matches the original 'project' data. - * This ensures that no data was lost or corrupted during the renaming process. - */ - const chatData = db.all<{ id: string; name: string; prompt: string }>( - sql`SELECT id, name, prompt FROM chat ORDER BY id`, - ); - expect(chatData).toEqual( - testData.projects.map(({ id, name, prompt }) => ({ id, name, prompt })), - ); - /* - * Verify that the 'response' table data is correct, with 'chatId' replacing 'projectId'. - * This ensures that the foreign key relationships were properly updated. - */ - const responseData = db.all<{ id: string; chatId: string; modelId: string }>( - sql`SELECT id, chatId, modelId FROM response ORDER BY id`, - ); - expect(responseData).toEqual( - testData.responses.map(({ id, projectId: chatId, modelId }) => ({ id, chatId, modelId })), - ); - - /* - * Verify that the 'responseMessage' table data remains unchanged. - * This table wasn't directly affected by the migrations, so its data should be intact. - */ - const messageData = db.all<{ id: string; responseId: string; role: string; content: string }>( - sql`SELECT id, responseId, role, content FROM responseMessage ORDER BY id`, - ); - expect(messageData).toEqual( - testData.responseMessages.map(({ id, responseId, role, content }) => ({ - id, - responseId, - role, - content, - })), - ); - - /* - * Test the ON DELETE CASCADE behavior introduced in the third migration. - * This ensures that when a chat is deleted, its associated responses are also deleted. - */ - await db.run(sql`DELETE FROM chat WHERE id = 'project1'`); - const responseCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM response WHERE chatId = 'project1'`, - ).count; - expect(responseCount).toBe(0); - - /* - * Verify that the deletion of 'project1' didn't affect other chats' responses - */ - const remainingResponseCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM response`, - ).count; - expect(remainingResponseCount).toBe(initialResponseCount - 2); // 'project1' had 2 responses - - /* - * Check that the responseMessages associated with the deleted responses are also removed - * This tests the cascading delete behavior through multiple levels - */ - const remainingMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM responseMessage`, - ).count; - expect(remainingMessageCount).toBe(initialMessageCount - 3); // 'project1' had 3 messages - }); - - it("0003_huge_nick_fury", async () => { - await applyMigrationsUpTo("0003_huge_nick_fury"); - - // Check for the creation of new tables - const messageTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='message'`, - ); - expect(messageTable).toBeTruthy(); - - const revisionTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='revision'`, - ); - expect(revisionTable).toBeTruthy(); - - // Verify the creation of new indexes - const messageIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='message_revisionId_idx'`, - ); - expect(messageIndex).toBeTruthy(); - - const revisionIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='revision_chatId_idx'`, - ); - expect(revisionIndex).toBeTruthy(); - - // Check that data has been migrated correctly - const revisionCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM revision`, - ).count; - expect(revisionCount).toBe(initialResponseCount); - - const messageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM message`, - ).count; - expect(messageCount).toBe(initialMessageCount); - - // Verify the structure of the new tables - const revisionColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(revision)`, - ); - expect(revisionColumns).toContainEqual( - expect.objectContaining({ name: "version", type: "INTEGER" }), - ); - expect(revisionColumns).toContainEqual( - expect.objectContaining({ name: "chatId", type: "TEXT" }), - ); - - const messageColumns = db.all<{ name: string; type: string }>(sql`PRAGMA table_info(message)`); - expect(messageColumns).toContainEqual( - expect.objectContaining({ name: "revisionId", type: "TEXT" }), - ); - expect(messageColumns).toContainEqual(expect.objectContaining({ name: "role", type: "TEXT" })); - - // Verify the content of migrated data - const revisionData = db.all<{ id: string; version: number; chatId: string }>( - sql`SELECT id, version, chatId FROM revision ORDER BY chatId, createdAt`, - ); - - // Sort testData.responses by createdAt to ensure correct ordering - const sortedResponses = [...testData.responses].sort( - (a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(), - ); - - // Calculate expected versions - const chatVersions = new Map(); - const expectedRevisionData = sortedResponses.map(({ id, projectId: chatId }) => { - const currentVersion = (chatVersions.get(chatId) || 0) + 1; - chatVersions.set(chatId, currentVersion); - return { id, version: currentVersion, chatId }; - }); - - expect(revisionData).toEqual(expectedRevisionData); - - const messageData = db.all<{ id: string; revisionId: string; role: string; content: string }>( - sql`SELECT id, revisionId, role, content FROM message ORDER BY id`, - ); - expect(messageData).toEqual( - testData.responseMessages.map(({ id, responseId: revisionId, role, content }) => ({ - id, - revisionId, - role, - content, - })), - ); - - // Test cascading delete behavior - await db.run(sql`DELETE FROM chat WHERE id = 'project2'`); - const remainingRevisionCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM revision WHERE chatId = 'project2'`, - ).count; - expect(remainingRevisionCount).toBe(0); - - const remainingMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM message WHERE revisionId IN (SELECT id FROM revision WHERE chatId = 'project2')`, - ).count; - expect(remainingMessageCount).toBe(0); - - // Verify that the deletion didn't affect other chats' data - const totalRemainingRevisionCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM revision`, - ).count; - expect(totalRemainingRevisionCount).toBe(revisionCount - 1); // 'project2' had 1 response/revision - - const totalRemainingMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM message`, - ).count; - expect(totalRemainingMessageCount).toBe(messageCount - 2); // 'project2' had 2 messages - }); - - it("0004_skinny_machine_man", async () => { - await applyMigrationsUpTo("0004_skinny_machine_man"); - - // Verify that the 'response' table has been dropped - const responseTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='response'`, - ); - expect(responseTable).toBeFalsy(); - - // Verify that the 'responseMessage' table has been dropped - const responseMessageTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='responseMessage'`, - ); - expect(responseMessageTable).toBeFalsy(); - - // Verify that the 'revision' and 'message' tables still exist and contain the migrated data - const revisionCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM revision`, - ).count; - expect(revisionCount).toBe(initialResponseCount); - - const messageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM message`, - ).count; - expect(messageCount).toBe(initialMessageCount); - - // Verify that the data in the 'revision' and 'message' tables is still correct - const revisionData = db.all<{ id: string; version: number; chatId: string }>( - sql`SELECT id, version, chatId FROM revision ORDER BY chatId, createdAt`, - ); - - const chatVersions = new Map(); - const expectedRevisionData = testData.responses - .sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()) - .map(({ id, projectId: chatId }) => { - const currentVersion = (chatVersions.get(chatId) || 0) + 1; - chatVersions.set(chatId, currentVersion); - return { id, version: currentVersion, chatId }; - }); - - expect(revisionData).toEqual(expectedRevisionData); - - const messageData = db.all<{ id: string; revisionId: string; role: string; content: string }>( - sql`SELECT id, revisionId, role, content FROM message ORDER BY id`, - ); - - const expectedMessageData = testData.responseMessages.map( - ({ id, responseId: revisionId, role, content }) => ({ - id, - revisionId, - role, - content, - }), - ); - - expect(messageData).toEqual(expectedMessageData); - - // Verify that the foreign key relationships are still intact - await db.run(sql`DELETE FROM chat WHERE id = 'project1'`); - const remainingRevisionCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM revision WHERE chatId = 'project1'`, - ).count; - expect(remainingRevisionCount).toBe(0); - - const remainingMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM message WHERE revisionId IN (SELECT id FROM revision WHERE chatId = 'project1')`, - ).count; - expect(remainingMessageCount).toBe(0); - - // Final check on the total remaining data - const finalRevisionCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM revision`, - ).count; - expect(finalRevisionCount).toBe(revisionCount - 2); // 'project1' had 2 revisions - - const finalMessageCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM message`, - ).count; - expect(finalMessageCount).toBe(messageCount - 3); // 'project1' had 3 messages - }); - - it("0005_careful_the_professor", async () => { - await applyMigrationsUpTo("0005_careful_the_professor"); - - // Verify that the 'attachment' table was created - const attachmentTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='attachment'`, - ); - expect(attachmentTable).toBeTruthy(); - - // Check the structure of the 'attachment' table - const attachmentColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(attachment)`, - ); - expect(attachmentColumns).toContainEqual( - expect.objectContaining({ - name: "id", - type: "TEXT", - }), - ); - expect(attachmentColumns).toContainEqual( - expect.objectContaining({ - name: "messageId", - type: "TEXT", - }), - ); - expect(attachmentColumns).toContainEqual( - expect.objectContaining({ - name: "documentId", - type: "TEXT", - }), - ); - expect(attachmentColumns).toContainEqual( - expect.objectContaining({ - name: "createdAt", - type: "TEXT", - }), - ); - - // Verify that the 'type' column was added to the 'document' table - const documentColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(document)`, - ); - expect(documentColumns).toContainEqual(expect.objectContaining({ name: "type", type: "TEXT" })); - - // Check if the indexes were created - const attachmentMessageIdIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='attachment_messageId_idx'`, - ); - expect(attachmentMessageIdIndex).toBeTruthy(); - - const messageDocumentUniqueIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='messageDocument_unique'`, - ); - expect(messageDocumentUniqueIndex).toBeTruthy(); - - // Test foreign key constraints - const message = db.get<{ id: string }>(sql`SELECT id FROM message LIMIT 1`); - const document = db.get<{ id: string }>(sql`SELECT id FROM document LIMIT 1`); - - if (message && document) { - // Insert a valid attachment - db.run( - sql`INSERT INTO attachment (id, messageId, documentId) VALUES ('test1', ${message.id}, ${document.id})`, - ); - - // Attempt to insert an attachment with non-existent messageId (should fail) - expect(() => - db.run( - sql`INSERT INTO attachment (id, messageId, documentId) VALUES ('test2', 'non_existent', ${document.id})`, - ), - ).toThrow(); - - // Attempt to insert an attachment with non-existent documentId (should fail) - expect(() => - db.run( - sql`INSERT INTO attachment (id, messageId, documentId) VALUES ('test3', ${message.id}, 'non_existent')`, - ), - ).toThrow(); - - // Test cascade delete - db.run(sql`DELETE FROM message WHERE id = ${message.id}`); - const attachmentAfterDelete = db.get( - sql`SELECT * FROM attachment WHERE messageId = ${message.id}`, - ); - expect(attachmentAfterDelete).toBeFalsy(); - } - }); - - it("0006_opposite_sugar_man", async () => { - await applyMigrationsUpTo("0006_opposite_sugar_man"); - - // Verify that the 'attributes' column was added to the 'document' table - const documentColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(document)`, - ); - expect(documentColumns).toContainEqual( - expect.objectContaining({ name: "attributes", type: "TEXT" }), - ); - - // Check if the default value is set correctly - const document = db.get<{ attributes: string }>(sql`SELECT attributes FROM document LIMIT 1`); - expect(document?.attributes).toBe("{}"); - - // Test inserting a document with custom attributes - db.run( - sql`INSERT INTO document (id, name, type, description, content, attributes) VALUES ('test_doc', 'Test Document', 'document', 'Test description', 'Test content', '{"key": "value"}')`, - ); - const insertedDocument = db.get<{ attributes: string }>( - sql`SELECT attributes FROM document WHERE id = 'test_doc'`, - ); - expect(insertedDocument?.attributes).toBe('{"key": "value"}'); - - // Verify that existing documents have the default attributes value - const existingDocuments = db.all<{ id: string; attributes: string }>( - sql`SELECT id, attributes FROM document WHERE id != 'test_doc'`, - ); - existingDocuments.forEach((doc) => { - expect(doc.attributes).toBe("{}"); - }); - }); - - it("0007_tidy_lilandra", async () => { - await applyMigrationsUpTo("0007_tidy_lilandra"); - - // Verify that the 'document_name_unique' index was dropped - const documentNameUniqueIndex = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='document_name_unique'`, - ); - expect(documentNameUniqueIndex).toBeFalsy(); - - // Test that we can now insert documents with the same name - db.run( - sql`INSERT INTO document (id, name, type, description, content) VALUES ('doc3', 'Same Name', 'document', 'Test description', 'Test content')`, - ); - db.run( - sql`INSERT INTO document (id, name, type, description, content) VALUES ('doc4', 'Same Name', 'document', 'Test description', 'Test content')`, - ); - - const documentsWithSameName = db.all<{ id: string }>( - sql`SELECT id FROM document WHERE name = 'Same Name'`, - ); - expect(documentsWithSameName.length).toBe(2); - - // Verify that other constraints and data remain intact - const documentCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM document`, - ).count; - expect(documentCount).toBe(initialDocumentCount + 2); // Initial count plus the two we just added - }); - - it("0008_parallel_grandmaster", async () => { - await applyMigrationsUpTo("0008_parallel_grandmaster"); - - // Verify that 'aiService' table was renamed to 'aiAccount' - const aiAccountTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='aiAccount'`, - ); - expect(aiAccountTable).toBeTruthy(); - - const aiServiceTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='aiService'`, - ); - expect(aiServiceTable).toBeFalsy(); - - // Check that 'aiServiceId' column in 'model' table was renamed to 'aiAccountId' - const modelColumns = db.all<{ name: string; type: string }>(sql`PRAGMA table_info(aiModel)`); - expect(modelColumns).toContainEqual( - expect.objectContaining({ name: "aiAccountId", type: "TEXT" }), - ); - expect(modelColumns).not.toContainEqual(expect.objectContaining({ name: "aiServiceId" })); - - // Verify that 'providerId' column in 'aiAccount' table was renamed to 'aiServiceId' - const aiAccountColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(aiAccount)`, - ); - expect(aiAccountColumns).toContainEqual( - expect.objectContaining({ name: "aiServiceId", type: "TEXT" }), - ); - expect(aiAccountColumns).not.toContainEqual(expect.objectContaining({ name: "providerId" })); - - // Check that the new indexes were created - const aiAccountIdIdx = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='aiAccountId_idx'`, - ); - expect(aiAccountIdIdx).toBeTruthy(); - - const aiAccountIdUnique = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='aiAccountId_unique'`, - ); - expect(aiAccountIdUnique).toBeTruthy(); - - // Verify that the old indexes were dropped - const aiServiceIdIdx = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='aiServiceId_idx'`, - ); - expect(aiServiceIdIdx).toBeFalsy(); - - const aiServiceNameUnique = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='index' AND name='aiServiceName_unique'`, - ); - expect(aiServiceNameUnique).toBeFalsy(); - - // Verify that the data was migrated correctly - const aiAccountCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM aiAccount`, - ).count; - expect(aiAccountCount).toBe(initialServiceCount); - - const modelCount = db.get<{ count: number }>(sql`SELECT COUNT(*) as count FROM aiModel`).count; - expect(modelCount).toBe(initialModelCount); - - // Verify the content of migrated data - const aiAccountData = db.all<{ id: string; name: string; aiServiceId: string }>( - sql`SELECT id, name, aiServiceId FROM aiAccount ORDER BY id`, - ); - expect(aiAccountData).toEqual( - testData.services.map(({ id, name, providerId: aiServiceId }) => ({ id, name, aiServiceId })), - ); - - const modelData = db.all<{ id: string; aiAccountId: string; name: string; visible: number }>( - sql`SELECT id, aiAccountId, name, visible FROM aiModel ORDER BY id`, - ); - expect(modelData).toEqual( - testData.models.map(({ id, serviceId: aiAccountId, name, visible }) => ({ - id, - aiAccountId, - name, - visible, - })), - ); - - // Test the new foreign key constraint - const aiAccount = db.get<{ id: string }>(sql`SELECT id FROM aiAccount LIMIT 1`); - expect(aiAccount).toBeTruthy(); - - // Insert a valid model - db.run( - sql`INSERT INTO aiModel (id, aiAccountId, name, visible) VALUES ('test_model', ${aiAccount.id}, 'Test Model', 1)`, - ); - - // Attempt to insert a model with non-existent aiAccountId (should fail) - expect(() => - db.run( - sql`INSERT INTO aiModel (id, aiAccountId, name, visible) VALUES ('invalid_model', 'non_existent', 'Invalid Model', 1)`, - ), - ).toThrow(); - - // Test cascade delete - db.run(sql`DELETE FROM aiAccount WHERE id = ${aiAccount.id}`); - const modelAfterDelete = db.get(sql`SELECT * FROM aiModel WHERE aiAccountId = ${aiAccount.id}`); - expect(modelAfterDelete).toBeFalsy(); - }); - - it("0009_ancient_korath", async () => { - await applyMigrationsUpTo("0009_ancient_korath"); - - // Verify that the 'aiSdk' table was created - const aiSdkTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='aiSdk'`, - ); - expect(aiSdkTable).toBeTruthy(); - - // Verify that the 'aiService' table was created - const aiServiceTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='aiService'`, - ); - expect(aiServiceTable).toBeTruthy(); - - // Check the structure of the 'aiSdk' table - const aiSdkColumns = db.all<{ name: string; type: string }>(sql`PRAGMA table_info(aiSdk)`); - expect(aiSdkColumns).toContainEqual(expect.objectContaining({ name: "id", type: "TEXT" })); - expect(aiSdkColumns).toContainEqual(expect.objectContaining({ name: "slug", type: "TEXT" })); - expect(aiSdkColumns).toContainEqual(expect.objectContaining({ name: "name", type: "TEXT" })); - - // Check the structure of the 'aiService' table - const aiServiceColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(aiService)`, - ); - expect(aiServiceColumns).toContainEqual(expect.objectContaining({ name: "id", type: "TEXT" })); - expect(aiServiceColumns).toContainEqual( - expect.objectContaining({ name: "name", type: "TEXT" }), - ); - expect(aiServiceColumns).toContainEqual( - expect.objectContaining({ name: "aiSdkId", type: "TEXT" }), - ); - expect(aiServiceColumns).toContainEqual( - expect.objectContaining({ name: "baseURL", type: "TEXT" }), - ); - expect(aiServiceColumns).toContainEqual( - expect.objectContaining({ name: "createdAt", type: "TEXT" }), - ); - - // Verify that the initial data was inserted correctly - const aiSdkCount = db.get<{ count: number }>(sql`SELECT COUNT(*) as count FROM aiSdk`).count; - expect(aiSdkCount).toBe(8); // 11 SDKs were inserted - - const aiServiceCount = db.get<{ count: number }>( - sql`SELECT COUNT(*) as count FROM aiService`, - ).count; - expect(aiServiceCount).toBe(11); // 11 services were inserted - - // Check some specific entries to ensure data integrity - const openaiSdk = db.get<{ id: string; slug: string; name: string }>( - sql`SELECT * FROM aiSdk WHERE id = 'openai'`, - ); - expect(openaiSdk).toEqual({ id: "openai", slug: "openai", name: "OpenAI" }); - - const azureService = db.get(sql`SELECT * FROM aiService WHERE id = 'azure'`); - expect(azureService).toMatchObject({ - id: "azure", - name: "Azure OpenAI", - aiSdkId: "azure", - baseURL: null, - }); - - // // Test unique constraint on aiSdk slug - // expect(() => - // db.run(sql`INSERT INTO aiSdk (id, slug, name) VALUES ('test', 'openai', 'Test SDK')`), - // ).toThrow(); - - // Verify that the aiAccount table still exists and maintains its relationship with aiService - const aiAccountTable = db.get<{ name: string } | undefined>( - sql`SELECT name FROM sqlite_master WHERE type='table' AND name='aiAccount'`, - ); - expect(aiAccountTable).toBeTruthy(); - - const aiAccountColumns = db.all<{ name: string; type: string }>( - sql`PRAGMA table_info(aiAccount)`, - ); - expect(aiAccountColumns).toContainEqual( - expect.objectContaining({ name: "aiServiceId", type: "TEXT" }), - ); - }); - - it("0010_far_wiccan", async () => { - await applyMigrationsUpTo("0010_far_wiccan"); - - // Test unique constraint on aiSdk slug - expect(() => - db.run(sql`INSERT INTO aiSdk (id, slug, name) VALUES ('test', 'openai', 'Test SDK')`), - ).toThrow(); - }); -}); diff --git a/src/database/migrations/0000_careful_smiling_tiger.sql b/src/database/migrations/0000_careful_smiling_tiger.sql deleted file mode 100644 index 74f321c..0000000 --- a/src/database/migrations/0000_careful_smiling_tiger.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE `document` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `description` text NOT NULL, - `content` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP) -); ---> statement-breakpoint -CREATE TABLE `model` ( - `id` text PRIMARY KEY NOT NULL, - `serviceId` text NOT NULL, - `name` text NOT NULL, - `visible` integer NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`serviceId`) REFERENCES `service`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `project` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `prompt` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP) -); ---> statement-breakpoint -CREATE TABLE `responseMessage` ( - `id` text PRIMARY KEY NOT NULL, - `index` integer NOT NULL, - `responseId` text NOT NULL, - `role` text NOT NULL, - `content` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`responseId`) REFERENCES `response`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `response` ( - `id` text PRIMARY KEY NOT NULL, - `projectId` text NOT NULL, - `modelId` text NOT NULL, - `error` text, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`projectId`) REFERENCES `project`(`id`) ON UPDATE no action ON DELETE no action, - FOREIGN KEY (`modelId`) REFERENCES `model`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `service` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `providerId` text NOT NULL, - `baseURL` text NOT NULL, - `apiKey` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP) -); ---> statement-breakpoint -CREATE UNIQUE INDEX `document_name_unique` ON `document` (`name`);--> statement-breakpoint -CREATE INDEX `serviceId_idx` ON `model` (`serviceId`);--> statement-breakpoint -CREATE UNIQUE INDEX `serviceName_unique` ON `model` (`serviceId`,`name`);--> statement-breakpoint -CREATE INDEX `responseId_idx` ON `responseMessage` (`responseId`);--> statement-breakpoint -CREATE INDEX `projectId_idx` ON `response` (`projectId`); \ No newline at end of file diff --git a/src/database/migrations/0000_nappy_the_liberteens.sql b/src/database/migrations/0000_nappy_the_liberteens.sql new file mode 100644 index 0000000..682d5c9 --- /dev/null +++ b/src/database/migrations/0000_nappy_the_liberteens.sql @@ -0,0 +1,111 @@ +CREATE TABLE IF NOT EXISTS "attachment" ( + "id" text PRIMARY KEY NOT NULL, + "message_id" text NOT NULL, + "document_id" text NOT NULL, + "created_at" text DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT "message_document_unique" UNIQUE("message_id","document_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "chat" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "prompt" text NOT NULL, + "created_at" text DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "document" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "type" text DEFAULT 'document' NOT NULL, + "description" text NOT NULL, + "content" text NOT NULL, + "attributes" jsonb DEFAULT '{}'::jsonb NOT NULL, + "created_at" text DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "key" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "service_id" text NOT NULL, + "base_url" text, + "api_key" text NOT NULL, + "created_at" text DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "message" ( + "id" text PRIMARY KEY NOT NULL, + "index" integer NOT NULL, + "revision_id" text NOT NULL, + "role" text NOT NULL, + "content" text NOT NULL, + "created_at" text DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "model" ( + "id" text PRIMARY KEY NOT NULL, + "key_id" text NOT NULL, + "name" text NOT NULL, + "visible" integer NOT NULL, + "created_at" text DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT "account_id_unique" UNIQUE("key_id","name") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "revision" ( + "id" text PRIMARY KEY NOT NULL, + "version" integer NOT NULL, + "chat_id" text NOT NULL, + "error" text, + "created_at" text DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "sdk" ( + "id" text PRIMARY KEY NOT NULL, + "slug" text NOT NULL, + "type" text DEFAULT 'model' NOT NULL, + "name" text NOT NULL, + "supported" integer DEFAULT 1 NOT NULL, + CONSTRAINT "slug_unique" UNIQUE("slug") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "service" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "sdk_id" text NOT NULL, + "base_url" text, + "created_at" text DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "attachment" ADD CONSTRAINT "attachment_message_id_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."message"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "attachment" ADD CONSTRAINT "attachment_document_id_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."document"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "message" ADD CONSTRAINT "message_revision_id_revision_id_fk" FOREIGN KEY ("revision_id") REFERENCES "public"."revision"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "model" ADD CONSTRAINT "model_key_id_key_id_fk" FOREIGN KEY ("key_id") REFERENCES "public"."key"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "revision" ADD CONSTRAINT "revision_chat_id_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chat"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "attachment_message_id_idx" ON "attachment" USING btree ("message_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "message_revision_id_idx" ON "message" USING btree ("revision_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "account_id_idx" ON "model" USING btree ("key_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "revision_chat_id_idx" ON "revision" USING btree ("chat_id"); \ No newline at end of file diff --git a/src/database/migrations/0001_nosy_earthquake.sql b/src/database/migrations/0001_nosy_earthquake.sql deleted file mode 100644 index 556dbf4..0000000 --- a/src/database/migrations/0001_nosy_earthquake.sql +++ /dev/null @@ -1,54 +0,0 @@ -CREATE TABLE new_response ( - id TEXT PRIMARY KEY, - projectId TEXT NOT NULL, - modelId TEXT NOT NULL, - error TEXT, - createdAt TEXT DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (projectId) REFERENCES project(id) ON DELETE CASCADE -); ---> statement-breakpoint -INSERT INTO new_response SELECT * FROM response; ---> statement-breakpoint -DROP TABLE response; ---> statement-breakpoint -ALTER TABLE new_response RENAME TO response; ---> statement-breakpoint -CREATE TABLE new_responseMessage ( - id TEXT PRIMARY KEY, - "index" INTEGER NOT NULL, - responseId TEXT NOT NULL, - role TEXT NOT NULL, - content TEXT NOT NULL, - createdAt TEXT DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (responseId) REFERENCES response(id) ON DELETE CASCADE -); ---> statement-breakpoint -INSERT INTO new_responseMessage SELECT * FROM responseMessage; ---> statement-breakpoint -DROP TABLE responseMessage; ---> statement-breakpoint -ALTER TABLE new_responseMessage RENAME TO responseMessage; ---> statement-breakpoint -CREATE TABLE new_model ( - id TEXT PRIMARY KEY, - serviceId TEXT NOT NULL, - name TEXT NOT NULL, - visible INTEGER NOT NULL, - createdAt TEXT DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (serviceId) REFERENCES service(id) ON DELETE CASCADE, - UNIQUE (serviceId, name) -); ---> statement-breakpoint -INSERT INTO new_model SELECT * FROM model; ---> statement-breakpoint -DROP TABLE model; ---> statement-breakpoint -ALTER TABLE new_model RENAME TO model; ---> statement-breakpoint -CREATE INDEX projectId_idx ON response(projectId); ---> statement-breakpoint -CREATE INDEX responseId_idx ON responseMessage(responseId); ---> statement-breakpoint -CREATE INDEX serviceId_idx ON model(serviceId); ---> statement-breakpoint -CREATE UNIQUE INDEX `serviceName_unique` ON `model` (`serviceId`,`name`); diff --git a/src/database/migrations/0002_overjoyed_mordo.sql b/src/database/migrations/0002_overjoyed_mordo.sql deleted file mode 100644 index 3d79d39..0000000 --- a/src/database/migrations/0002_overjoyed_mordo.sql +++ /dev/null @@ -1,41 +0,0 @@ -ALTER TABLE `project` RENAME TO `chat`; ---> statement-breakpoint -ALTER TABLE `response` RENAME COLUMN `projectId` TO `chatId`; ---> statement-breakpoint -DROP INDEX IF EXISTS `projectId_idx`; ---> statement-breakpoint -CREATE TABLE `new_response` ( - `id` text PRIMARY KEY NOT NULL, - `chatId` text NOT NULL, - `modelId` text NOT NULL, - `error` text, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`chatId`) REFERENCES `chat`(`id`) ON UPDATE no action ON DELETE cascade -); ---> statement-breakpoint -INSERT INTO `new_response` SELECT * FROM `response`; ---> statement-breakpoint -DROP TABLE `response`; ---> statement-breakpoint -ALTER TABLE `new_response` RENAME TO `response`; ---> statement-breakpoint -CREATE INDEX `chatId_idx` ON `response` (`chatId`); ---> statement-breakpoint --- Must recreate responseMessage so that its foreign key references the new response table -CREATE TABLE `new_responseMessage` ( - `id` text PRIMARY KEY NOT NULL, - `index` integer NOT NULL, - `responseId` text NOT NULL, - `role` text NOT NULL, - `content` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`responseId`) REFERENCES `response`(`id`) ON DELETE CASCADE -); ---> statement-breakpoint -INSERT INTO `new_responseMessage` SELECT * FROM `responseMessage`; ---> statement-breakpoint -DROP TABLE `responseMessage`; ---> statement-breakpoint -ALTER TABLE `new_responseMessage` RENAME TO `responseMessage`; ---> statement-breakpoint -CREATE INDEX `responseId_idx` ON `responseMessage` (`responseId`); diff --git a/src/database/migrations/0003_huge_nick_fury.sql b/src/database/migrations/0003_huge_nick_fury.sql deleted file mode 100644 index 2a8d2cd..0000000 --- a/src/database/migrations/0003_huge_nick_fury.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE IF NOT EXISTS `message` ( - `id` text PRIMARY KEY NOT NULL, - `index` integer NOT NULL, - `revisionId` text NOT NULL, - `role` text NOT NULL, - `content` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`revisionId`) REFERENCES `revision`(`id`) ON UPDATE no action ON DELETE cascade -); ---> statement-breakpoint -CREATE TABLE `revision` ( - `id` text PRIMARY KEY NOT NULL, - `version` integer NOT NULL, - `chatId` text NOT NULL, - `error` text, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`chatId`) REFERENCES `chat`(`id`) ON UPDATE no action ON DELETE cascade -); ---> statement-breakpoint -CREATE INDEX `message_revisionId_idx` ON `message` (`revisionId`);--> statement-breakpoint -CREATE INDEX `revision_chatId_idx` ON `revision` (`chatId`); ---> statement-breakpoint -INSERT INTO revision ("id", "version", "chatId", "error", "createdAt") -SELECT - r."id", - (SELECT COUNT(*) - FROM response r2 - WHERE r2."chatId" = r."chatId" AND r2."createdAt" <= r."createdAt") AS version, - r."chatId", - r."error", - r."createdAt" -FROM response r; ---> statement-breakpoint -INSERT INTO message ("id", "index", "revisionId", "role", "content", "createdAt") -SELECT - rm."id", - rm."index", - rm."responseId" AS revisionId, - rm."role", - rm."content", - rm."createdAt" -FROM responseMessage rm; diff --git a/src/database/migrations/0004_skinny_machine_man.sql b/src/database/migrations/0004_skinny_machine_man.sql deleted file mode 100644 index 1ad903b..0000000 --- a/src/database/migrations/0004_skinny_machine_man.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE `responseMessage`;--> statement-breakpoint -DROP TABLE `response`; \ No newline at end of file diff --git a/src/database/migrations/0005_careful_the_professor.sql b/src/database/migrations/0005_careful_the_professor.sql deleted file mode 100644 index 9df08f5..0000000 --- a/src/database/migrations/0005_careful_the_professor.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE `attachment` ( - `id` text PRIMARY KEY NOT NULL, - `messageId` text NOT NULL, - `documentId` text NOT NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`messageId`) REFERENCES `message`(`id`) ON UPDATE no action ON DELETE cascade, - FOREIGN KEY (`documentId`) REFERENCES `document`(`id`) ON UPDATE no action ON DELETE cascade -); ---> statement-breakpoint -ALTER TABLE `document` ADD `type` text DEFAULT 'document' NOT NULL;--> statement-breakpoint -CREATE INDEX `attachment_messageId_idx` ON `attachment` (`messageId`);--> statement-breakpoint -CREATE UNIQUE INDEX `messageDocument_unique` ON `attachment` (`messageId`,`documentId`); \ No newline at end of file diff --git a/src/database/migrations/0006_opposite_sugar_man.sql b/src/database/migrations/0006_opposite_sugar_man.sql deleted file mode 100644 index 08dc1a6..0000000 --- a/src/database/migrations/0006_opposite_sugar_man.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `document` ADD `attributes` text DEFAULT '{}' NOT NULL; \ No newline at end of file diff --git a/src/database/migrations/0007_tidy_lilandra.sql b/src/database/migrations/0007_tidy_lilandra.sql deleted file mode 100644 index a77c9f1..0000000 --- a/src/database/migrations/0007_tidy_lilandra.sql +++ /dev/null @@ -1 +0,0 @@ -DROP INDEX IF EXISTS `document_name_unique`; \ No newline at end of file diff --git a/src/database/migrations/0008_parallel_grandmaster.sql b/src/database/migrations/0008_parallel_grandmaster.sql deleted file mode 100644 index ed516e0..0000000 --- a/src/database/migrations/0008_parallel_grandmaster.sql +++ /dev/null @@ -1,46 +0,0 @@ -ALTER TABLE `service` RENAME TO `aiAccount`;--> statement-breakpoint -ALTER TABLE `model` RENAME TO `aiModel`;--> statement-breakpoint -ALTER TABLE `aiModel` RENAME COLUMN `serviceId` TO `aiAccountId`;--> statement-breakpoint -ALTER TABLE `aiAccount` RENAME COLUMN `providerId` TO `aiServiceId`;--> statement-breakpoint - -DROP INDEX IF EXISTS `serviceId_idx`;--> statement-breakpoint -DROP INDEX IF EXISTS `serviceName_unique`;--> statement-breakpoint -CREATE INDEX `aiAccountId_idx` ON `aiModel` (`aiAccountId`);--> statement-breakpoint -CREATE UNIQUE INDEX `aiAccountId_unique` ON `aiModel` (`aiAccountId`,`name`); ---> statement-breakpoint -ALTER TABLE `aiModel` RENAME TO `aiModel_old`; ---> statement-breakpoint -CREATE TABLE `aiModel` ( - `id` TEXT PRIMARY KEY NOT NULL, - `aiAccountId` TEXT NOT NULL, - `name` TEXT NOT NULL, - `visible` INTEGER NOT NULL, - `createdAt` TEXT DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`aiAccountId`) REFERENCES `aiAccount`(`id`) ON DELETE CASCADE -); ---> statement-breakpoint -INSERT INTO `aiModel` (`id`, `aiAccountId`, `name`, `visible`, `createdAt`) -SELECT `id`, `aiAccountId`, `name`, `visible`, `createdAt` -FROM `aiModel_old`; ---> statement-breakpoint -DROP TABLE `aiModel_old`; ---> statement-breakpoint -CREATE INDEX `aiAccountId_idx` ON `aiModel` (`aiAccountId`); ---> statement-breakpoint -CREATE UNIQUE INDEX `aiAccountId_unique` ON `aiModel` (`aiAccountId`,`name`); ---> statement-breakpoint --- Make baseURL nullable in aiAccount table -CREATE TABLE `aiAccount_new` ( - `id` TEXT PRIMARY KEY NOT NULL, - `name` TEXT NOT NULL, - `aiServiceId` TEXT NOT NULL, - `baseURL` TEXT, - `apiKey` TEXT NOT NULL, - `createdAt` TEXT DEFAULT (CURRENT_TIMESTAMP) -); ---> statement-breakpoint -INSERT INTO `aiAccount_new` SELECT * FROM `aiAccount`; ---> statement-breakpoint -DROP TABLE `aiAccount`; ---> statement-breakpoint -ALTER TABLE `aiAccount_new` RENAME TO `aiAccount`; diff --git a/src/database/migrations/0009_ancient_korath.sql b/src/database/migrations/0009_ancient_korath.sql deleted file mode 100644 index 85ef4e5..0000000 --- a/src/database/migrations/0009_ancient_korath.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE `aiSdk` ( - `id` text PRIMARY KEY NOT NULL, - `slug` text NOT NULL, - `name` text NOT NULL -); ---> statement-breakpoint -CREATE TABLE `aiService` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `aiSdkId` text NOT NULL, - `baseURL` text NULL, - `createdAt` text DEFAULT (CURRENT_TIMESTAMP) -); ---> statement-breakpoint -INSERT INTO aiSdk (id, slug, name) VALUES -('openai', 'openai', 'OpenAI'), -('azure', 'azure', 'Azure'), -('anthropic', 'anthropic', 'Anthropic'), -('amazon', 'amazon', 'Amazon Bedrock'), -('google-gen-ai', 'google-gen-ai', 'Google Generative AI'), -('google-vertex', 'google-vertex', 'Google Vertex AI'), -('mistral', 'mistral', 'Mistral'), -('cohere', 'cohere', 'Cohere'); ---> statement-breakpoint -INSERT INTO aiService (id, name, aiSdkId, baseURL) VALUES -('openai', 'OpenAI', 'openai', NULL), -('azure', 'Azure OpenAI', 'azure', NULL), -('anthropic', 'Anthropic', 'anthropic', NULL), -('amazon-bedrock', 'Amazon Bedrock', 'amazon', NULL), -('google-gen-ai', 'Google Generative AI', 'google-gen-ai', NULL), -('google-vertex', 'Google Vertex AI', 'google-vertex', NULL), -('mistral', 'Mistral', 'mistral', NULL), -('groq', 'Groq', 'openai', 'https://api.groq.com/openai/v1'), -('perplexity', 'Perplexity', 'openai', 'https://api.perplexity.ai/'), -('fireworks', 'Fireworks', 'openai', 'https://api.fireworks.ai/inference/v1'), -('nvidia', 'Nvidia', 'openai', 'https://integrate.api.nvidia.com/v1'), -('cohere', 'Cohere', 'cohere', NULL); - diff --git a/src/database/migrations/0010_far_wiccan.sql b/src/database/migrations/0010_far_wiccan.sql deleted file mode 100644 index db1ec47..0000000 --- a/src/database/migrations/0010_far_wiccan.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE UNIQUE INDEX `slug_unique` ON `aiSdk` (`slug`); \ No newline at end of file diff --git a/src/database/migrations/0011_easy_slapstick.sql b/src/database/migrations/0011_easy_slapstick.sql deleted file mode 100644 index 198f4f0..0000000 --- a/src/database/migrations/0011_easy_slapstick.sql +++ /dev/null @@ -1,47 +0,0 @@ -ALTER TABLE `aiAccount` RENAME TO `key`;--> statement-breakpoint -ALTER TABLE `aiModel` RENAME TO `model`;--> statement-breakpoint -ALTER TABLE `aiSdk` RENAME TO `sdk`;--> statement-breakpoint -ALTER TABLE `aiService` RENAME TO `service`;--> statement-breakpoint -ALTER TABLE `key` RENAME COLUMN `aiServiceId` TO `serviceId`;--> statement-breakpoint -ALTER TABLE `model` RENAME COLUMN `aiAccountId` TO `keyId`;--> statement-breakpoint -ALTER TABLE `service` RENAME COLUMN `aiSdkId` TO `sdkId`;--> statement-breakpoint -DROP INDEX IF EXISTS `accountId_idx`;--> statement-breakpoint -DROP INDEX IF EXISTS `accountId_unique`;--> statement-breakpoint -CREATE INDEX `accountId_idx` ON `model` (`keyId`);--> statement-breakpoint -CREATE UNIQUE INDEX `accountId_unique` ON `model` (`keyId`,`name`);--> statement-breakpoint -ALTER TABLE `model` RENAME TO `model_old`; ---> statement-breakpoint -CREATE TABLE `model` ( - `id` TEXT PRIMARY KEY NOT NULL, - `keyId` TEXT NOT NULL, - `name` TEXT NOT NULL, - `visible` INTEGER NOT NULL, - `createdAt` TEXT DEFAULT (CURRENT_TIMESTAMP), - FOREIGN KEY (`keyId`) REFERENCES `key`(`id`) ON DELETE CASCADE -); ---> statement-breakpoint -INSERT INTO `model` (`id`, `keyId`, `name`, `visible`, `createdAt`) -SELECT `id`, `keyId`, `name`, `visible`, `createdAt` -FROM `model_old`; ---> statement-breakpoint -DROP TABLE `model_old`; ---> statement-breakpoint -CREATE INDEX `keyId_idx` ON `model` (`keyId`); ---> statement-breakpoint -CREATE UNIQUE INDEX `keyId_unique` ON `model` (`keyId`,`name`); ---> statement-breakpoint --- Make baseURL nullable in key table -CREATE TABLE `key_new` ( - `id` TEXT PRIMARY KEY NOT NULL, - `name` TEXT NOT NULL, - `serviceId` TEXT NOT NULL, - `baseURL` TEXT, - `apiKey` TEXT NOT NULL, - `createdAt` TEXT DEFAULT (CURRENT_TIMESTAMP) -); ---> statement-breakpoint -INSERT INTO `key_new` SELECT * FROM `key`; ---> statement-breakpoint -DROP TABLE `key`; ---> statement-breakpoint -ALTER TABLE `key_new` RENAME TO `key`; diff --git a/src/database/migrations/0012_soft_trish_tilby.sql b/src/database/migrations/0012_soft_trish_tilby.sql deleted file mode 100644 index c814438..0000000 --- a/src/database/migrations/0012_soft_trish_tilby.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE `sdk` ADD `supported` integer DEFAULT 1 NOT NULL; ---> statement-breakpoint -/* Disable Azure, Amazon Bedrock. No method to input extra options yet */ -UPDATE `sdk` SET `supported` = 0 WHERE `id` = 'azure'; ---> statement-breakpoint -UPDATE `sdk` SET `supported` = 0 WHERE `id` = 'amazon'; ---> statement-breakpoint -UPDATE `sdk` SET `supported` = 0 WHERE `id` = 'google-vertex'; diff --git a/src/database/migrations/0013_tiny_glorian.sql b/src/database/migrations/0013_tiny_glorian.sql deleted file mode 100644 index 39e5fc2..0000000 --- a/src/database/migrations/0013_tiny_glorian.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE `sdk` ADD `type` text DEFAULT 'model' NOT NULL; ---> statement-breakpoint -INSERT INTO sdk (id, slug, type, name) VALUES -('unstructured', 'unstructured', 'document', 'Unstructured'); ---> statement-breakpoint -INSERT INTO service (id, name, sdkId, baseURL) VALUES -('unstructured', 'Unstructured', 'unstructured', 'https://api.unstructured.io/general/v0/general'); diff --git a/src/database/migrations/meta/0000_snapshot.json b/src/database/migrations/meta/0000_snapshot.json index 42c48f9..5ceda9f 100644 --- a/src/database/migrations/meta/0000_snapshot.json +++ b/src/database/migrations/meta/0000_snapshot.json @@ -1,168 +1,226 @@ { - "version": "6", - "dialect": "sqlite", - "id": "e48d9370-c57b-4cce-95ab-c80a492bbe34", + "id": "c8f95801-d339-42a4-a17d-d8ec8c06b21f", "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", "tables": { - "document": { - "name": "document", + "public.attachment": { + "name": "attachment", + "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "description": { - "name": "description", + "message_id": { + "name": "message_id", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "content": { - "name": "content", + "document_id": { + "name": "document_id", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "createdAt": { - "name": "createdAt", + "created_at": { + "name": "created_at", "type": "text", "primaryKey": false, "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" + "default": "CURRENT_TIMESTAMP" } }, "indexes": { - "document_name_unique": { - "name": "document_name_unique", + "attachment_message_id_idx": { + "name": "attachment_message_id_idx", "columns": [ - "name" + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } ], - "isUnique": true + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "attachment_message_id_message_id_fk": { + "name": "attachment_message_id_message_id_fk", + "tableFrom": "attachment", + "tableTo": "message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "attachment_document_id_document_id_fk": { + "name": "attachment_document_id_document_id_fk", + "tableFrom": "attachment", + "tableTo": "document", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" } }, - "foreignKeys": {}, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": { + "message_document_unique": { + "name": "message_document_unique", + "nullsNotDistinct": false, + "columns": [ + "message_id", + "document_id" + ] + } + } }, - "model": { - "name": "model", + "public.chat": { + "name": "chat", + "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, - "notNull": true, - "autoincrement": false + "notNull": true }, - "serviceId": { - "name": "serviceId", + "name": { + "name": "name", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.document": { + "name": "document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, "notNull": true, - "autoincrement": false + "default": "'document'" }, - "visible": { - "name": "visible", - "type": "integer", + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attributes": { + "name": "attributes", + "type": "jsonb", "primaryKey": false, "notNull": true, - "autoincrement": false + "default": "'{}'::jsonb" }, - "createdAt": { - "name": "createdAt", + "created_at": { + "name": "created_at", "type": "text", "primaryKey": false, "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" + "default": "CURRENT_TIMESTAMP" } }, + "indexes": {}, + "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, - "project": { - "name": "project", + "public.key": { + "name": "key", + "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, - "notNull": true, - "autoincrement": false + "notNull": true }, "name": { "name": "name", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "prompt": { - "name": "prompt", + "service_id": { + "name": "service_id", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": true }, - "createdAt": { - "name": "createdAt", + "created_at": { + "name": "created_at", "type": "text", "primaryKey": false, "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" + "default": "CURRENT_TIMESTAMP" } }, "indexes": {}, @@ -170,205 +228,318 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {} }, - "responseMessage": { - "name": "responseMessage", + "public.message": { + "name": "message", + "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, - "notNull": true, - "autoincrement": false + "notNull": true }, "index": { "name": "index", "type": "integer", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "responseId": { - "name": "responseId", + "revision_id": { + "name": "revision_id", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, "role": { "name": "role", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, "content": { "name": "content", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "createdAt": { - "name": "createdAt", + "created_at": { + "name": "created_at", "type": "text", "primaryKey": false, "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" + "default": "CURRENT_TIMESTAMP" } }, "indexes": { - "responseId_idx": { - "name": "responseId_idx", + "message_revision_id_idx": { + "name": "message_revision_id_idx", "columns": [ - "responseId" + { + "expression": "revision_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } ], - "isUnique": false + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { - "responseMessage_responseId_response_id_fk": { - "name": "responseMessage_responseId_response_id_fk", - "tableFrom": "responseMessage", - "tableTo": "response", + "message_revision_id_revision_id_fk": { + "name": "message_revision_id_revision_id_fk", + "tableFrom": "message", + "tableTo": "revision", "columnsFrom": [ - "responseId" + "revision_id" ], "columnsTo": [ "id" ], - "onDelete": "no action", + "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, - "response": { - "name": "response", + "public.model": { + "name": "model", + "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, - "notNull": true, - "autoincrement": false + "notNull": true }, - "projectId": { - "name": "projectId", + "key_id": { + "name": "key_id", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "modelId": { - "name": "modelId", + "name": { + "name": "name", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "error": { - "name": "error", - "type": "text", + "visible": { + "name": "visible", + "type": "integer", "primaryKey": false, - "notNull": false, - "autoincrement": false + "notNull": true }, - "createdAt": { - "name": "createdAt", + "created_at": { + "name": "created_at", "type": "text", "primaryKey": false, "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" + "default": "CURRENT_TIMESTAMP" } }, "indexes": { - "projectId_idx": { - "name": "projectId_idx", + "account_id_idx": { + "name": "account_id_idx", "columns": [ - "projectId" + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } ], - "isUnique": false + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { - "response_projectId_project_id_fk": { - "name": "response_projectId_project_id_fk", - "tableFrom": "response", - "tableTo": "project", + "model_key_id_key_id_fk": { + "name": "model_key_id_key_id_fk", + "tableFrom": "model", + "tableTo": "key", "columnsFrom": [ - "projectId" + "key_id" ], "columnsTo": [ "id" ], - "onDelete": "no action", + "onDelete": "cascade", "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "account_id_unique": { + "name": "account_id_unique", + "nullsNotDistinct": false, + "columns": [ + "key_id", + "name" + ] + } + } + }, + "public.revision": { + "name": "revision", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true }, - "response_modelId_model_id_fk": { - "name": "response_modelId_model_id_fk", - "tableFrom": "response", - "tableTo": "model", + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "revision_chat_id_idx": { + "name": "revision_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "revision_chat_id_chat_id_fk": { + "name": "revision_chat_id_chat_id_fk", + "tableFrom": "revision", + "tableTo": "chat", "columnsFrom": [ - "modelId" + "chat_id" ], "columnsTo": [ "id" ], - "onDelete": "no action", + "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, - "service": { - "name": "service", + "public.sdk": { + "name": "sdk", + "schema": "", "columns": { "id": { "name": "id", "type": "text", "primaryKey": true, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, "notNull": true, - "autoincrement": false + "default": "'model'" }, "name": { "name": "name", "type": "text", "primaryKey": false, + "notNull": true + }, + "supported": { + "name": "supported", + "type": "integer", + "primaryKey": false, "notNull": true, - "autoincrement": false + "default": 1 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slug_unique": { + "name": "slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + } + }, + "public.service": { + "name": "service", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true }, - "providerId": { - "name": "providerId", + "name": { + "name": "name", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "baseURL": { - "name": "baseURL", + "sdk_id": { + "name": "sdk_id", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": true }, - "apiKey": { - "name": "apiKey", + "base_url": { + "name": "base_url", "type": "text", "primaryKey": false, - "notNull": true, - "autoincrement": false + "notNull": false }, - "createdAt": { - "name": "createdAt", + "created_at": { + "name": "created_at", "type": "text", "primaryKey": false, "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" + "default": "CURRENT_TIMESTAMP" } }, "indexes": {}, @@ -378,9 +549,11 @@ } }, "enums": {}, + "schemas": {}, + "sequences": {}, "_meta": { + "columns": {}, "schemas": {}, - "tables": {}, - "columns": {} + "tables": {} } } \ No newline at end of file diff --git a/src/database/migrations/meta/0001_snapshot.json b/src/database/migrations/meta/0001_snapshot.json deleted file mode 100644 index 0729d67..0000000 --- a/src/database/migrations/meta/0001_snapshot.json +++ /dev/null @@ -1,373 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "bfc7699b-dda4-4c1f-836b-145406d9d2f2", - "prevId": "e48d9370-c57b-4cce-95ab-c80a492bbe34", - "tables": { - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "document_name_unique": { - "name": "document_name_unique", - "columns": [ - "name" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "project": { - "name": "project", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "responseMessage": { - "name": "responseMessage", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "responseId": { - "name": "responseId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "responseId_idx": { - "name": "responseId_idx", - "columns": [ - "responseId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "responseMessage_responseId_response_id_fk": { - "name": "responseMessage_responseId_response_id_fk", - "tableFrom": "responseMessage", - "tableTo": "response", - "columnsFrom": [ - "responseId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "response": { - "name": "response", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "projectId": { - "name": "projectId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "modelId": { - "name": "modelId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "projectId_idx": { - "name": "projectId_idx", - "columns": [ - "projectId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "response_projectId_project_id_fk": { - "name": "response_projectId_project_id_fk", - "tableFrom": "response", - "tableTo": "project", - "columnsFrom": [ - "projectId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0002_snapshot.json b/src/database/migrations/meta/0002_snapshot.json deleted file mode 100644 index 661b3d8..0000000 --- a/src/database/migrations/meta/0002_snapshot.json +++ /dev/null @@ -1,377 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "0de01fd3-0bed-4287-a8d0-dcd9494d7fd3", - "prevId": "bfc7699b-dda4-4c1f-836b-145406d9d2f2", - "tables": { - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "document_name_unique": { - "name": "document_name_unique", - "columns": [ - "name" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "responseMessage": { - "name": "responseMessage", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "responseId": { - "name": "responseId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "responseId_idx": { - "name": "responseId_idx", - "columns": [ - "responseId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "responseMessage_responseId_response_id_fk": { - "name": "responseMessage_responseId_response_id_fk", - "tableFrom": "responseMessage", - "tableTo": "response", - "columnsFrom": [ - "responseId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "response": { - "name": "response", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "modelId": { - "name": "modelId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "chatId_idx": { - "name": "chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "response_chatId_chat_id_fk": { - "name": "response_chatId_chat_id_fk", - "tableFrom": "response", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": { - "\"project\"": "\"chat\"" - }, - "columns": { - "\"response\".\"projectId\"": "\"response\".\"chatId\"" - } - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0003_snapshot.json b/src/database/migrations/meta/0003_snapshot.json deleted file mode 100644 index e38bba3..0000000 --- a/src/database/migrations/meta/0003_snapshot.json +++ /dev/null @@ -1,514 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "c96805ab-fd2c-4965-8a88-286fa5d614ac", - "prevId": "0de01fd3-0bed-4287-a8d0-dcd9494d7fd3", - "tables": { - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "document_name_unique": { - "name": "document_name_unique", - "columns": [ - "name" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "responseMessage": { - "name": "responseMessage", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "responseId": { - "name": "responseId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "responseId_idx": { - "name": "responseId_idx", - "columns": [ - "responseId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "responseMessage_responseId_response_id_fk": { - "name": "responseMessage_responseId_response_id_fk", - "tableFrom": "responseMessage", - "tableTo": "response", - "columnsFrom": [ - "responseId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "response": { - "name": "response", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "modelId": { - "name": "modelId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "chatId_idx": { - "name": "chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "response_chatId_chat_id_fk": { - "name": "response_chatId_chat_id_fk", - "tableFrom": "response", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0004_snapshot.json b/src/database/migrations/meta/0004_snapshot.json deleted file mode 100644 index 914402a..0000000 --- a/src/database/migrations/meta/0004_snapshot.json +++ /dev/null @@ -1,373 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "357ab258-c1ea-4a56-8738-db8538d1a6d6", - "prevId": "c96805ab-fd2c-4965-8a88-286fa5d614ac", - "tables": { - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "document_name_unique": { - "name": "document_name_unique", - "columns": [ - "name" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0005_snapshot.json b/src/database/migrations/meta/0005_snapshot.json deleted file mode 100644 index 0a9a14c..0000000 --- a/src/database/migrations/meta/0005_snapshot.json +++ /dev/null @@ -1,462 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "be59e45d-6fd8-4a9a-9af2-04ff5bb425d1", - "prevId": "357ab258-c1ea-4a56-8738-db8538d1a6d6", - "tables": { - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "document_name_unique": { - "name": "document_name_unique", - "columns": [ - "name" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0006_snapshot.json b/src/database/migrations/meta/0006_snapshot.json deleted file mode 100644 index 6ffe5ff..0000000 --- a/src/database/migrations/meta/0006_snapshot.json +++ /dev/null @@ -1,470 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "a538b869-961f-4970-965e-6d323dbc3841", - "prevId": "be59e45d-6fd8-4a9a-9af2-04ff5bb425d1", - "tables": { - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "document_name_unique": { - "name": "document_name_unique", - "columns": [ - "name" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0007_snapshot.json b/src/database/migrations/meta/0007_snapshot.json deleted file mode 100644 index e2ae09a..0000000 --- a/src/database/migrations/meta/0007_snapshot.json +++ /dev/null @@ -1,462 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "13680e80-0b0a-4e45-99a8-474065d437b4", - "prevId": "a538b869-961f-4970-965e-6d323dbc3841", - "tables": { - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "serviceId_idx": { - "name": "serviceId_idx", - "columns": [ - "serviceId" - ], - "isUnique": false - }, - "serviceName_unique": { - "name": "serviceName_unique", - "columns": [ - "serviceId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_serviceId_service_id_fk": { - "name": "model_serviceId_service_id_fk", - "tableFrom": "model", - "tableTo": "service", - "columnsFrom": [ - "serviceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "providerId": { - "name": "providerId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0008_snapshot.json b/src/database/migrations/meta/0008_snapshot.json deleted file mode 100644 index 9abd972..0000000 --- a/src/database/migrations/meta/0008_snapshot.json +++ /dev/null @@ -1,468 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "672af5b5-5588-4a3b-b692-a5fdb2b12118", - "prevId": "13680e80-0b0a-4e45-99a8-474065d437b4", - "tables": { - "aiAccount": { - "name": "aiAccount", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "aiServiceId": { - "name": "aiServiceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiModel": { - "name": "aiModel", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "aiAccountId": { - "name": "aiAccountId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "accountId_idx": { - "name": "accountId_idx", - "columns": [ - "aiAccountId" - ], - "isUnique": false - }, - "accountId_unique": { - "name": "accountId_unique", - "columns": [ - "aiAccountId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "aiModel_aiAccountId_aiAccount_id_fk": { - "name": "aiModel_aiAccountId_aiAccount_id_fk", - "tableFrom": "aiModel", - "tableTo": "aiAccount", - "columnsFrom": [ - "aiAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": { - "\"service\"": "\"aiAccount\"", - "\"model\"": "\"aiModel\"" - }, - "columns": { - "\"aiModel\".\"serviceId\"": "\"aiModel\".\"aiAccountId\"", - "\"aiAccount\".\"providerId\"": "\"aiAccount\".\"aiServiceId\"" - } - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0009_snapshot.json b/src/database/migrations/meta/0009_snapshot.json deleted file mode 100644 index 9a8a641..0000000 --- a/src/database/migrations/meta/0009_snapshot.json +++ /dev/null @@ -1,537 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "e316ef9a-4ca9-4634-8f49-db5d3dafbe39", - "prevId": "672af5b5-5588-4a3b-b692-a5fdb2b12118", - "tables": { - "aiAccount": { - "name": "aiAccount", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "aiServiceId": { - "name": "aiServiceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiModel": { - "name": "aiModel", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "aiAccountId": { - "name": "aiAccountId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "accountId_idx": { - "name": "accountId_idx", - "columns": [ - "aiAccountId" - ], - "isUnique": false - }, - "accountId_unique": { - "name": "accountId_unique", - "columns": [ - "aiAccountId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "aiModel_aiAccountId_aiAccount_id_fk": { - "name": "aiModel_aiAccountId_aiAccount_id_fk", - "tableFrom": "aiModel", - "tableTo": "aiAccount", - "columnsFrom": [ - "aiAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiSdk": { - "name": "aiSdk", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiService": { - "name": "aiService", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "aiSdkId": { - "name": "aiSdkId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0010_snapshot.json b/src/database/migrations/meta/0010_snapshot.json deleted file mode 100644 index f9fda34..0000000 --- a/src/database/migrations/meta/0010_snapshot.json +++ /dev/null @@ -1,545 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "8969d23b-855c-4fa5-a0b9-11ee61b43274", - "prevId": "e316ef9a-4ca9-4634-8f49-db5d3dafbe39", - "tables": { - "aiAccount": { - "name": "aiAccount", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "aiServiceId": { - "name": "aiServiceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiModel": { - "name": "aiModel", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "aiAccountId": { - "name": "aiAccountId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "accountId_idx": { - "name": "accountId_idx", - "columns": [ - "aiAccountId" - ], - "isUnique": false - }, - "accountId_unique": { - "name": "accountId_unique", - "columns": [ - "aiAccountId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "aiModel_aiAccountId_aiAccount_id_fk": { - "name": "aiModel_aiAccountId_aiAccount_id_fk", - "tableFrom": "aiModel", - "tableTo": "aiAccount", - "columnsFrom": [ - "aiAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiSdk": { - "name": "aiSdk", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "slug_unique": { - "name": "slug_unique", - "columns": [ - "slug" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "aiService": { - "name": "aiService", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "aiSdkId": { - "name": "aiSdkId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0011_snapshot.json b/src/database/migrations/meta/0011_snapshot.json deleted file mode 100644 index 973bc4e..0000000 --- a/src/database/migrations/meta/0011_snapshot.json +++ /dev/null @@ -1,554 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "3e9ce11f-801c-433c-b3bf-8f40433cc3b5", - "prevId": "8969d23b-855c-4fa5-a0b9-11ee61b43274", - "tables": { - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "keyId": { - "name": "keyId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "accountId_idx": { - "name": "accountId_idx", - "columns": [ - "keyId" - ], - "isUnique": false - }, - "accountId_unique": { - "name": "accountId_unique", - "columns": [ - "keyId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_keyId_key_id_fk": { - "name": "model_keyId_key_id_fk", - "tableFrom": "model", - "tableTo": "key", - "columnsFrom": [ - "keyId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "sdk": { - "name": "sdk", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "slug_unique": { - "name": "slug_unique", - "columns": [ - "slug" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "sdkId": { - "name": "sdkId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": { - "\"aiAccount\"": "\"key\"", - "\"aiModel\"": "\"model\"", - "\"aiSdk\"": "\"sdk\"", - "\"aiService\"": "\"service\"" - }, - "columns": { - "\"key\".\"aiServiceId\"": "\"key\".\"serviceId\"", - "\"model\".\"aiAccountId\"": "\"model\".\"keyId\"", - "\"service\".\"aiSdkId\"": "\"service\".\"sdkId\"" - } - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0012_snapshot.json b/src/database/migrations/meta/0012_snapshot.json deleted file mode 100644 index af1e126..0000000 --- a/src/database/migrations/meta/0012_snapshot.json +++ /dev/null @@ -1,553 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "8bd68b8d-72a4-4b2c-83fc-61d4269779d0", - "prevId": "3e9ce11f-801c-433c-b3bf-8f40433cc3b5", - "tables": { - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "keyId": { - "name": "keyId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "accountId_idx": { - "name": "accountId_idx", - "columns": [ - "keyId" - ], - "isUnique": false - }, - "accountId_unique": { - "name": "accountId_unique", - "columns": [ - "keyId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_keyId_key_id_fk": { - "name": "model_keyId_key_id_fk", - "tableFrom": "model", - "tableTo": "key", - "columnsFrom": [ - "keyId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "sdk": { - "name": "sdk", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "supported": { - "name": "supported", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 1 - } - }, - "indexes": { - "slug_unique": { - "name": "slug_unique", - "columns": [ - "slug" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "sdkId": { - "name": "sdkId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/0013_snapshot.json b/src/database/migrations/meta/0013_snapshot.json deleted file mode 100644 index d2299e2..0000000 --- a/src/database/migrations/meta/0013_snapshot.json +++ /dev/null @@ -1,561 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "cc4fa37d-7749-484d-85e2-30ef047570bd", - "prevId": "8bd68b8d-72a4-4b2c-83fc-61d4269779d0", - "tables": { - "attachment": { - "name": "attachment", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "messageId": { - "name": "messageId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "documentId": { - "name": "documentId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "attachment_messageId_idx": { - "name": "attachment_messageId_idx", - "columns": [ - "messageId" - ], - "isUnique": false - }, - "messageDocument_unique": { - "name": "messageDocument_unique", - "columns": [ - "messageId", - "documentId" - ], - "isUnique": true - } - }, - "foreignKeys": { - "attachment_messageId_message_id_fk": { - "name": "attachment_messageId_message_id_fk", - "tableFrom": "attachment", - "tableTo": "message", - "columnsFrom": [ - "messageId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "attachment_documentId_document_id_fk": { - "name": "attachment_documentId_document_id_fk", - "tableFrom": "attachment", - "tableTo": "document", - "columnsFrom": [ - "documentId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "chat": { - "name": "chat", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "document": { - "name": "document", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'document'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "attributes": { - "name": "attributes", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'{}'" - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "serviceId": { - "name": "serviceId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "apiKey": { - "name": "apiKey", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "message": { - "name": "message", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "index": { - "name": "index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "revisionId": { - "name": "revisionId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "message_revisionId_idx": { - "name": "message_revisionId_idx", - "columns": [ - "revisionId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "message_revisionId_revision_id_fk": { - "name": "message_revisionId_revision_id_fk", - "tableFrom": "message", - "tableTo": "revision", - "columnsFrom": [ - "revisionId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "model": { - "name": "model", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "keyId": { - "name": "keyId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "visible": { - "name": "visible", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "accountId_idx": { - "name": "accountId_idx", - "columns": [ - "keyId" - ], - "isUnique": false - }, - "accountId_unique": { - "name": "accountId_unique", - "columns": [ - "keyId", - "name" - ], - "isUnique": true - } - }, - "foreignKeys": { - "model_keyId_key_id_fk": { - "name": "model_keyId_key_id_fk", - "tableFrom": "model", - "tableTo": "key", - "columnsFrom": [ - "keyId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "revision": { - "name": "revision", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "chatId": { - "name": "chatId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": { - "revision_chatId_idx": { - "name": "revision_chatId_idx", - "columns": [ - "chatId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "revision_chatId_chat_id_fk": { - "name": "revision_chatId_chat_id_fk", - "tableFrom": "revision", - "tableTo": "chat", - "columnsFrom": [ - "chatId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "sdk": { - "name": "sdk", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'model'" - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "supported": { - "name": "supported", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": 1 - } - }, - "indexes": { - "slug_unique": { - "name": "slug_unique", - "columns": [ - "slug" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "service": { - "name": "service", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "sdkId": { - "name": "sdkId", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "baseURL": { - "name": "baseURL", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "createdAt": { - "name": "createdAt", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false, - "default": "(CURRENT_TIMESTAMP)" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - } -} \ No newline at end of file diff --git a/src/database/migrations/meta/_journal.json b/src/database/migrations/meta/_journal.json index f2ef347..f6e5ab9 100644 --- a/src/database/migrations/meta/_journal.json +++ b/src/database/migrations/meta/_journal.json @@ -1,103 +1,12 @@ { - "version": "6", - "dialect": "sqlite", + "version": "7", + "dialect": "postgresql", "entries": [ { "idx": 0, - "version": "6", - "when": 1716023408078, - "tag": "0000_careful_smiling_tiger", - "breakpoints": true - }, - { - "idx": 1, - "version": "6", - "when": 1720013980037, - "tag": "0001_nosy_earthquake", - "breakpoints": true - }, - { - "idx": 2, - "version": "6", - "when": 1720063831479, - "tag": "0002_overjoyed_mordo", - "breakpoints": true - }, - { - "idx": 3, - "version": "6", - "when": 1720361174122, - "tag": "0003_huge_nick_fury", - "breakpoints": true - }, - { - "idx": 4, - "version": "6", - "when": 1720447287431, - "tag": "0004_skinny_machine_man", - "breakpoints": true - }, - { - "idx": 5, - "version": "6", - "when": 1720702384826, - "tag": "0005_careful_the_professor", - "breakpoints": true - }, - { - "idx": 6, - "version": "6", - "when": 1720834189336, - "tag": "0006_opposite_sugar_man", - "breakpoints": true - }, - { - "idx": 7, - "version": "6", - "when": 1721109071985, - "tag": "0007_tidy_lilandra", - "breakpoints": true - }, - { - "idx": 8, - "version": "6", - "when": 1722605561757, - "tag": "0008_parallel_grandmaster", - "breakpoints": true - }, - { - "idx": 9, - "version": "6", - "when": 1722605742561, - "tag": "0009_ancient_korath", - "breakpoints": true - }, - { - "idx": 10, - "version": "6", - "when": 1722607191126, - "tag": "0010_far_wiccan", - "breakpoints": true - }, - { - "idx": 11, - "version": "6", - "when": 1722788063130, - "tag": "0011_easy_slapstick", - "breakpoints": true - }, - { - "idx": 12, - "version": "6", - "when": 1722860350143, - "tag": "0012_soft_trish_tilby", - "breakpoints": true - }, - { - "idx": 13, - "version": "6", - "when": 1723389269325, - "tag": "0013_tiny_glorian", + "version": "7", + "when": 1723548717244, + "tag": "0000_nappy_the_liberteens", "breakpoints": true } ] diff --git a/src/database/migrator.ts b/src/database/migrator.ts index 9574630..c5d7312 100644 --- a/src/database/migrator.ts +++ b/src/database/migrator.ts @@ -2,42 +2,55 @@ import { sql } from "drizzle-orm/sql"; import journal from "./migrations/meta/_journal.json"; import { useDb } from "@/database/client"; import { seed } from "@/database/seed"; +import type { PgliteDatabase } from "drizzle-orm/pglite"; export async function runMigrations(skipSeed = false) { - const haveMigrationsTable = await useDb().get( - sql.raw("SELECT name FROM sqlite_master WHERE type='table' AND name='migrations';"), + const db = useDb(); + const result = await db.execute<{ exists: boolean }>( + sql`SELECT EXISTS ( + SELECT FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'migrations' + );`, ); - let shouldSeed = false; + + const haveMigrationsTable = result.rows[0]?.exists ?? false; + if (!haveMigrationsTable) { - await useDb().run(sql.raw("CREATE TABLE `migrations` (`name` text PRIMARY KEY NOT NULL);")); - shouldSeed = true; + await db.execute(sql`CREATE TABLE migrations (name text PRIMARY KEY NOT NULL);`); } + for (const entry of journal.entries) { - await applyMigration(entry.idx, entry.tag); + await applyMigration(db, entry.tag, skipSeed); } - if (shouldSeed && !skipSeed) { - await seed(); - } - // console.log("Migrations applied"); } -async function applyMigration(idx: number, migration: string) { - // check if migration is already applied - const checkQuery = `SELECT name FROM migrations WHERE name='${migration}'`; - // console.log("checkQuery", checkQuery); - const hasMigration = await useDb().get(sql.raw(checkQuery)); - // console.log("hasMigration", hasMigration); - if (!hasMigration) { +async function applyMigration(db: PgliteDatabase, tag: string, skipSeed: boolean) { + // check if tag is already applied + const result = await db.execute<{ name: string }>( + sql`SELECT name FROM migrations WHERE name = ${tag}`, + ); + + if (result.rows.length === 0) { try { - await useDb().transaction(async (tx) => { - const migrationSql = (await import(`./migrations/${migration}.sql?raw`)).default; - // console.log("Applying migration", migration); - // split statements for better-sqlite3 compatibility - await Promise.all( - migrationSql.split("--> statement-breakpoint").map((s: string) => tx.run(sql.raw(s))), - ); - // record migration in migrations table - await tx.run(sql.raw(`INSERT INTO migrations (name) VALUES ('${migration}');`)); + await db.transaction(async (tx) => { + const migrationSql = (await import(`./migrations/${tag}.sql?raw`)).default; + // Split the tag SQL into individual statements + const statements = migrationSql + .split("--> statement-breakpoint") + .filter((statement: any) => statement.trim() !== ""); + + for (const statement of statements) { + await tx.execute(sql.raw(statement)); + } + + await tx.execute(sql`INSERT INTO migrations (name) VALUES (${tag})`); + + const num = tag.split("_")[0]; + if (num in seed && !skipSeed) { + // @ts-expect-error + await seed[num](tx); + } }); } catch (e) { console.error(e); diff --git a/src/database/model.ts b/src/database/model.ts index c2aaf91..7b8ea32 100644 --- a/src/database/model.ts +++ b/src/database/model.ts @@ -3,6 +3,7 @@ import { createTableRelationsHelpers, extractTablesRelationalConfig, getTableName, + getTableUniqueName, type Table, } from "drizzle-orm"; import { invalidate } from "$app/navigation"; @@ -20,9 +21,8 @@ export function registerModel(table: Table, view: Model | Model[], depends: Depe const table = relationalConfig.tables[relationalConfig.tableNamesMap[tableName]]; for (const key of Object.keys(table.relations)) { if (record[key]) { - const referencedTableName = table.relations[key].referencedTableName; register( - referencedTableName, + getTableUniqueName(table.relations[key].referencedTable), Array.isArray(record[key]) ? record[key] : [record[key]], depends, ); @@ -31,10 +31,10 @@ export function registerModel(table: Table, view: Model | Model[], depends: Depe } } - const tableName = getTableName(table); + const tableName = getTableUniqueName(table); register(tableName, Array.isArray(view) ? view : [view], depends); } export function invalidateModel(table: Table, model: Model) { - return invalidate(`model:${getTableName(table)}:${model.id}`); + return invalidate(`model:${getTableUniqueName(table)}:${model.id}`); } diff --git a/src/database/schema.ts b/src/database/schema.ts index fdddc46..c319490 100644 --- a/src/database/schema.ts +++ b/src/database/schema.ts @@ -1,4 +1,4 @@ -import { sqliteTable, text, int, primaryKey, index, unique } from "drizzle-orm/sqlite-core"; +import { pgTable, text, integer, primaryKey, index, unique, jsonb } from "drizzle-orm/pg-core"; import { type InferInsertModel, type InferSelectModel, relations } from "drizzle-orm"; import { sql } from "drizzle-orm/sql"; @@ -6,129 +6,120 @@ import { sql } from "drizzle-orm/sql"; * Tables */ -export const documentTable = sqliteTable("document", { +export const documentTable = pgTable("document", { id: text("id").primaryKey(), name: text("name").notNull(), type: text("type").notNull().default("document"), description: text("description").notNull(), content: text("content").notNull(), - attributes: text("attributes", { mode: "json" }) - .$type>() - .notNull() - .default({}), - // data: text("data").notNull(), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + attributes: jsonb("attributes").notNull().default({}), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }); -export const revisionTable = sqliteTable( +export const revisionTable = pgTable( "revision", { id: text("id").primaryKey(), - version: int("version").notNull(), - chatId: text("chatId") + version: integer("version").notNull(), + chatId: text("chat_id") .notNull() .references(() => chatTable.id, { onDelete: "cascade" }), error: text("error"), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }, (table) => ({ - chatIdIdx: index("revision_chatId_idx").on(table.chatId), + chatIdIdx: index("revision_chat_id_idx").on(table.chatId), }), ); -export const messageTable = sqliteTable( +export const messageTable = pgTable( "message", { id: text("id").primaryKey(), - index: int("index").notNull(), - revisionId: text("revisionId") + index: integer("index").notNull(), + revisionId: text("revision_id") .notNull() .references(() => revisionTable.id, { onDelete: "cascade" }), role: text("role").notNull(), content: text("content").notNull(), - // attachments: text("attachments", { mode: "json" }) - // .$type<{ documentId: string }[]>() - // .default([]), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }, (table) => ({ - revisionIdIdx: index("message_revisionId_idx").on(table.revisionId), + revisionIdIdx: index("message_revision_id_idx").on(table.revisionId), }), ); -export const attachmentTable = sqliteTable( +export const attachmentTable = pgTable( "attachment", { id: text("id").primaryKey(), - messageId: text("messageId") + messageId: text("message_id") .notNull() .references(() => messageTable.id, { onDelete: "cascade" }), - documentId: text("documentId") + documentId: text("document_id") .notNull() .references(() => documentTable.id, { onDelete: "cascade" }), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }, (table) => ({ - messageDocumentUnique: unique("messageDocument_unique").on(table.messageId, table.documentId), - messageIdIdx: index("attachment_messageId_idx").on(table.messageId), + messageDocumentUnique: unique("message_document_unique").on(table.messageId, table.documentId), + messageIdIdx: index("attachment_message_id_idx").on(table.messageId), }), ); -export const modelTable = sqliteTable( +export const modelTable = pgTable( "model", { id: text("id").notNull().primaryKey(), - keyId: text("keyId") + keyId: text("key_id") .notNull() .references(() => keyTable.id, { onDelete: "cascade" }), name: text("name").notNull(), - visible: int("visible").notNull(), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + visible: integer("visible").notNull(), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }, (table) => ({ - keyId_unique: unique("accountId_unique").on(table.keyId, table.name), - keyId_idx: index("accountId_idx").on(table.keyId), + keyId_unique: unique("account_id_unique").on(table.keyId, table.name), + keyId_idx: index("account_id_idx").on(table.keyId), }), ); -export const keyTable = sqliteTable("key", { +export const keyTable = pgTable("key", { id: text("id").primaryKey(), name: text("name").notNull(), - serviceId: text("serviceId").notNull(), - baseURL: text("baseURL"), - apiKey: text("apiKey").notNull(), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + serviceId: text("service_id").notNull(), + baseURL: text("base_url"), + apiKey: text("api_key").notNull(), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }); -export const serviceTable = sqliteTable("service", { +export const serviceTable = pgTable("service", { id: text("id").primaryKey(), name: text("name").notNull(), - sdkId: text("sdkId").notNull(), - baseURL: text("baseURL").notNull(), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + sdkId: text("sdk_id").notNull(), + baseURL: text("base_url"), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }); -export const sdkTable = sqliteTable( +export const sdkTable = pgTable( "sdk", { id: text("id").primaryKey(), slug: text("slug").notNull(), - type: text("type", { enum: ["model", "document"] }) - .notNull() - .default("model"), + type: text("type").notNull().default("model"), name: text("name").notNull(), - supported: int("supported").notNull().default(1), + supported: integer("supported").notNull().default(1), }, (table) => ({ slugUnique: unique("slug_unique").on(table.slug), }), ); -export const chatTable = sqliteTable("chat", { +export const chatTable = pgTable("chat", { id: text("id").primaryKey(), name: text("name").notNull(), prompt: text("prompt").notNull(), - createdAt: text("createdAt").default(sql`(CURRENT_TIMESTAMP)`), + createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`), }); /** diff --git a/src/database/seed.ts b/src/database/seed.ts index 2473404..e6cfe16 100644 --- a/src/database/seed.ts +++ b/src/database/seed.ts @@ -1,6 +1,41 @@ -import { newChat } from "../routes/(app)/$data"; +import { sql } from "drizzle-orm"; +import { nanoid } from "nanoid"; +import { PgTransaction } from "drizzle-orm/pg-core"; -export function seed() { - // create first chat - return newChat(); -} +export const seed = { + "0000": async (tx: PgTransaction) => { + await tx.execute(sql`INSERT INTO sdk (id, slug, name, type, supported) VALUES + ('openai', 'openai', 'OpenAI', 'model', 1), + ('azure', 'azure', 'Azure', 'model', 0), + ('anthropic', 'anthropic', 'Anthropic', 'model', 1), + ('amazon', 'amazon', 'Amazon Bedrock', 'model', 0), + ('google-gen-ai', 'google-gen-ai', 'Google Generative AI', 'model', 1), + ('google-vertex', 'google-vertex', 'Google Vertex AI', 'model', 0), + ('mistral', 'mistral', 'Mistral', 'model', 1), + ('cohere', 'cohere', 'Cohere', 'model', 1), + ('unstructured', 'unstructured', 'Unstructured', 'document', 1); + `); + + await tx.execute(sql`INSERT INTO service (id, name, sdk_id, base_url) VALUES + ('openai', 'OpenAI', 'openai', NULL), + ('azure', 'Azure OpenAI', 'azure', NULL), + ('anthropic', 'Anthropic', 'anthropic', NULL), + ('amazon-bedrock', 'Amazon Bedrock', 'amazon', NULL), + ('google-gen-ai', 'Google Generative AI', 'google-gen-ai', NULL), + ('google-vertex', 'Google Vertex AI', 'google-vertex', NULL), + ('mistral', 'Mistral', 'mistral', NULL), + ('groq', 'Groq', 'openai', 'https://api.groq.com/openai/v1'), + ('perplexity', 'Perplexity', 'openai', 'https://api.perplexity.ai/'), + ('fireworks', 'Fireworks', 'openai', 'https://api.fireworks.ai/inference/v1'), + ('nvidia', 'Nvidia', 'openai', 'https://integrate.api.nvidia.com/v1'), + ('cohere', 'Cohere', 'cohere', NULL), + ('unstructured', 'Unstructured', 'unstructured', NULL); + `); + + const chatId = nanoid(10); + await tx.execute(sql`INSERT INTO chat (id, name, prompt) VALUES + (${chatId}, 'Untitled', '');`); + await tx.execute(sql`INSERT INTO revision (id, version, chat_id) VALUES + (${nanoid(10)}, 1, ${chatId});`); + }, +}; diff --git a/src/routes/(app)/$data.test.ts b/src/routes/(app)/$data.test.ts index a292e70..5c99499 100644 --- a/src/routes/(app)/$data.test.ts +++ b/src/routes/(app)/$data.test.ts @@ -1,34 +1,34 @@ -import { afterEach, beforeEach, describe, expect, it, vi, onTestFailed } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { duplicateChat, newChat, removeChat } from "./$data"; -import Database from "better-sqlite3"; -import { type BetterSQLite3Database, drizzle } from "drizzle-orm/better-sqlite3"; +import { drizzle } from "drizzle-orm/pglite"; import { nanoid } from "nanoid"; import * as schema from "@/database/schema"; -import { chatTable, revisionTable, messageTable } from "@/database/schema"; +import { chatTable, messageTable, revisionTable } from "@/database/schema"; import { runMigrations } from "@/database/migrator"; import { eq } from "drizzle-orm"; import { invalidate } from "$app/navigation"; import { sql } from "drizzle-orm/sql"; import { useDb } from "@/database"; +import { PGlite } from "@electric-sql/pglite"; +import type { PgliteDatabase } from "drizzle-orm/pglite"; describe("(app)/$data", () => { vi.mock("@/database/client"); vi.mock("$app/navigation"); vi.mock("nanoid"); - let sqlite: Database.Database; - let db: BetterSQLite3Database; + let pglite: PGlite; + let db: PgliteDatabase; - beforeEach(async () => { - // Create an in-memory SQLite database - sqlite = new Database(":memory:"); - db = drizzle(sqlite, { schema }); + beforeAll(async () => { + pglite = new PGlite(); + db = drizzle(pglite, { schema }); + }); + beforeEach(async () => { vi.mocked(useDb).mockReturnValue(db); - db.run(sql.raw("PRAGMA foreign_keys=off;")); await runMigrations(true); - db.run(sql.raw("PRAGMA foreign_keys=on;")); await db.delete(schema.messageTable); await db.delete(schema.revisionTable); @@ -43,17 +43,15 @@ describe("(app)/$data", () => { .values([ { id: "service1", name: "Test Service", sdkId: "sdk1", baseURL: "https://api.test.com" }, ]); - await db - .insert(schema.keyTable) - .values([ - { - id: "key1", - name: "Test Key", - serviceId: "service1", - baseURL: "https://api.test.com", - apiKey: "test-api-key", - }, - ]); + await db.insert(schema.keyTable).values([ + { + id: "key1", + name: "Test Key", + serviceId: "service1", + baseURL: "https://api.test.com", + apiKey: "test-api-key", + }, + ]); await db .insert(schema.modelTable) .values([{ id: "model1", keyId: "key1", name: "Test Model", visible: 1 }]); @@ -87,8 +85,25 @@ describe("(app)/$data", () => { ]); }); - afterEach(() => { - sqlite.close(); + afterEach(async () => { + // pglite is slowish to start for each test + // instead drop all the tables + await db.execute(sql`DO $$ + DECLARE + r RECORD; + BEGIN + -- Disable all triggers + EXECUTE 'SET session_replication_role = replica'; + + -- Drop all tables in the current schema + FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP + EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE'; + END LOOP; + + -- Re-enable triggers + EXECUTE 'SET session_replication_role = DEFAULT'; + END $$; + `); vi.resetAllMocks(); }); diff --git a/src/routes/(app)/+layout.ts b/src/routes/(app)/+layout.ts index 90d8de3..1dea5c5 100644 --- a/src/routes/(app)/+layout.ts +++ b/src/routes/(app)/+layout.ts @@ -29,7 +29,6 @@ async function runMigrations() { const { runMigrations } = await import("@/database/migrator"); console.log("Migrating database"); await runMigrations(); - await useDb().run(sql.raw("PRAGMA foreign_keys=on;")); console.log("Migration complete"); migrated = true; } catch (err) { diff --git a/src/routes/(app)/api/chat/+server.ts b/src/routes/(app)/api/chat/+server.ts index 6c827dc..35f065d 100644 --- a/src/routes/(app)/api/chat/+server.ts +++ b/src/routes/(app)/api/chat/+server.ts @@ -11,12 +11,12 @@ export const POST = (async ({ request }) => { let { messages, sdkId, apiKey, baseURL, modelName } = (await request.json()) as { messages: any[]; sdkId: string; - baseURL: string; + baseURL: string | undefined; apiKey: string; modelName: string; }; - baseURL = baseURL ?? undefined; + baseURL = baseURL || undefined; if (!sdkId || !modelName) { return new Response(`Malformed request`, { diff --git a/src/routes/(app)/chat/[id]/$data.test.ts b/src/routes/(app)/chat/[id]/$data.test.ts index 064d7c3..58dc3af 100644 --- a/src/routes/(app)/chat/[id]/$data.test.ts +++ b/src/routes/(app)/chat/[id]/$data.test.ts @@ -1,32 +1,35 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { appendMessages, createRevision, + getKeys, getLatestRevision, getModelKey, getRevision, interpolateDocuments, isTab, - getKeys, tabRouteId, updateChat, } from "./$data"; -import Database from "better-sqlite3"; -import { type BetterSQLite3Database, drizzle } from "drizzle-orm/better-sqlite3"; +import type { PgliteDatabase } from "drizzle-orm/pglite"; +import { drizzle } from "drizzle-orm/pglite"; import * as schema from "@/database/schema"; import { runMigrations } from "@/database/migrator"; import { eq } from "drizzle-orm"; import { nanoid } from "nanoid"; import type { ChatMessage } from "$lib/chat-service.svelte"; +import { PGlite } from "@electric-sql/pglite"; +import { sql } from "drizzle-orm/sql"; -let sqlite: Database.Database; -let db: BetterSQLite3Database; +let pglite: PGlite; +let db: PgliteDatabase; -beforeEach(async () => { - // Set up database - sqlite = new Database(":memory:"); - db = drizzle(sqlite, { schema }); +beforeAll(async () => { + pglite = new PGlite(); + db = drizzle(pglite, { schema }); +}); +beforeEach(async () => { // Set up mocks vi.mock("$app/navigation", () => ({ invalidate: vi.fn(), @@ -124,8 +127,26 @@ beforeEach(async () => { ]); }); -afterEach(() => { - sqlite.close(); +afterEach(async () => { + // pglite is slowish to start for each test + // instead drop all the tables + await db.execute(sql`DO $$ + DECLARE + r RECORD; + BEGIN + -- Disable all triggers + EXECUTE 'SET session_replication_role = replica'; + + -- Drop all tables in the current schema + FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP + EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE'; + END LOOP; + + -- Re-enable triggers + EXECUTE 'SET session_replication_role = DEFAULT'; + END $$; + `); + vi.clearAllMocks(); }); @@ -214,11 +235,12 @@ describe("getModelService", () => { describe("createRevision", () => { it("should create a new revision", async () => { + vi.mocked(nanoid).mockReturnValueOnce("created-revision-id"); const newRevision = await createRevision("chat1"); expect(newRevision).toMatchObject({ chatId: "chat1", version: 3, - id: "mocked-nanoid", + id: "created-revision-id", }); }); }); @@ -252,7 +274,7 @@ describe("appendMessage", () => { describe("newRevision", () => { it("should create a new revision with messages", async () => { vi.mocked(nanoid) - .mockReturnValueOnce("mocked-nanoid") + .mockReturnValueOnce("revision-with-messages-id") .mockReturnValueOnce("message-1") .mockReturnValueOnce("message-2"); const messages: ChatMessage[] = [ @@ -264,11 +286,11 @@ describe("newRevision", () => { expect(revision).toMatchObject({ chatId: "chat1", version: 3, - id: "mocked-nanoid", + id: "revision-with-messages-id", }); const newMessages = await db.query.messageTable.findMany({ - where: eq(schema.messageTable.revisionId, "mocked-nanoid"), + where: eq(schema.messageTable.revisionId, "revision-with-messages-id"), }); expect(newMessages).toHaveLength(2); expect(newMessages[0]).toMatchObject({ diff --git a/src/routes/(app)/chat/[id]/MessageCard.svelte b/src/routes/(app)/chat/[id]/MessageCard.svelte index 1d58760..8a530db 100644 --- a/src/routes/(app)/chat/[id]/MessageCard.svelte +++ b/src/routes/(app)/chat/[id]/MessageCard.svelte @@ -53,8 +53,7 @@
{#each message.attachments as attachment, index (index)} {/each} diff --git a/src/routes/(app)/settings/keys/+page.ts b/src/routes/(app)/settings/keys/+page.ts index 435ba64..d57c77d 100644 --- a/src/routes/(app)/settings/keys/+page.ts +++ b/src/routes/(app)/settings/keys/+page.ts @@ -1,7 +1,7 @@ import { keyTable, registerModel } from "@/database"; import { loadKeys } from "./$data"; -export async function load({ depends, route }) { +export async function load({ depends }) { const keys = await loadKeys(); registerModel(keyTable, keys, depends); depends("view:services"); diff --git a/test/registry.test.ts b/test/registry.test.ts index 6818c44..7b15cfb 100644 --- a/test/registry.test.ts +++ b/test/registry.test.ts @@ -49,10 +49,10 @@ describe("cache", () => { }); expect(dependencies).toEqual( new Set([ - "model:chat:id-chat", - "model:revision:id-revision", - "model:message:id-message", - "model:message:id-message2", + "model:public.chat:id-chat", + "model:public.revision:id-revision", + "model:public.message:id-message", + "model:public.message:id-message2", ]), ); }); diff --git a/vite.config.ts b/vite.config.ts index 0a799fa..0305f40 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,7 +16,7 @@ export default defineConfig({ }, }, optimizeDeps: { - exclude: ["sqlocal"], + exclude: ["sqlocal", "@electric-sql/pglite"], }, plugins: [ sveltekit(),