The open source coding agent.
TypeScript
wip: cloud
Dax Raad810c9cff1db9
diff --git a/bun.lock b/bun.lockindex dc231b6355a..b5d8841201e 100644--- a/bun.lock+++ b/bun.lock@@ -26,10 +26,11 @@},"cloud/core": {"name": "@opencode/cloud-core",- "version": "0.5.28",+ "version": "0.6.2","dependencies": {"@aws-sdk/client-sts": "3.782.0","@opencode/cloud-resource": "workspace:*",+ "@planetscale/database": "1.19.0","drizzle-orm": "0.41.0","postgres": "3.4.7","stripe": "18.0.0",@@ -37,11 +38,12 @@},"devDependencies": {"drizzle-kit": "0.30.5",+ "mysql2": "3.14.4",},},"cloud/function": {"name": "@opencode/cloud-function",- "version": "0.5.28",+ "version": "0.6.2","dependencies": {"@ai-sdk/anthropic": "2.0.0","@ai-sdk/openai": "2.0.2",@@ -67,7 +69,7 @@},"packages/function": {"name": "@opencode/function",- "version": "0.5.28",+ "version": "0.6.2","dependencies": {"@octokit/auth-app": "8.0.1","@octokit/rest": "22.0.0",@@ -82,7 +84,7 @@},"packages/opencode": {"name": "opencode",- "version": "0.5.28",+ "version": "0.6.2","bin": {"opencode": "./bin/opencode",},@@ -132,7 +134,7 @@},"packages/plugin": {"name": "@opencode-ai/plugin",- "version": "0.5.28",+ "version": "0.6.2","dependencies": {"@opencode-ai/sdk": "workspace:*",},@@ -143,7 +145,7 @@},"packages/sdk/js": {"name": "@opencode-ai/sdk",- "version": "0.5.28",+ "version": "0.6.2","dependencies": {"@hey-api/openapi-ts": "0.81.0",},@@ -155,7 +157,7 @@},"packages/web": {"name": "@opencode/web",- "version": "0.5.28",+ "version": "0.6.2","dependencies": {"@astrojs/cloudflare": "12.6.3","@astrojs/markdown-remark": "6.3.1",@@ -747,6 +749,8 @@"@pkgjs/parseargs": ["@pkgjs/[email protected]", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],+ "@planetscale/database": ["@planetscale/[email protected]", "", {}, "sha512-Tv4jcFUFAFjOWrGSio49H6R2ijALv0ZzVBfJKIdm+kl9X046Fh4LLawrF9OMsglVbK6ukqMJsUCeucGAFTBcMA=="],+"@poppinss/colors": ["@poppinss/[email protected]", "", { "dependencies": { "kleur": "^4.1.5" } }, "sha512-FvdDqtcRCtz6hThExcFOgW0cWX+xwSMWcRuQe5ZEb2m7cVQOAVZOIMt+/v9RxGiD9/OY16qJBXK4CVKWAPalBw=="],"@poppinss/dumper": ["@poppinss/[email protected]", "", { "dependencies": { "@poppinss/colors": "^4.1.5", "@sindresorhus/is": "^7.0.2", "supports-color": "^10.0.0" } }, "sha512-iG0TIdqv8xJ3Lt9O8DrPRxw1MRLjNpoqiSGU03P/wNLP/s0ra0udPJ1J2Tx5M0J3H/cVyEgpbn8xUKRY9j59kQ=="],@@ -1161,6 +1165,8 @@"aws-sdk": ["[email protected]", "", { "dependencies": { "buffer": "4.9.2", "events": "1.1.1", "ieee754": "1.1.13", "jmespath": "0.16.0", "querystring": "0.2.0", "sax": "1.2.1", "url": "0.10.3", "util": "^0.12.4", "uuid": "8.0.0", "xml2js": "0.6.2" } }, "sha512-x511uiJ/57FIsbgUe5csJ13k3uzu25uWQE+XqfBis/sB0SFoiElJWXRkgEAUh0U6n40eT3ay5Ue4oPkRMu1LYw=="],+ "aws-ssl-profiles": ["[email protected]", "", {}, "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g=="],+"aws4fetch": ["[email protected]", "", {}, "sha512-3Cf+YaUl07p24MoQ46rFwulAmiyCwH2+1zw1ZyPAX5OtJ34Hh185DwB8y/qRLb6cYYYtSFJ9pthyLc0MD4e8sQ=="],"axobject-query": ["[email protected]", "", {}, "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="],@@ -1631,6 +1637,8 @@"gel": ["[email protected]", "", { "dependencies": { "@petamoriken/float16": "^3.8.7", "debug": "^4.3.4", "env-paths": "^3.0.0", "semver": "^7.6.2", "shell-quote": "^1.8.1", "which": "^4.0.0" }, "bin": { "gel": "dist/cli.mjs" } }, "sha512-Newg9X7mRYskoBjSw70l1YnJ/ZGbq64VPyR821H5WVkTGpHG2O0mQILxCeUhxdYERLFY9B4tUyKLyf3uMTjtKw=="],+ "generate-function": ["[email protected]", "", { "dependencies": { "is-property": "^1.0.2" } }, "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ=="],+"gensync": ["[email protected]", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],"get-amd-module-type": ["[email protected]", "", { "dependencies": { "ast-module-types": "^6.0.1", "node-source-walk": "^7.0.1" } }, "sha512-MtjsmYiCXcYDDrGqtNbeIYdAl85n+5mSv2r3FbzER/YV3ZILw4HNNIw34HuV5pyl0jzs6GFYU1VHVEefhgcNHQ=="],@@ -1769,7 +1777,7 @@"i18next": ["[email protected]", "", { "dependencies": { "@babel/runtime": "^7.23.2" } }, "sha512-06r/TitrM88Mg5FdUXAKL96dJMzgqLE5dv3ryBAra4KCwD9mJ4ndOTS95ZuymIGoE+2hzfdaMak2X11/es7ZWg=="],- "iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],+ "iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ=="],"ieee754": ["[email protected]", "", {}, "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="],@@ -1845,6 +1853,8 @@"is-promise": ["[email protected]", "", {}, "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="],+ "is-property": ["[email protected]", "", {}, "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g=="],+"is-reference": ["[email protected]", "", { "dependencies": { "@types/estree": "*" } }, "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ=="],"is-regex": ["[email protected]", "", { "dependencies": { "call-bound": "^1.0.2", "gopd": "^1.2.0", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g=="],@@ -1957,6 +1967,8 @@"lru-cache": ["[email protected]", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA=="],+ "lru.min": ["[email protected]", "", {}, "sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg=="],+"luxon": ["[email protected]", "", {}, "sha512-tJLxrKJhO2ukZ5z0gyjY1zPh3Rh88Ej9P7jNrZiHMUXHae1yvI2imgOZtL1TO8TW6biMMKfTtAOoEJANgtWBMQ=="],"magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-yi8swmWbO17qHhwIBNeeZxTceJMeBvWJaId6dyvTSOwTipqeHhMhOrz6513r1sOKnpvQ7zkhlG8tPrpilwTxHQ=="],@@ -2145,6 +2157,10 @@"ms": ["[email protected]", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],+ "mysql2": ["[email protected]", "", { "dependencies": { "aws-ssl-profiles": "^1.1.1", "denque": "^2.1.0", "generate-function": "^2.3.1", "iconv-lite": "^0.7.0", "long": "^5.2.1", "lru.min": "^1.0.0", "named-placeholders": "^1.1.3", "seq-queue": "^0.0.5", "sqlstring": "^2.3.2" } }, "sha512-Cs/jx3WZPNrYHVz+Iunp9ziahaG5uFMvD2R8Zlmc194AqXNxt9HBNu7ZsPYrUtmJsF0egETCWIdMIYAwOGjL1w=="],++ "named-placeholders": ["[email protected]", "", { "dependencies": { "lru-cache": "^7.14.1" } }, "sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w=="],+"nanoid": ["[email protected]", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],"napi-build-utils": ["[email protected]", "", {}, "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA=="],@@ -2523,6 +2539,8 @@"send": ["[email protected]", "", { "dependencies": { "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", "http-errors": "2.0.0", "mime": "1.6.0", "ms": "2.1.3", "on-finished": "2.4.1", "range-parser": "~1.2.1", "statuses": "2.0.1" } }, "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw=="],+ "seq-queue": ["[email protected]", "", {}, "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="],+"serialize-javascript": ["[email protected]", "", { "dependencies": { "randombytes": "^2.1.0" } }, "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g=="],"seroval": ["[email protected]", "", {}, "sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ=="],@@ -2607,6 +2625,8 @@"sprintf-js": ["[email protected]", "", {}, "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="],+ "sqlstring": ["[email protected]", "", {}, "sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg=="],+"ssri": ["[email protected]", "", { "dependencies": { "minipass": "^7.0.3" } }, "sha512-MGrFH9Z4NP9Iyhqn16sDtBpRRNJ0Y2hNa6D65h736fVSaPCHr4DM4sWUNvVaSuC+0OBGhwsrydQwmgfg5LncqQ=="],"sst": ["[email protected]", "", { "dependencies": { "aws-sdk": "2.1692.0", "aws4fetch": "1.0.18", "jose": "5.2.3", "opencontrol": "0.0.6", "openid-client": "5.6.4" }, "optionalDependencies": { "sst-darwin-arm64": "3.17.12", "sst-darwin-x64": "3.17.12", "sst-linux-arm64": "3.17.12", "sst-linux-x64": "3.17.12", "sst-linux-x86": "3.17.12", "sst-win32-arm64": "3.17.12", "sst-win32-x64": "3.17.12", "sst-win32-x86": "3.17.12" }, "bin": { "sst": "bin/sst.mjs" } }, "sha512-UwUbucNZRLp9GHgPAwkat1sBsNGaJfHsLXZHCMKsolCW7CEuugJfvBl2vOyJrhKP4N+Xnv1QFh0BGsOmN0kQeA=="],@@ -3113,6 +3133,8 @@"bl/readable-stream": ["[email protected]", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="],+ "body-parser/iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],+"cacache/lru-cache": ["[email protected]", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],"cacheable-request/get-stream": ["[email protected]", "", { "dependencies": { "pump": "^3.0.0" } }, "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA=="],@@ -3129,6 +3151,8 @@"drizzle-kit/esbuild": ["[email protected]", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.19.12", "@esbuild/android-arm": "0.19.12", "@esbuild/android-arm64": "0.19.12", "@esbuild/android-x64": "0.19.12", "@esbuild/darwin-arm64": "0.19.12", "@esbuild/darwin-x64": "0.19.12", "@esbuild/freebsd-arm64": "0.19.12", "@esbuild/freebsd-x64": "0.19.12", "@esbuild/linux-arm": "0.19.12", "@esbuild/linux-arm64": "0.19.12", "@esbuild/linux-ia32": "0.19.12", "@esbuild/linux-loong64": "0.19.12", "@esbuild/linux-mips64el": "0.19.12", "@esbuild/linux-ppc64": "0.19.12", "@esbuild/linux-riscv64": "0.19.12", "@esbuild/linux-s390x": "0.19.12", "@esbuild/linux-x64": "0.19.12", "@esbuild/netbsd-x64": "0.19.12", "@esbuild/openbsd-x64": "0.19.12", "@esbuild/sunos-x64": "0.19.12", "@esbuild/win32-arm64": "0.19.12", "@esbuild/win32-ia32": "0.19.12", "@esbuild/win32-x64": "0.19.12" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg=="],+ "encoding/iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],+"estree-util-to-js/source-map": ["[email protected]", "", {}, "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ=="],"express/cookie": ["[email protected]", "", {}, "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w=="],@@ -3187,6 +3211,8 @@"mlly/pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],+ "named-placeholders/lru-cache": ["[email protected]", "", {}, "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA=="],+"netlify/node-fetch": ["[email protected]", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="],"nitropack/c12": ["[email protected]", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.1", "exsolve": "^1.0.7", "giget": "^2.0.0", "jiti": "^2.5.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^1.0.0", "pkg-types": "^2.2.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "^0.3.5" }, "optionalPeers": ["magicast"] }, "sha512-ixkEtbYafL56E6HiFuonMm1ZjoKtIo7TH68/uiEq4DAwv9NcUX2nJ95F8TrbMeNjqIkZpruo3ojXQJ+MGG5gcQ=="],@@ -3243,6 +3269,8 @@"prompts/kleur": ["[email protected]", "", {}, "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="],+ "raw-body/iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],+"rc/ini": ["[email protected]", "", {}, "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="],"read-pkg/unicorn-magic": ["[email protected]", "", {}, "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ=="],diff --git a/cloud/app/app.config.ts b/cloud/app/app.config.tsindex 4dd799edc4c..af013bc81cb 100644--- a/cloud/app/app.config.ts+++ b/cloud/app/app.config.ts@@ -1,6 +1,7 @@import { defineConfig } from "@solidjs/start/config"export default defineConfig({+ middleware: "./src/middleware.ts",vite: {server: {allowedHosts: true,diff --git a/cloud/app/src/entry-server.tsx b/cloud/app/src/entry-server.tsxindex f626e8e9d01..41fc8fc8b5d 100644--- a/cloud/app/src/entry-server.tsx+++ b/cloud/app/src/entry-server.tsx@@ -21,5 +21,5 @@ export default createHandler(() => ()}/>), {- mode: "sync",+ mode: "async",})diff --git a/cloud/app/src/middleware.ts b/cloud/app/src/middleware.tsnew file mode 100644index 00000000000..b49473cbe7d--- /dev/null+++ b/cloud/app/src/middleware.ts@@ -0,0 +1,5 @@+import { defineMiddleware } from "vinxi/http"++export default defineMiddleware({+ onBeforeResponse() {},+})diff --git a/cloud/core/drizzle.config.ts b/cloud/core/drizzle.config.tsindex fdecb6c5663..0b7c4417e80 100644--- a/cloud/core/drizzle.config.ts+++ b/cloud/core/drizzle.config.ts@@ -1,4 +1,4 @@-import { Resource } from "@opencode/cloud-resource"+import { Resource } from "sst"import { defineConfig } from "drizzle-kit"export default defineConfig({@@ -6,7 +6,7 @@ export default defineConfig({strict: true,schema: ["./src/**/*.sql.ts"],verbose: true,- dialect: "postgresql",+ dialect: "mysql",dbCredentials: {database: Resource.Database.database,host: Resource.Database.host,diff --git a/cloud/core/migrations/0000_amused_mojo.sql b/cloud/core/migrations/0000_amused_mojo.sqldeleted file mode 100644index 75441ad2456..00000000000--- a/cloud/core/migrations/0000_amused_mojo.sql+++ /dev/null@@ -1,66 +0,0 @@-CREATE TABLE "billing" (- "id" varchar(30) NOT NULL,- "workspace_id" varchar(30) NOT NULL,- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone,- "customer_id" varchar(255),- "payment_method_id" varchar(255),- "payment_method_last4" varchar(4),- "balance" bigint NOT NULL,- "reload" boolean,- CONSTRAINT "billing_workspace_id_id_pk" PRIMARY KEY("workspace_id","id")-);---> statement-breakpoint-CREATE TABLE "payment" (- "id" varchar(30) NOT NULL,- "workspace_id" varchar(30) NOT NULL,- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone,- "customer_id" varchar(255),- "payment_id" varchar(255),- "amount" bigint NOT NULL,- CONSTRAINT "payment_workspace_id_id_pk" PRIMARY KEY("workspace_id","id")-);---> statement-breakpoint-CREATE TABLE "usage" (- "id" varchar(30) NOT NULL,- "workspace_id" varchar(30) NOT NULL,- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone,- "request_id" varchar(255),- "model" varchar(255) NOT NULL,- "input_tokens" integer NOT NULL,- "output_tokens" integer NOT NULL,- "reasoning_tokens" integer,- "cache_read_tokens" integer,- "cache_write_tokens" integer,- "cost" bigint NOT NULL,- CONSTRAINT "usage_workspace_id_id_pk" PRIMARY KEY("workspace_id","id")-);---> statement-breakpoint-CREATE TABLE "user" (- "id" varchar(30) NOT NULL,- "workspace_id" varchar(30) NOT NULL,- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone,- "email" text NOT NULL,- "name" varchar(255) NOT NULL,- "time_seen" timestamp with time zone,- "color" integer,- CONSTRAINT "user_workspace_id_id_pk" PRIMARY KEY("workspace_id","id")-);---> statement-breakpoint-CREATE TABLE "workspace" (- "id" varchar(30) PRIMARY KEY NOT NULL,- "slug" varchar(255),- "name" varchar(255),- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone-);---> statement-breakpoint-ALTER TABLE "billing" ADD CONSTRAINT "billing_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint-ALTER TABLE "payment" ADD CONSTRAINT "payment_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint-ALTER TABLE "usage" ADD CONSTRAINT "usage_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint-ALTER TABLE "user" ADD CONSTRAINT "user_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint-CREATE UNIQUE INDEX "user_email" ON "user" USING btree ("workspace_id","email");--> statement-breakpoint-CREATE UNIQUE INDEX "slug" ON "workspace" USING btree ("slug");\ No newline at end of filediff --git a/cloud/core/migrations/0000_fluffy_raza.sql b/cloud/core/migrations/0000_fluffy_raza.sqlnew file mode 100644index 00000000000..8e817334645--- /dev/null+++ b/cloud/core/migrations/0000_fluffy_raza.sql@@ -0,0 +1,89 @@+CREATE TABLE `account` (+ `id` varchar(30) NOT NULL,+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ `email` varchar(255) NOT NULL,+ CONSTRAINT `email` UNIQUE(`email`)+);+--> statement-breakpoint+CREATE TABLE `billing` (+ `id` varchar(30) NOT NULL,+ `workspace_id` varchar(30) NOT NULL,+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ `customer_id` varchar(255),+ `payment_method_id` varchar(255),+ `payment_method_last4` varchar(4),+ `balance` bigint NOT NULL,+ `reload` boolean,+ CONSTRAINT `billing_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`)+);+--> statement-breakpoint+CREATE TABLE `payment` (+ `id` varchar(30) NOT NULL,+ `workspace_id` varchar(30) NOT NULL,+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ `customer_id` varchar(255),+ `payment_id` varchar(255),+ `amount` bigint NOT NULL,+ CONSTRAINT `payment_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`)+);+--> statement-breakpoint+CREATE TABLE `usage` (+ `id` varchar(30) NOT NULL,+ `workspace_id` varchar(30) NOT NULL,+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ `model` varchar(255) NOT NULL,+ `input_tokens` int NOT NULL,+ `output_tokens` int NOT NULL,+ `reasoning_tokens` int,+ `cache_read_tokens` int,+ `cache_write_tokens` int,+ `cost` bigint NOT NULL,+ CONSTRAINT `usage_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`)+);+--> statement-breakpoint+CREATE TABLE `key` (+ `id` varchar(30) NOT NULL,+ `workspace_id` varchar(30) NOT NULL,+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ `user_id` text NOT NULL,+ `name` varchar(255) NOT NULL,+ `key` varchar(255) NOT NULL,+ `time_used` timestamp(3),+ CONSTRAINT `key_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`),+ CONSTRAINT `global_key` UNIQUE(`key`)+);+--> statement-breakpoint+CREATE TABLE `user` (+ `id` varchar(30) NOT NULL,+ `workspace_id` varchar(30) NOT NULL,+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ `email` varchar(255) NOT NULL,+ `name` varchar(255) NOT NULL,+ `time_seen` timestamp(3),+ `color` int,+ CONSTRAINT `user_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`),+ CONSTRAINT `user_email` UNIQUE(`workspace_id`,`email`)+);+--> statement-breakpoint+CREATE TABLE `workspace` (+ `id` varchar(30) NOT NULL,+ `slug` varchar(255),+ `name` varchar(255),+ `time_created` timestamp(3) NOT NULL DEFAULT (now()),+ `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),+ `time_deleted` timestamp(3),+ CONSTRAINT `workspace_id` PRIMARY KEY(`id`),+ CONSTRAINT `slug` UNIQUE(`slug`)+);diff --git a/cloud/core/migrations/0001_thankful_chat.sql b/cloud/core/migrations/0001_thankful_chat.sqldeleted file mode 100644index 9c66a6ac4fc..00000000000--- a/cloud/core/migrations/0001_thankful_chat.sql+++ /dev/null@@ -1,8 +0,0 @@-CREATE TABLE "account" (- "id" varchar(30) NOT NULL,- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone,- "email" varchar(255) NOT NULL-);---> statement-breakpoint-CREATE UNIQUE INDEX "email" ON "account" USING btree ("email");\ No newline at end of filediff --git a/cloud/core/migrations/0002_stale_jackal.sql b/cloud/core/migrations/0002_stale_jackal.sqldeleted file mode 100644index 267dff27353..00000000000--- a/cloud/core/migrations/0002_stale_jackal.sql+++ /dev/null@@ -1,14 +0,0 @@-CREATE TABLE "key" (- "id" varchar(30) NOT NULL,- "workspace_id" varchar(30) NOT NULL,- "time_created" timestamp with time zone DEFAULT now() NOT NULL,- "time_deleted" timestamp with time zone,- "user_id" text NOT NULL,- "name" varchar(255) NOT NULL,- "key" varchar(255) NOT NULL,- "time_used" timestamp with time zone,- CONSTRAINT "key_workspace_id_id_pk" PRIMARY KEY("workspace_id","id")-);---> statement-breakpoint-ALTER TABLE "key" ADD CONSTRAINT "key_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint-CREATE UNIQUE INDEX "global_key" ON "key" USING btree ("key");\ No newline at end of filediff --git a/cloud/core/migrations/0003_tranquil_spencer_smythe.sql b/cloud/core/migrations/0003_tranquil_spencer_smythe.sqldeleted file mode 100644index 4f57f779fb2..00000000000--- a/cloud/core/migrations/0003_tranquil_spencer_smythe.sql+++ /dev/null@@ -1 +0,0 @@-ALTER TABLE "usage" DROP COLUMN "request_id";\ No newline at end of filediff --git a/cloud/core/migrations/meta/0000_snapshot.json b/cloud/core/migrations/meta/0000_snapshot.jsonindex 3b86bed25ad..623ec4930f3 100644--- a/cloud/core/migrations/meta/0000_snapshot.json+++ b/cloud/core/migrations/meta/0000_snapshot.json@@ -1,85 +1,142 @@{- "id": "9b5cec8c-8b59-4d7a-bb5c-76ade1c83d6f",+ "version": "5",+ "dialect": "mysql",+ "id": "aee779c5-db1d-4655-95ec-6451c18455be","prevId": "00000000-0000-0000-0000-000000000000",- "version": "7",- "dialect": "postgresql","tables": {- "public.billing": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "email": {+ "name": "email",+ "columns": [+ "email"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "billing": {"name": "billing",- "schema": "","columns": {"id": {"name": "id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"workspace_id": {"name": "workspace_id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"time_created": {"name": "time_created",- "type": "timestamp with time zone",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)","primaryKey": false,"notNull": true,- "default": "now()"+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"},"time_deleted": {"name": "time_deleted",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"customer_id": {"name": "customer_id","type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"payment_method_id": {"name": "payment_method_id","type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"payment_method_last4": {"name": "payment_method_last4","type": "varchar(4)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"balance": {"name": "balance","type": "bigint","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"reload": {"name": "reload","type": "boolean","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false}},"indexes": {},- "foreignKeys": {- "billing_workspace_id_workspace_id_fk": {- "name": "billing_workspace_id_workspace_id_fk",- "tableFrom": "billing",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },+ "foreignKeys": {},"compositePrimaryKeys": {"billing_workspace_id_id_pk": {"name": "billing_workspace_id_id_pk",@@ -90,74 +147,72 @@}},"uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false+ "checkConstraint": {}},- "public.payment": {+ "payment": {"name": "payment",- "schema": "","columns": {"id": {"name": "id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"workspace_id": {"name": "workspace_id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"time_created": {"name": "time_created",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,"notNull": true,- "default": "now()"+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"},"time_deleted": {"name": "time_deleted",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"customer_id": {"name": "customer_id","type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"payment_id": {"name": "payment_id","type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"amount": {"name": "amount","type": "bigint","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false}},"indexes": {},- "foreignKeys": {- "payment_workspace_id_workspace_id_fk": {- "name": "payment_workspace_id_workspace_id_fk",- "tableFrom": "payment",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },+ "foreignKeys": {},"compositePrimaryKeys": {"payment_workspace_id_id_pk": {"name": "payment_workspace_id_id_pk",@@ -168,107 +223,194 @@}},"uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false+ "checkConstraint": {}},- "public.usage": {+ "usage": {"name": "usage",- "schema": "","columns": {"id": {"name": "id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"workspace_id": {"name": "workspace_id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"time_created": {"name": "time_created",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,"notNull": true,- "default": "now()"+ "autoincrement": false,+ "default": "(now())"},- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"},- "request_id": {- "name": "request_id",- "type": "varchar(255)",+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"model": {"name": "model","type": "varchar(255)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"input_tokens": {"name": "input_tokens",- "type": "integer",+ "type": "int","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"output_tokens": {"name": "output_tokens",- "type": "integer",+ "type": "int","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"reasoning_tokens": {"name": "reasoning_tokens",- "type": "integer",+ "type": "int","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"cache_read_tokens": {"name": "cache_read_tokens",- "type": "integer",+ "type": "int","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"cache_write_tokens": {"name": "cache_write_tokens",- "type": "integer",+ "type": "int","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"cost": {"name": "cost","type": "bigint","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false}},"indexes": {},- "foreignKeys": {- "usage_workspace_id_workspace_id_fk": {- "name": "usage_workspace_id_workspace_id_fk",- "tableFrom": "usage",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "usage_workspace_id_id_pk": {+ "name": "usage_workspace_id_id_pk",+ "columns": [+ "workspace_id","id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "key": {+ "name": "key",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_used": {+ "name": "time_used",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_key": {+ "name": "global_key",+ "columns": [+ "key"],- "onDelete": "no action",- "onUpdate": "no action"+ "isUnique": true}},+ "foreignKeys": {},"compositePrimaryKeys": {- "usage_workspace_id_id_pk": {- "name": "usage_workspace_id_id_pk",+ "key_workspace_id_id_pk": {+ "name": "key_workspace_id_id_pk","columns": ["workspace_id","id"@@ -276,102 +418,88 @@}},"uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false+ "checkConstraint": {}},- "public.user": {+ "user": {"name": "user",- "schema": "","columns": {"id": {"name": "id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"workspace_id": {"name": "workspace_id","type": "varchar(30)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"time_created": {"name": "time_created",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,"notNull": true,- "default": "now()"+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"},"time_deleted": {"name": "time_deleted",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"email": {"name": "email",- "type": "text",+ "type": "varchar(255)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"name": {"name": "name","type": "varchar(255)","primaryKey": false,- "notNull": true+ "notNull": true,+ "autoincrement": false},"time_seen": {"name": "time_seen",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"color": {"name": "color",- "type": "integer",+ "type": "int","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false}},"indexes": {"user_email": {"name": "user_email","columns": [- {- "expression": "workspace_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "user_workspace_id_workspace_id_fk": {- "name": "user_workspace_id_workspace_id_fk",- "tableFrom": "user",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"+ "workspace_id",+ "email"],- "onDelete": "no action",- "onUpdate": "no action"+ "isUnique": true}},+ "foreignKeys": {},"compositePrimaryKeys": {"user_workspace_id_id_pk": {"name": "user_workspace_id_id_pk",@@ -382,80 +510,86 @@}},"uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false+ "checkConstraint": {}},- "public.workspace": {+ "workspace": {"name": "workspace",- "schema": "","columns": {"id": {"name": "id","type": "varchar(30)",- "primaryKey": true,- "notNull": true+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false},"slug": {"name": "slug","type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"name": {"name": "name","type": "varchar(255)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false},"time_created": {"name": "time_created",- "type": "timestamp with time zone",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)","primaryKey": false,"notNull": true,- "default": "now()"+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"},"time_deleted": {"name": "time_deleted",- "type": "timestamp with time zone",+ "type": "timestamp(3)","primaryKey": false,- "notNull": false+ "notNull": false,+ "autoincrement": false}},"indexes": {"slug": {"name": "slug","columns": [- {- "expression": "slug",- "isExpression": false,- "asc": true,- "nulls": "last"- }+ "slug"],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}+ "isUnique": true}},"foreignKeys": {},- "compositePrimaryKeys": {},+ "compositePrimaryKeys": {+ "workspace_id": {+ "name": "workspace_id",+ "columns": [+ "id"+ ]+ }+ },"uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false+ "checkConstraint": {}}},- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},"views": {},"_meta": {- "columns": {},"schemas": {},- "tables": {}+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}}}\ No newline at end of filediff --git a/cloud/core/migrations/meta/0001_snapshot.json b/cloud/core/migrations/meta/0001_snapshot.jsondeleted file mode 100644index 69d66ebc6d2..00000000000--- a/cloud/core/migrations/meta/0001_snapshot.json+++ /dev/null@@ -1,515 +0,0 @@-{- "id": "bf9e9084-4073-4ecb-8e56-5610816c9589",- "prevId": "9b5cec8c-8b59-4d7a-bb5c-76ade1c83d6f",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.account": {- "name": "account",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "email": {- "name": "email",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- }- },- "indexes": {- "email": {- "name": "email",- "columns": [- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.billing": {- "name": "billing",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "customer_id": {- "name": "customer_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_method_id": {- "name": "payment_method_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_method_last4": {- "name": "payment_method_last4",- "type": "varchar(4)",- "primaryKey": false,- "notNull": false- },- "balance": {- "name": "balance",- "type": "bigint",- "primaryKey": false,- "notNull": true- },- "reload": {- "name": "reload",- "type": "boolean",- "primaryKey": false,- "notNull": false- }- },- "indexes": {},- "foreignKeys": {- "billing_workspace_id_workspace_id_fk": {- "name": "billing_workspace_id_workspace_id_fk",- "tableFrom": "billing",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "billing_workspace_id_id_pk": {- "name": "billing_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.payment": {- "name": "payment",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "customer_id": {- "name": "customer_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_id": {- "name": "payment_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "amount": {- "name": "amount",- "type": "bigint",- "primaryKey": false,- "notNull": true- }- },- "indexes": {},- "foreignKeys": {- "payment_workspace_id_workspace_id_fk": {- "name": "payment_workspace_id_workspace_id_fk",- "tableFrom": "payment",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "payment_workspace_id_id_pk": {- "name": "payment_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.usage": {- "name": "usage",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "request_id": {- "name": "request_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "model": {- "name": "model",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "input_tokens": {- "name": "input_tokens",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "output_tokens": {- "name": "output_tokens",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "reasoning_tokens": {- "name": "reasoning_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cache_read_tokens": {- "name": "cache_read_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cache_write_tokens": {- "name": "cache_write_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cost": {- "name": "cost",- "type": "bigint",- "primaryKey": false,- "notNull": true- }- },- "indexes": {},- "foreignKeys": {- "usage_workspace_id_workspace_id_fk": {- "name": "usage_workspace_id_workspace_id_fk",- "tableFrom": "usage",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "usage_workspace_id_id_pk": {- "name": "usage_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.user": {- "name": "user",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "time_seen": {- "name": "time_seen",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "color": {- "name": "color",- "type": "integer",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "user_email": {- "name": "user_email",- "columns": [- {- "expression": "workspace_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "user_workspace_id_workspace_id_fk": {- "name": "user_workspace_id_workspace_id_fk",- "tableFrom": "user",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "user_workspace_id_id_pk": {- "name": "user_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.workspace": {- "name": "workspace",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": true,- "notNull": true- },- "slug": {- "name": "slug",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "slug": {- "name": "slug",- "columns": [- {- "expression": "slug",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}\ No newline at end of filediff --git a/cloud/core/migrations/meta/0002_snapshot.json b/cloud/core/migrations/meta/0002_snapshot.jsondeleted file mode 100644index 7d970ab022b..00000000000--- a/cloud/core/migrations/meta/0002_snapshot.json+++ /dev/null@@ -1,615 +0,0 @@-{- "id": "351e4956-74e0-4282-a23b-02f1a73fa38c",- "prevId": "bf9e9084-4073-4ecb-8e56-5610816c9589",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.account": {- "name": "account",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "email": {- "name": "email",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- }- },- "indexes": {- "email": {- "name": "email",- "columns": [- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.billing": {- "name": "billing",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "customer_id": {- "name": "customer_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_method_id": {- "name": "payment_method_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_method_last4": {- "name": "payment_method_last4",- "type": "varchar(4)",- "primaryKey": false,- "notNull": false- },- "balance": {- "name": "balance",- "type": "bigint",- "primaryKey": false,- "notNull": true- },- "reload": {- "name": "reload",- "type": "boolean",- "primaryKey": false,- "notNull": false- }- },- "indexes": {},- "foreignKeys": {- "billing_workspace_id_workspace_id_fk": {- "name": "billing_workspace_id_workspace_id_fk",- "tableFrom": "billing",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "billing_workspace_id_id_pk": {- "name": "billing_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.payment": {- "name": "payment",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "customer_id": {- "name": "customer_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_id": {- "name": "payment_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "amount": {- "name": "amount",- "type": "bigint",- "primaryKey": false,- "notNull": true- }- },- "indexes": {},- "foreignKeys": {- "payment_workspace_id_workspace_id_fk": {- "name": "payment_workspace_id_workspace_id_fk",- "tableFrom": "payment",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "payment_workspace_id_id_pk": {- "name": "payment_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.usage": {- "name": "usage",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "request_id": {- "name": "request_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "model": {- "name": "model",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "input_tokens": {- "name": "input_tokens",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "output_tokens": {- "name": "output_tokens",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "reasoning_tokens": {- "name": "reasoning_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cache_read_tokens": {- "name": "cache_read_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cache_write_tokens": {- "name": "cache_write_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cost": {- "name": "cost",- "type": "bigint",- "primaryKey": false,- "notNull": true- }- },- "indexes": {},- "foreignKeys": {- "usage_workspace_id_workspace_id_fk": {- "name": "usage_workspace_id_workspace_id_fk",- "tableFrom": "usage",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "usage_workspace_id_id_pk": {- "name": "usage_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.key": {- "name": "key",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "user_id": {- "name": "user_id",- "type": "text",- "primaryKey": false,- "notNull": true- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "key": {- "name": "key",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "time_used": {- "name": "time_used",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "global_key": {- "name": "global_key",- "columns": [- {- "expression": "key",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "key_workspace_id_workspace_id_fk": {- "name": "key_workspace_id_workspace_id_fk",- "tableFrom": "key",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "key_workspace_id_id_pk": {- "name": "key_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.user": {- "name": "user",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "time_seen": {- "name": "time_seen",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "color": {- "name": "color",- "type": "integer",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "user_email": {- "name": "user_email",- "columns": [- {- "expression": "workspace_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "user_workspace_id_workspace_id_fk": {- "name": "user_workspace_id_workspace_id_fk",- "tableFrom": "user",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "user_workspace_id_id_pk": {- "name": "user_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.workspace": {- "name": "workspace",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": true,- "notNull": true- },- "slug": {- "name": "slug",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "slug": {- "name": "slug",- "columns": [- {- "expression": "slug",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}\ No newline at end of filediff --git a/cloud/core/migrations/meta/0003_snapshot.json b/cloud/core/migrations/meta/0003_snapshot.jsondeleted file mode 100644index e1202ddbfc5..00000000000--- a/cloud/core/migrations/meta/0003_snapshot.json+++ /dev/null@@ -1,609 +0,0 @@-{- "id": "fa935883-9e51-4811-90c7-8967eefe458c",- "prevId": "351e4956-74e0-4282-a23b-02f1a73fa38c",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.account": {- "name": "account",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "email": {- "name": "email",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- }- },- "indexes": {- "email": {- "name": "email",- "columns": [- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.billing": {- "name": "billing",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "customer_id": {- "name": "customer_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_method_id": {- "name": "payment_method_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_method_last4": {- "name": "payment_method_last4",- "type": "varchar(4)",- "primaryKey": false,- "notNull": false- },- "balance": {- "name": "balance",- "type": "bigint",- "primaryKey": false,- "notNull": true- },- "reload": {- "name": "reload",- "type": "boolean",- "primaryKey": false,- "notNull": false- }- },- "indexes": {},- "foreignKeys": {- "billing_workspace_id_workspace_id_fk": {- "name": "billing_workspace_id_workspace_id_fk",- "tableFrom": "billing",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "billing_workspace_id_id_pk": {- "name": "billing_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.payment": {- "name": "payment",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "customer_id": {- "name": "customer_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "payment_id": {- "name": "payment_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "amount": {- "name": "amount",- "type": "bigint",- "primaryKey": false,- "notNull": true- }- },- "indexes": {},- "foreignKeys": {- "payment_workspace_id_workspace_id_fk": {- "name": "payment_workspace_id_workspace_id_fk",- "tableFrom": "payment",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "payment_workspace_id_id_pk": {- "name": "payment_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.usage": {- "name": "usage",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "model": {- "name": "model",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "input_tokens": {- "name": "input_tokens",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "output_tokens": {- "name": "output_tokens",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "reasoning_tokens": {- "name": "reasoning_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cache_read_tokens": {- "name": "cache_read_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cache_write_tokens": {- "name": "cache_write_tokens",- "type": "integer",- "primaryKey": false,- "notNull": false- },- "cost": {- "name": "cost",- "type": "bigint",- "primaryKey": false,- "notNull": true- }- },- "indexes": {},- "foreignKeys": {- "usage_workspace_id_workspace_id_fk": {- "name": "usage_workspace_id_workspace_id_fk",- "tableFrom": "usage",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "usage_workspace_id_id_pk": {- "name": "usage_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.key": {- "name": "key",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "user_id": {- "name": "user_id",- "type": "text",- "primaryKey": false,- "notNull": true- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "key": {- "name": "key",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "time_used": {- "name": "time_used",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "global_key": {- "name": "global_key",- "columns": [- {- "expression": "key",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "key_workspace_id_workspace_id_fk": {- "name": "key_workspace_id_workspace_id_fk",- "tableFrom": "key",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "key_workspace_id_id_pk": {- "name": "key_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.user": {- "name": "user",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "workspace_id": {- "name": "workspace_id",- "type": "varchar(30)",- "primaryKey": false,- "notNull": true- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true- },- "time_seen": {- "name": "time_seen",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- },- "color": {- "name": "color",- "type": "integer",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "user_email": {- "name": "user_email",- "columns": [- {- "expression": "workspace_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "email",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "user_workspace_id_workspace_id_fk": {- "name": "user_workspace_id_workspace_id_fk",- "tableFrom": "user",- "tableTo": "workspace",- "columnsFrom": [- "workspace_id"- ],- "columnsTo": [- "id"- ],- "onDelete": "no action",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {- "user_workspace_id_id_pk": {- "name": "user_workspace_id_id_pk",- "columns": [- "workspace_id",- "id"- ]- }- },- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.workspace": {- "name": "workspace",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(30)",- "primaryKey": true,- "notNull": true- },- "slug": {- "name": "slug",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "name": {- "name": "name",- "type": "varchar(255)",- "primaryKey": false,- "notNull": false- },- "time_created": {- "name": "time_created",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "time_deleted": {- "name": "time_deleted",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": false- }- },- "indexes": {- "slug": {- "name": "slug",- "columns": [- {- "expression": "slug",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": true,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}\ No newline at end of filediff --git a/cloud/core/migrations/meta/_journal.json b/cloud/core/migrations/meta/_journal.jsonindex ceba11e26bb..6ff70c2171d 100644--- a/cloud/core/migrations/meta/_journal.json+++ b/cloud/core/migrations/meta/_journal.json@@ -1,33 +1,12 @@{"version": "7",- "dialect": "postgresql",+ "dialect": "mysql","entries": [{"idx": 0,- "version": "7",- "when": 1754518198186,- "tag": "0000_amused_mojo",- "breakpoints": true- },- {- "idx": 1,- "version": "7",- "when": 1754609655262,- "tag": "0001_thankful_chat",- "breakpoints": true- },- {- "idx": 2,- "version": "7",- "when": 1754627626945,- "tag": "0002_stale_jackal",- "breakpoints": true- },- {- "idx": 3,- "version": "7",- "when": 1754672464106,- "tag": "0003_tranquil_spencer_smythe",+ "version": "5",+ "when": 1756796050935,+ "tag": "0000_fluffy_raza","breakpoints": true}]diff --git a/cloud/core/package.json b/cloud/core/package.jsonindex 702bb3b0673..10ba3479cf6 100644--- a/cloud/core/package.json+++ b/cloud/core/package.json@@ -7,6 +7,7 @@"dependencies": {"@aws-sdk/client-sts": "3.782.0","@opencode/cloud-resource": "workspace:*",+ "@planetscale/database": "1.19.0","drizzle-orm": "0.41.0","postgres": "3.4.7","stripe": "18.0.0",@@ -19,6 +20,7 @@"db": "sst shell drizzle-kit"},"devDependencies": {- "drizzle-kit": "0.30.5"+ "drizzle-kit": "0.30.5",+ "mysql2": "3.14.4"}}diff --git a/cloud/core/src/billing.ts b/cloud/core/src/billing.tsindex 620a72212ef..ee44a24ef08 100644--- a/cloud/core/src/billing.ts+++ b/cloud/core/src/billing.ts@@ -80,14 +80,12 @@ export namespace Billing {cacheWriteTokens: input.cacheWriteTokens,cost,})- const [updated] = await tx+ await tx.update(BillingTable).set({balance: sql`${BillingTable.balance} - ${cost}`,}).where(eq(BillingTable.workspaceID, workspaceID))- .returning()- return updated.balance})},)diff --git a/cloud/core/src/drizzle/index.ts b/cloud/core/src/drizzle/index.tsindex 23441928ef3..80603799603 100644--- a/cloud/core/src/drizzle/index.ts+++ b/cloud/core/src/drizzle/index.ts@@ -1,41 +1,33 @@-import { drizzle } from "drizzle-orm/postgres-js"+import { drizzle } from "drizzle-orm/planetscale-serverless"import { Resource } from "@opencode/cloud-resource"export * from "drizzle-orm"-import postgres from "postgres"+import { Client } from "@planetscale/database"-const init = () => {- const client = postgres({- idle_timeout: 30000,- connect_timeout: 30000,- host: Resource.Database.host,- database: Resource.Database.database,- user: Resource.Database.username,- password: Resource.Database.password,- port: Resource.Database.port,- ssl: {- rejectUnauthorized: false,- },- max: 6,- })- return drizzle(client, {})-}--const createClient = init--import { PgTransaction, type PgTransactionConfig } from "drizzle-orm/pg-core"+import { MySqlTransaction, type MySqlTransactionConfig } from "drizzle-orm/mysql-core"import type { ExtractTablesWithRelations } from "drizzle-orm"-import type { PostgresJsQueryResultHKT } from "drizzle-orm/postgres-js"+import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "drizzle-orm/planetscale-serverless"import { Context } from "../context"import { memo } from "../util/memo"export namespace Database {- export type Transaction = PgTransaction<- PostgresJsQueryResultHKT,- Record<string, unknown>,- ExtractTablesWithRelations<Record<string, unknown>>+ export type Transaction = MySqlTransaction<+ PlanetscaleQueryResultHKT,+ PlanetScalePreparedQueryHKT,+ Record<string, never>,+ ExtractTablesWithRelations<Record<string, never>>>- export type TxOrDb = Transaction | ReturnType<typeof createClient>+ const client = memo(() => {+ const result = new Client({+ host: Resource.Database.host,+ username: Resource.Database.username,+ password: Resource.Database.password,+ })+ const db = drizzle(result, {})+ return db+ })++ export type TxOrDb = Transaction | ReturnType<typeof client>const TransactionContext = Context.create<{tx: TxOrDb@@ -48,14 +40,13 @@ export namespace Database {return tx.transaction(callback)} catch (err) {if (err instanceof Context.NotFound) {- const client = createClient()const effects: (() => void | Promise<void>)[] = []const result = await TransactionContext.provide({effects,- tx: client,+ tx: client(),},- () => callback(client),+ () => callback(client()),)await Promise.all(effects.map((x) => x()))return result@@ -76,15 +67,14 @@ export namespace Database {}}- export async function transaction<T>(callback: (tx: TxOrDb) => Promise<T>, config?: PgTransactionConfig) {+ export async function transaction<T>(callback: (tx: TxOrDb) => Promise<T>, config?: MySqlTransactionConfig) {try {const { tx } = TransactionContext.use()return callback(tx)} catch (err) {if (err instanceof Context.NotFound) {- const client = createClient()const effects: (() => void | Promise<void>)[] = []- const result = await client.transaction(async (tx) => {+ const result = await client().transaction(async (tx) => {return TransactionContext.provide({ tx, effects }, () => callback(tx))}, config)await Promise.all(effects.map((x) => x()))diff --git a/cloud/core/src/drizzle/types.ts b/cloud/core/src/drizzle/types.tsindex 5ae95d0112c..f16ad5a8aae 100644--- a/cloud/core/src/drizzle/types.ts+++ b/cloud/core/src/drizzle/types.ts@@ -1,4 +1,5 @@-import { bigint, timestamp, varchar } from "drizzle-orm/pg-core"+import { sql } from "drizzle-orm"+import { bigint, timestamp, varchar } from "drizzle-orm/mysql-core"export const ulid = (name: string) => varchar(name, { length: 30 })@@ -15,7 +16,7 @@ export const id = () => ulid("id").notNull()export const utc = (name: string) =>timestamp(name, {- withTimezone: true,+ fsp: 3,})export const currency = (name: string) =>@@ -25,5 +26,8 @@ export const currency = (name: string) =>export const timestamps = {timeCreated: utc("time_created").notNull().defaultNow(),+ timeUpdated: utc("time_updated")+ .notNull()+ .default(sql`CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)`),timeDeleted: utc("time_deleted"),}diff --git a/cloud/core/src/key.ts b/cloud/core/src/key.tsindex cf4f6e4104f..b195bd7c94c 100644--- a/cloud/core/src/key.ts+++ b/cloud/core/src/key.ts@@ -36,44 +36,26 @@ export namespace Key {randomPart += chars.charAt(Math.floor(Math.random() * chars.length))}const secretKey = `sk-${randomPart}`-- const keyRecord = await Database.use((tx) =>- tx- .insert(KeyTable)- .values({- id: Identifier.create("key"),- workspaceID: user.properties.workspaceID,- userID: user.properties.userID,- name,- key: secretKey,- timeUsed: null,- })- .returning(),+ const keyID = Identifier.create("key")++ await Database.use((tx) =>+ tx.insert(KeyTable).values({+ id: keyID,+ workspaceID: user.properties.workspaceID,+ userID: user.properties.userID,+ name,+ key: secretKey,+ timeUsed: null,+ }),)- return {- key: secretKey,- id: keyRecord[0].id,- name: keyRecord[0].name,- created: keyRecord[0].timeCreated,- }+ return keyID})export const remove = fn(z.object({ id: z.string() }), async (input) => {const user = Actor.assert("user")- const { id } = input-- const result = await Database.use((tx) =>- tx- .delete(KeyTable)- .where(and(eq(KeyTable.id, id), eq(KeyTable.workspaceID, user.properties.workspaceID)))- .returning({ id: KeyTable.id }),+ await Database.use((tx) =>+ tx.delete(KeyTable).where(and(eq(KeyTable.id, input.id), eq(KeyTable.workspaceID, user.properties.workspaceID))),)-- if (result.length === 0) {- throw new Error("Key not found")- }-- return { id: result[0].id }})}diff --git a/cloud/core/src/schema/account.sql.ts b/cloud/core/src/schema/account.sql.tsindex 1733f0a1568..4d993711475 100644--- a/cloud/core/src/schema/account.sql.ts+++ b/cloud/core/src/schema/account.sql.ts@@ -1,7 +1,7 @@-import { pgTable, uniqueIndex, varchar } from "drizzle-orm/pg-core"+import { mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core"import { id, timestamps } from "../drizzle/types"-export const AccountTable = pgTable(+export const AccountTable = mysqlTable("account",{id: id(),diff --git a/cloud/core/src/schema/billing.sql.ts b/cloud/core/src/schema/billing.sql.tsindex 96b29f5def6..eff1f6550ae 100644--- a/cloud/core/src/schema/billing.sql.ts+++ b/cloud/core/src/schema/billing.sql.ts@@ -1,8 +1,8 @@-import { bigint, boolean, integer, pgTable, varchar } from "drizzle-orm/pg-core"+import { bigint, boolean, int, mysqlTable, varchar } from "drizzle-orm/mysql-core"import { timestamps, workspaceColumns } from "../drizzle/types"import { workspaceIndexes } from "./workspace.sql"-export const BillingTable = pgTable(+export const BillingTable = mysqlTable("billing",{...workspaceColumns,@@ -16,7 +16,7 @@ export const BillingTable = pgTable((table) => [...workspaceIndexes(table)],)-export const PaymentTable = pgTable(+export const PaymentTable = mysqlTable("payment",{...workspaceColumns,@@ -28,17 +28,17 @@ export const PaymentTable = pgTable((table) => [...workspaceIndexes(table)],)-export const UsageTable = pgTable(+export const UsageTable = mysqlTable("usage",{...workspaceColumns,...timestamps,model: varchar("model", { length: 255 }).notNull(),- inputTokens: integer("input_tokens").notNull(),- outputTokens: integer("output_tokens").notNull(),- reasoningTokens: integer("reasoning_tokens"),- cacheReadTokens: integer("cache_read_tokens"),- cacheWriteTokens: integer("cache_write_tokens"),+ inputTokens: int("input_tokens").notNull(),+ outputTokens: int("output_tokens").notNull(),+ reasoningTokens: int("reasoning_tokens"),+ cacheReadTokens: int("cache_read_tokens"),+ cacheWriteTokens: int("cache_write_tokens"),cost: bigint("cost", { mode: "number" }).notNull(),},(table) => [...workspaceIndexes(table)],diff --git a/cloud/core/src/schema/key.sql.ts b/cloud/core/src/schema/key.sql.tsindex 240736b86d7..200e829cb00 100644--- a/cloud/core/src/schema/key.sql.ts+++ b/cloud/core/src/schema/key.sql.ts@@ -1,8 +1,8 @@-import { text, pgTable, varchar, uniqueIndex } from "drizzle-orm/pg-core"+import { text, mysqlTable, varchar, uniqueIndex } from "drizzle-orm/mysql-core"import { timestamps, utc, workspaceColumns } from "../drizzle/types"import { workspaceIndexes } from "./workspace.sql"-export const KeyTable = pgTable(+export const KeyTable = mysqlTable("key",{...workspaceColumns,diff --git a/cloud/core/src/schema/user.sql.ts b/cloud/core/src/schema/user.sql.tsindex 34cbd6bebc6..00c372d1aa5 100644--- a/cloud/core/src/schema/user.sql.ts+++ b/cloud/core/src/schema/user.sql.ts@@ -1,16 +1,16 @@-import { text, pgTable, uniqueIndex, varchar, integer } from "drizzle-orm/pg-core"+import { text, mysqlTable, uniqueIndex, varchar, int } from "drizzle-orm/mysql-core"import { timestamps, utc, workspaceColumns } from "../drizzle/types"import { workspaceIndexes } from "./workspace.sql"-export const UserTable = pgTable(+export const UserTable = mysqlTable("user",{...workspaceColumns,...timestamps,- email: text("email").notNull(),+ email: varchar("email", { length: 255 }).notNull(),name: varchar("name", { length: 255 }).notNull(),timeSeen: utc("time_seen"),- color: integer("color"),+ color: int("color"),},(table) => [...workspaceIndexes(table), uniqueIndex("user_email").on(table.workspaceID, table.email)],)diff --git a/cloud/core/src/schema/workspace.sql.ts b/cloud/core/src/schema/workspace.sql.tsindex 3e9379e1f53..97925542897 100644--- a/cloud/core/src/schema/workspace.sql.ts+++ b/cloud/core/src/schema/workspace.sql.ts@@ -1,7 +1,7 @@-import { primaryKey, foreignKey, pgTable, uniqueIndex, varchar } from "drizzle-orm/pg-core"+import { primaryKey, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core"import { timestamps, ulid } from "../drizzle/types"-export const WorkspaceTable = pgTable(+export const WorkspaceTable = mysqlTable("workspace",{id: ulid("id").notNull().primaryKey(),@@ -17,9 +17,5 @@ export function workspaceIndexes(table: any) {primaryKey({columns: [table.workspaceID, table.id],}),- foreignKey({- foreignColumns: [WorkspaceTable.id],- columns: [table.workspaceID],- }),]}diff --git a/cloud/core/src/util/memo.ts b/cloud/core/src/util/memo.tsindex 3c84cf1fb46..49043010f73 100644--- a/cloud/core/src/util/memo.ts+++ b/cloud/core/src/util/memo.ts@@ -1,11 +1,18 @@-export function memo<T>(fn: () => T) {+export function memo<T>(fn: () => T, cleanup?: (input: T) => Promise<void>) {let value: T | undefinedlet loaded = false- return (): T => {+ const result = (): T => {if (loaded) return value as Tloaded = truevalue = fn()return value as T}+ result.reset = async () => {+ if (cleanup && value) await cleanup(value)+ loaded = false+ value = undefined+ }++ return result}diff --git a/cloud/function/src/auth.ts b/cloud/function/src/auth.tsindex 17c3fa8eaca..bda02cd8718 100644--- a/cloud/function/src/auth.ts+++ b/cloud/function/src/auth.ts@@ -10,6 +10,7 @@ import { Account } from "@opencode/cloud-core/account.js"import { Workspace } from "@opencode/cloud-core/workspace.js"import { Actor } from "@opencode/cloud-core/actor.js"import { Resource } from "@opencode/cloud-resource"+import { Database } from "@opencode/cloud-core/drizzle/index.js"type Env = {AuthStorage: KVNamespace@@ -33,7 +34,7 @@ const MY_THEME: Theme = {export default {async fetch(request: Request, env: Env, ctx: ExecutionContext) {- return issuer({+ const result = await issuer({theme: MY_THEME,providers: {github: GithubProvider({@@ -135,5 +136,6 @@ export default {return ctx.subject("account", accountID, { accountID, email })},}).fetch(request, env, ctx)+ return result},}diff --git a/cloud/function/sst-env.d.ts b/cloud/function/sst-env.d.tsindex 9c4f5cc0d3f..d0b2bb4a4da 100644--- a/cloud/function/sst-env.d.ts+++ b/cloud/function/sst-env.d.ts@@ -18,14 +18,6 @@ declare module "sst" {"type": "sst.cloudflare.SolidStart""url": string}- "DATABASE_PASSWORD": {- "type": "sst.sst.Secret"- "value": string- }- "DATABASE_USERNAME": {- "type": "sst.sst.Secret"- "value": string- }"Database": {"database": string"host": stringdiff --git a/cloud/resource/sst-env.d.ts b/cloud/resource/sst-env.d.tsindex 9c4f5cc0d3f..d0b2bb4a4da 100644--- a/cloud/resource/sst-env.d.ts+++ b/cloud/resource/sst-env.d.ts@@ -18,14 +18,6 @@ declare module "sst" {"type": "sst.cloudflare.SolidStart""url": string}- "DATABASE_PASSWORD": {- "type": "sst.sst.Secret"- "value": string- }- "DATABASE_USERNAME": {- "type": "sst.sst.Secret"- "value": string- }"Database": {"database": string"host": stringdiff --git a/infra/cloud.ts b/infra/cloud.tsindex 8181ae0e082..9dbfcd2cc0f 100644--- a/infra/cloud.ts+++ b/infra/cloud.ts@@ -5,15 +5,40 @@ import { domain } from "./stage"// DATABASE////////////////-const DATABASE_USERNAME = new sst.Secret("DATABASE_USERNAME")-const DATABASE_PASSWORD = new sst.Secret("DATABASE_PASSWORD")+const cluster = planetscale.getDatabaseOutput({+ name: "opencode",+ organization: "sst",+})++const branch =+ $app.stage === "production"+ ? planetscale.getBranchOutput({+ name: "production",+ organization: cluster.organization,+ database: cluster.name,+ })+ : new planetscale.Branch("DatabaseBranch", {+ database: cluster.name,+ organization: cluster.organization,+ name: $app.stage,+ parentBranch: "production",+ })+const password = new planetscale.Password("DatabasePassword", {+ name: $app.stage,+ database: cluster.name,+ organization: cluster.organization,+ branch: branch.name,+})++password.accessHostUrl.apply(console.log)+export const database = new sst.Linkable("Database", {properties: {- host: `aws-us-east-2-${$app.stage === "thdxr" ? "2" : "1"}.pg.psdb.cloud`,- database: "postgres",- username: DATABASE_USERNAME.value,- password: DATABASE_PASSWORD.value,- port: 6432,+ host: password.accessHostUrl,+ database: cluster.name,+ username: password.username,+ password: password.plaintext,+ port: 3306,},})@@ -105,7 +130,7 @@ export const gateway = new sst.cloudflare.Worker("GatewayApi", {// CONSOLE////////////////-export const console = new sst.cloudflare.x.SolidStart("Console", {+new sst.cloudflare.x.SolidStart("Console", {domain: `console.${domain}`,path: "cloud/app",link: [diff --git a/packages/function/sst-env.d.ts b/packages/function/sst-env.d.tsindex 9c4f5cc0d3f..d0b2bb4a4da 100644--- a/packages/function/sst-env.d.ts+++ b/packages/function/sst-env.d.ts@@ -18,14 +18,6 @@ declare module "sst" {"type": "sst.cloudflare.SolidStart""url": string}- "DATABASE_PASSWORD": {- "type": "sst.sst.Secret"- "value": string- }- "DATABASE_USERNAME": {- "type": "sst.sst.Secret"- "value": string- }"Database": {"database": string"host": stringdiff --git a/sst-env.d.ts b/sst-env.d.tsindex 8725b456808..a9276330acb 100644--- a/sst-env.d.ts+++ b/sst-env.d.ts@@ -32,14 +32,6 @@ declare module "sst" {"type": "sst.cloudflare.SolidStart""url": string}- "DATABASE_PASSWORD": {- "type": "sst.sst.Secret"- "value": string- }- "DATABASE_USERNAME": {- "type": "sst.sst.Secret"- "value": string- }"Database": {"database": string"host": stringdiff --git a/sst.config.ts b/sst.config.tsindex 44f984b93cc..06cce7f3fd9 100644--- a/sst.config.ts+++ b/sst.config.ts@@ -1,5 +1,4 @@/// <reference path="./.sst/platform/config.d.ts" />-export default $config({app(input) {return {@@ -11,16 +10,17 @@ export default $config({stripe: {apiKey: process.env.STRIPE_SECRET_KEY,},+ planetscale: "0.4.1",},- }+ };},async run() {- const { api } = await import("./infra/app.js")- const { auth, gateway } = await import("./infra/cloud.js")+ const { api } = await import("./infra/app.js");+ const { auth, gateway } = await import("./infra/cloud.js");return {api: api.url,gateway: gateway.url,auth: auth.url,- }+ };},-})+});