void 0.10.13 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS_TEMPLATE.md +6 -0
- package/{skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md → LICENSE} +1 -1
- package/README.md +34 -8
- package/dist/{auth-qgMlYp7Z.d.mts → auth-DkcFflXV.d.mts} +10 -11
- package/dist/auth-W9WII-mN.mjs +630 -0
- package/dist/{auth-cmd-BqsdZJp5.mjs → auth-cmd-CAH62yDU.mjs} +4 -3
- package/dist/{auth-migrations-BTZ-ATvQ.mjs → auth-migrations-9vif1uj8.mjs} +53 -12
- package/dist/{better-auth-shared-BQooDxbw.mjs → better-auth-shared-CYw1T3k4.mjs} +7 -10
- package/dist/{better-auth-shared-DealXecJ.d.mts → better-auth-shared-DSCeohOK.d.mts} +10 -5
- package/dist/{build-cmd-Bujrv5q-.mjs → build-cmd-CJvZvPQO.mjs} +6 -4
- package/dist/{cache-C11V8Fxq.mjs → cache-BlNeQjuP.mjs} +9 -5
- package/dist/{cancel-deploy-fwFYF04b.mjs → cancel-deploy-CmlAZ9P6.mjs} +3 -2
- package/dist/cf-access-AJ1ehiFR.mjs +42 -0
- package/dist/cf-access-DsSsZUPr.mjs +67 -0
- package/dist/cli/cli.d.mts +1 -1
- package/dist/cli/cli.mjs +1735 -165
- package/dist/cli/env-schema-probe.d.mts +48 -61
- package/dist/cli/env-schema-probe.mjs +10 -58
- package/dist/{client-Gb71-XkG.mjs → client-Clirrol3.mjs} +120 -463
- package/dist/cloudflare-auth-B1QtTO1b.mjs +217 -0
- package/dist/cloudflare-cmd-B6_OZx2V.mjs +62 -0
- package/dist/cloudflare-connect-j5D4hhrG.mjs +56 -0
- package/dist/cloudflare-operations-CPTpRW6d.mjs +566 -0
- package/dist/{config-qHGgPuWT.mjs → config-BQFq7QvD.mjs} +75 -41
- package/dist/{config-CutEMNGJ.mjs → config-NOG_U1aK.mjs} +10 -15
- package/dist/connect-C04Wdy_h.mjs +79 -0
- package/dist/{create-project-DsYvl3TB.mjs → create-project-ChGZ1DFd.mjs} +26 -16
- package/dist/database-provider.d.mts +21 -0
- package/dist/database-provider.mjs +6 -0
- package/dist/{db-C0i0sYMS.mjs → db-D2d_mUsB.mjs} +612 -117
- package/dist/{delete-mh6p-zkQ.mjs → delete-D8GigDk8.mjs} +9 -6
- package/dist/{deploy-jBJT1fUT.mjs → deploy-iXZ3F0N6.mjs} +3252 -1995
- package/dist/dev-inbox-DkgRWLkW.mjs +307 -0
- package/dist/{discover-CJHyvYfR.mjs → discover-xvfrgJeo.mjs} +3 -3
- package/dist/{magic-string.es-ZQjdJFFn.mjs → dist-BR1quN_w.mjs} +570 -216
- package/dist/{dist-DaKKDf8D.mjs → dist-BrsS7cai.mjs} +17 -2
- package/dist/{dist-BuiRJkTd.mjs → dist-m40_XgNh.mjs} +48 -33
- package/dist/{domain-DiaNQbrl.mjs → domain-B1VmoSr0.mjs} +41 -4
- package/dist/dotenv-VQxupEUv.mjs +181 -0
- package/dist/edge.d.mts +2 -0
- package/dist/edge.mjs +2 -0
- package/dist/email-Ce6SQq-i.mjs +182 -0
- package/dist/email-uKyQYUVY.mjs +1016 -0
- package/dist/{entry-D7yy4xVH.mjs → entry-DU3oDoQ3.mjs} +2 -2
- package/dist/env-BcQzYgoG.mjs +73 -0
- package/dist/env-D4Emu-M_.mjs +95 -0
- package/dist/env-helpers-CyKtOBpj.d.mts +22 -0
- package/dist/env-public-D_6u46fX.d.mts +135 -0
- package/dist/{env-types-QBj-ndax.mjs → env-types-BNPhro-M.mjs} +2 -2
- package/dist/{env-validation-Dea3v3ej.mjs → env-validation-ENpMy6Ez.mjs} +68 -122
- package/dist/{gen-BzXf3Jh2.mjs → gen-DI2YwdBM.mjs} +70 -15
- package/dist/generate-RTK8_kK1.mjs +47 -0
- package/dist/{github-cmd-DKcGUNsj.mjs → github-cmd-xItS5Zwf.mjs} +39 -31
- package/dist/{handler-Cjh8uM3Y.d.mts → handler-D1hLsObx.d.mts} +124 -122
- package/dist/{head-nmvOgFjd.d.mts → head-Do8P4puT.d.mts} +9 -8
- package/dist/{headers-ChAADPQu.mjs → headers-D8QfRX9Y.mjs} +12 -10
- package/dist/inbound-2d0zi2yS.mjs +706 -0
- package/dist/inbound-afAcWeQ9.d.mts +363 -0
- package/dist/index.d.mts +61 -34
- package/dist/index.mjs +1012 -293
- package/dist/{init-7JCAcKNQ.mjs → init-BD-9THgn.mjs} +329 -271
- package/dist/link-RMdgjF1v.mjs +52 -0
- package/dist/{list-CPwFDZ_c.mjs → list-3F52R_yO.mjs} +37 -5
- package/dist/{runner-kapo9aPs.mjs → local-d1-D2I6Ox5F.mjs} +116 -6
- package/dist/{login-BT3H8PN3.mjs → login-pV69H-ZO.mjs} +17 -15
- package/dist/{logs-Bt313ax7.mjs → logs-DFHHD6wE.mjs} +16 -2
- package/dist/mime-BJD7d_qL.mjs +1216 -0
- package/dist/neon-DHwd2zvC.mjs +54 -0
- package/dist/{node-pRg81HqV.mjs → node-Dk3H2jmU.mjs} +29 -8
- package/dist/operator-cmd-DYWRbWUA.mjs +348 -0
- package/dist/{agents-CtgBYqld.mjs → output-tFQLLj26.mjs} +676 -211
- package/dist/{package-json-Cx1osYo6.mjs → package-json-CPoWX79C.mjs} +1 -1
- package/dist/pages/client.d.mts +43 -41
- package/dist/pages/client.mjs +40 -33
- package/dist/pages/head-client.d.mts +10 -12
- package/dist/pages/head.d.mts +1 -1
- package/dist/pages/index.d.mts +37 -14
- package/dist/pages/index.mjs +5 -5
- package/dist/pages/islands-plugin.d.mts +25 -27
- package/dist/pages/islands-plugin.mjs +6 -4
- package/dist/pages/prefetch.d.mts +6 -7
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +2 -1
- package/dist/pages/serialize.d.mts +7 -8
- package/dist/platform-cmd-DxJ2FRwR.mjs +123 -0
- package/dist/platform-domain-ChvbJkdy.mjs +228 -0
- package/dist/platform-lifecycle-DN4MzJF_.mjs +4450 -0
- package/dist/platform-management-Db2PXw0B.mjs +698 -0
- package/dist/platform-recovery-C_YO-tIs.mjs +99 -0
- package/dist/{plugin-inference-DMeavIJ6.mjs → plugin-inference-BDRfZngg.mjs} +35 -19
- package/dist/prepare-BfJvFUtJ.mjs +14 -0
- package/dist/{prepare-BvvgAz-3.mjs → prepare-CBetXvsN.mjs} +15 -24
- package/dist/{preset-BjyR3lzz.mjs → preset-lAy0B0BQ.mjs} +25 -212
- package/dist/{project-cmd-D_w-4w5B.mjs → project-cmd-Mo0V9yKS.mjs} +25 -12
- package/dist/{project-paths-BQd7OmIo.mjs → project-paths-SK8nMHPp.mjs} +3 -1
- package/dist/{project-tsconfig-B-QtXjLQ.mjs → project-tsconfig-Ql2XsSQp.mjs} +2 -2
- package/dist/{protocol-Bnb0LFp3.d.mts → protocol-C-pqYJjE.d.mts} +3 -4
- package/dist/{provision-CPx2ZxsH.mjs → provision-Blnstcm2.mjs} +78 -45
- package/dist/r2-conditions-D1Wk8i7b.mjs +30 -0
- package/dist/{requests-B8sZxaFM.mjs → requests-BcKOVpRg.mjs} +5 -3
- package/dist/{resolve-project-BBMtLLV9.mjs → resolve-project--Vxawf7z.mjs} +2 -2
- package/dist/rollback-Bx85-0xh.mjs +166 -0
- package/dist/{rolldown-runtime-DJK8HYOj.mjs → rolldown-runtime-rQ84J-ij.mjs} +1 -1
- package/dist/{route-types-z1jtHEi_.mjs → route-types-Da-DpyUp.mjs} +77 -25
- package/dist/routes-stub.d.mts +22 -23
- package/dist/runner-mysql-7BPUNGmL.mjs +61 -0
- package/dist/{runner-pg-CHM76xuC.mjs → runner-pg-BkEza-dX.mjs} +18 -6
- package/dist/runtime/ai.d.mts +21 -14
- package/dist/runtime/ai.mjs +5 -4
- package/dist/runtime/auth-client-react.d.mts +3 -5
- package/dist/runtime/auth-client-solid.d.mts +3 -5
- package/dist/runtime/auth-client-svelte.d.mts +3 -5
- package/dist/runtime/auth-client-vue.d.mts +3 -5
- package/dist/runtime/auth-client.d.mts +3 -5
- package/dist/runtime/auth.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.d.mts +10 -0
- package/dist/runtime/better-auth-mysql.mjs +49 -0
- package/dist/runtime/better-auth-pg.d.mts +8 -9
- package/dist/runtime/better-auth-pg.mjs +2 -2
- package/dist/runtime/better-auth.d.mts +8 -9
- package/dist/runtime/better-auth.mjs +2 -2
- package/dist/runtime/client-react.d.mts +1 -1
- package/dist/runtime/client-solid.d.mts +1 -1
- package/dist/runtime/client-svelte.d.mts +1 -1
- package/dist/runtime/client-vue.d.mts +1 -1
- package/dist/runtime/client.d.mts +1 -1
- package/dist/runtime/db-mysql.d.mts +2 -0
- package/dist/runtime/db-mysql.mjs +1 -0
- package/dist/runtime/db.d.mts +10 -11
- package/dist/runtime/durable.d.mts +47 -0
- package/dist/runtime/durable.mjs +146 -0
- package/dist/runtime/email/testing.d.mts +112 -0
- package/dist/runtime/email/testing.mjs +283 -0
- package/dist/runtime/email.d.mts +30 -0
- package/dist/runtime/email.mjs +573 -0
- package/dist/runtime/env-helpers.d.mts +2 -2
- package/dist/runtime/env-helpers.mjs +5 -42
- package/dist/runtime/env-public-client.d.mts +10 -11
- package/dist/runtime/env-public-client.mjs +1 -1
- package/dist/runtime/env-public.d.mts +2 -2
- package/dist/runtime/env-public.mjs +104 -49
- package/dist/runtime/env.d.mts +19 -18
- package/dist/runtime/env.mjs +15 -2
- package/dist/runtime/fetch-stream.d.mts +20 -21
- package/dist/runtime/fetch.d.mts +15 -16
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/isr.d.mts +21 -22
- package/dist/runtime/isr.mjs +26 -8
- package/dist/runtime/kv.d.mts +9 -10
- package/dist/runtime/live-client.d.mts +5 -7
- package/dist/runtime/live-client.mjs +9 -7
- package/dist/runtime/live-server.d.mts +4 -5
- package/dist/runtime/live.d.mts +22 -24
- package/dist/runtime/live.mjs +1 -1
- package/dist/runtime/log.d.mts +16 -17
- package/dist/runtime/migration-handler-mysql.d.mts +4 -0
- package/dist/runtime/migration-handler-mysql.mjs +81 -0
- package/dist/runtime/migration-handler-pg.d.mts +2 -4
- package/dist/runtime/migration-handler.d.mts +5 -6
- package/dist/runtime/migration-handler.mjs +4 -3
- package/dist/runtime/queues.d.mts +3 -4
- package/dist/runtime/queues.mjs +2 -1
- package/dist/runtime/remote/binding-handler.d.mts +10 -12
- package/dist/runtime/remote/binding-handler.mjs +24 -3
- package/dist/runtime/remote/index.d.mts +5 -6
- package/dist/runtime/remote/index.mjs +21 -18
- package/dist/runtime/response.d.mts +10 -11
- package/dist/runtime/sandbox.d.mts +56 -55
- package/dist/runtime/sandbox.mjs +57 -49
- package/dist/runtime/schema-mysql.d.mts +1 -0
- package/dist/runtime/schema-mysql.mjs +2 -0
- package/dist/runtime/seed.d.mts +14 -9
- package/dist/runtime/sse-client.d.mts +6 -7
- package/dist/runtime/sse.d.mts +11 -12
- package/dist/runtime/storage.d.mts +3 -4
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +12 -12
- package/dist/runtime/ws-server.mjs +32 -4
- package/dist/runtime/ws.d.mts +19 -21
- package/dist/{scan-ChWt4pX1.mjs → scan-BMH4rzlv.mjs} +42 -19
- package/dist/{scan-NU4xKGci.mjs → scan-CpK-57ug.mjs} +5 -4
- package/dist/{secret-Dt32J6RI.mjs → secret-ByhJ9AMl.mjs} +62 -5
- package/dist/{skills-CLjN0uUO.mjs → skills-Q46GZMO-.mjs} +6 -4
- package/dist/sqlite-validation-BzKMWnO4.mjs +25 -0
- package/dist/{standard-schema-DJ0HW7QP.d.mts → standard-schema-Fo_vCAZh.d.mts} +6 -6
- package/dist/{subcommand-prompt-BzV8iQZo.mjs → subcommand-prompt-WfySCQ7S.mjs} +67 -48
- package/dist/sveltekit.d.mts +12 -11
- package/dist/sveltekit.mjs +1 -1
- package/dist/types-BAp5AEBU.d.mts +79 -0
- package/dist/types-CKWnYgfy.d.mts +1 -0
- package/dist/{validate-Cw_RLeTj.mjs → validate-tBBN_dXH.mjs} +4 -3
- package/dist/wrangler--imS8n0d.mjs +1796 -0
- package/dist/{yarn-pnp-DJn3SAHF.mjs → yarn-pnp-DxSInkzL.mjs} +1 -1
- package/package.json +79 -65
- package/schema.json +22 -3
- package/skills/void/SKILL.md +59 -2
- package/skills/void/docs/guide/ai.md +32 -14
- package/skills/void/docs/guide/app-types.md +6 -6
- package/skills/void/docs/guide/auth.md +14 -16
- package/skills/void/docs/guide/database/d1.md +6 -0
- package/skills/void/docs/guide/database/mysql.md +60 -0
- package/skills/void/docs/guide/database/postgresql.md +14 -9
- package/skills/void/docs/guide/database.md +39 -26
- package/skills/void/docs/guide/deployment.md +99 -25
- package/skills/void/docs/guide/durable-state.md +140 -0
- package/skills/void/docs/guide/edge/headers.md +5 -5
- package/skills/void/docs/guide/edge/prerendering.md +2 -0
- package/skills/void/docs/guide/edge/revalidation.md +21 -6
- package/skills/void/docs/guide/edge/rewrites.md +18 -14
- package/skills/void/docs/guide/edge/static-assets.md +12 -10
- package/skills/void/docs/guide/email.md +640 -0
- package/skills/void/docs/guide/env-migration.md +109 -0
- package/skills/void/docs/guide/env-vars.md +70 -248
- package/skills/void/docs/guide/index.md +15 -17
- package/skills/void/docs/guide/jobs.md +8 -5
- package/skills/void/docs/guide/live.md +7 -15
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +8 -4
- package/skills/void/docs/guide/pages-routing/islands.md +3 -3
- package/skills/void/docs/guide/pages-routing/loaders.md +6 -4
- package/skills/void/docs/guide/pages-routing/overview.md +7 -7
- package/skills/void/docs/guide/platform-administration.md +212 -0
- package/skills/void/docs/guide/platform-development.md +264 -0
- package/skills/void/docs/guide/queues.md +10 -10
- package/skills/void/docs/guide/quickstart.md +46 -67
- package/skills/void/docs/guide/remote-dev.md +8 -6
- package/skills/void/docs/guide/sandboxes.md +33 -16
- package/skills/void/docs/guide/self-hosted-platform.md +553 -0
- package/skills/void/docs/guide/server-routing.md +5 -5
- package/skills/void/docs/guide/sse.md +4 -4
- package/skills/void/docs/guide/ssg.md +5 -3
- package/skills/void/docs/guide/storage.md +2 -2
- package/skills/void/docs/guide/websockets.md +15 -7
- package/skills/void/docs/index.md +3 -3
- package/skills/void/docs/integrations/agents.md +6 -64
- package/skills/void/docs/integrations/cloudflare.md +165 -146
- package/skills/void/docs/integrations/frameworks/analog.md +4 -4
- package/skills/void/docs/integrations/frameworks/astro.md +5 -5
- package/skills/void/docs/integrations/frameworks/nuxt.md +5 -5
- package/skills/void/docs/integrations/frameworks/overview.md +3 -3
- package/skills/void/docs/integrations/frameworks/react-router.md +3 -3
- package/skills/void/docs/integrations/frameworks/sveltekit.md +3 -3
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +2 -2
- package/skills/void/docs/integrations/nodejs-bun-deno.md +11 -4
- package/skills/void/docs/reference/api.md +42 -6
- package/skills/void/docs/reference/cli.md +665 -160
- package/skills/void/docs/reference/config.md +67 -27
- package/skills/void/docs/reference/resource-inference.md +13 -9
- package/skills/void/docs/reference/structure.md +9 -11
- package/AGENT_PROMPT.md +0 -19
- package/dist/cf-access-Bqw81xAf.mjs +0 -22
- package/dist/env-CZy5MorI.mjs +0 -299
- package/dist/env-helpers-z4stu8uc.d.mts +0 -52
- package/dist/env-mask-Dd47NbR6.mjs +0 -90
- package/dist/env-public-BfiLcMBk.d.mts +0 -140
- package/dist/link-CdGHSIy-.mjs +0 -45
- package/dist/mcp-DoM3_nhd.mjs +0 -377
- package/dist/project-paths-GpziKeQQ.d.mts +0 -25
- package/dist/providers-BNKRacMr.d.mts +0 -7
- package/dist/proxy-D-3_D-Gl.mjs +0 -5
- package/dist/rollback-CkvTFXx5.mjs +0 -90
- package/dist/runtime/isr-cache.d.mts +0 -207
- package/dist/runtime/isr-cache.mjs +0 -523
- package/dist/types-lLjNE9Qp.d.mts +0 -51
- package/getting-started-prompt.txt +0 -28
- package/skills/void/command/void.md +0 -7
- package/skills/void/docs/integrations/auth-providers.md +0 -0
- package/skills/void/docs/integrations/payment-processors.md +0 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +0 -408
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +0 -5
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +0 -103
- package/skills/void/docs/node_modules/oxc-minify/README.md +0 -78
- package/skills/void/docs/node_modules/reka-ui/README.md +0 -80
- package/skills/void/docs/node_modules/vitepress/README.md +0 -28
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +0 -49
- package/skills/void/docs/node_modules/vitepress/template/index.md +0 -28
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +0 -85
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +0 -101
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +0 -19
- package/skills/void/docs/node_modules/void/CLAUDE.md +0 -221
- package/skills/void/docs/node_modules/void/README.md +0 -90
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +0 -685
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +0 -396
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +0 -219
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +0 -37
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +0 -135
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +0 -189
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +0 -143
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +0 -1272
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +0 -19
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@types/proper-lockfile/README.md +0 -51
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +0 -22
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +0 -69
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +0 -153
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +0 -9
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +0 -9
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +0 -24
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +0 -565
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +0 -127
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +0 -600
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +0 -386
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +0 -95
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-footnote/README.md +0 -135
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathslash/README.md +0 -64
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +0 -25
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/AGENTS.md +0 -16
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/README.md +0 -220
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/build.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/check.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/create.md +0 -70
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/fmt.md +0 -20
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/index.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/lint.md +0 -26
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/pack.md +0 -17
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/run.md +0 -364
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/staged.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/test.md +0 -18
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/automatic-data-tracking.md +0 -145
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/build.md +0 -40
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/cache.md +0 -107
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/check.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/ci.md +0 -62
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/commit-hooks.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/create.md +0 -341
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/dev.md +0 -24
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/docker.md +0 -175
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/env.md +0 -167
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/fmt.md +0 -41
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/github-actions-cache.md +0 -165
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/ide-integration.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/implode.md +0 -23
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/index.md +0 -134
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/install.md +0 -199
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/lint.md +0 -50
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/migrate-rules.md +0 -347
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/migrate.md +0 -197
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/monorepo.md +0 -176
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/pack.md +0 -69
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/run.md +0 -356
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/test.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/troubleshooting.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/upgrade.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/vpx.md +0 -66
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/why.md +0 -39
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/index.md +0 -12
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/team.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/templates/generator/README.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/templates/monorepo/README.md +0 -29
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +0 -58
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +0 -165
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +0 -20
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +0 -32
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +0 -99
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +0 -51
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +0 -79
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +0 -44
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +0 -51
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +0 -65
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +0 -403
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +0 -48
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +0 -85
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +0 -452
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +0 -76
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +0 -364
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +0 -41
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +0 -325
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +0 -398
- package/skills/void/docs/node_modules/void/node_modules/pathslash/README.md +0 -64
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +0 -96
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +0 -135
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/proper-lockfile/CHANGELOG.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/proper-lockfile/README.md +0 -183
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +0 -25
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +0 -9
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +0 -94
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/AGENTS.md +0 -16
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/README.md +0 -220
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/build.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/check.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/create.md +0 -70
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/fmt.md +0 -20
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/index.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/lint.md +0 -26
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/pack.md +0 -17
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/run.md +0 -364
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/staged.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/test.md +0 -18
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/automatic-data-tracking.md +0 -145
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/build.md +0 -40
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/cache.md +0 -107
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/check.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/ci.md +0 -62
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/commit-hooks.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/create.md +0 -341
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/dev.md +0 -24
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/docker.md +0 -175
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/env.md +0 -167
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/fmt.md +0 -41
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/github-actions-cache.md +0 -165
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/ide-integration.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/implode.md +0 -23
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/index.md +0 -134
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/install.md +0 -199
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/lint.md +0 -50
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/migrate-rules.md +0 -347
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/migrate.md +0 -197
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/monorepo.md +0 -176
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/pack.md +0 -69
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/run.md +0 -356
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/test.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/troubleshooting.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/upgrade.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/vpx.md +0 -66
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/why.md +0 -39
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/index.md +0 -12
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/team.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/templates/generator/README.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/templates/monorepo/README.md +0 -29
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +0 -63
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +0 -191
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +0 -175
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +0 -76
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +0 -7
- package/skills/void/docs/node_modules/void/test/e2e/README.md +0 -85
|
@@ -1,16 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { D as
|
|
3
|
-
import { n as readProjectPaths } from "./project-paths-
|
|
4
|
-
import { t as cfAccessHeaders } from "./cf-access-
|
|
5
|
-
import { b as
|
|
6
|
-
import { c as getDatabaseDialect, f as readConfig, p as resolveBindingNames } from "./config-
|
|
7
|
-
import { r as detectFramework } from "./plugin-inference-
|
|
8
|
-
import { c as collectMigrations, d as stripSqlExt, f as writeJournal, n as listDrizzleArtifacts, r as validateMigrations, t as assertJournalCoherence, u as readJournal } from "./validate-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { c as relative, i as extname, l as resolve, o as join, t as basename } from "./dist-BrsS7cai.mjs";
|
|
2
|
+
import { D as log, E as intro, F as isCancel, a as dim, c as import_picocolors, k as outro, r as cliTitle, w as confirm } from "./output-tFQLLj26.mjs";
|
|
3
|
+
import { n as readProjectPaths } from "./project-paths-SK8nMHPp.mjs";
|
|
4
|
+
import { t as cfAccessHeaders } from "./cf-access-AJ1ehiFR.mjs";
|
|
5
|
+
import { b as readDeploymentPlatform, c as getToken, o as getProxyUrl, x as readProjectConfig } from "./auth-W9WII-mN.mjs";
|
|
6
|
+
import { c as getDatabaseDialect, f as readConfig, p as resolveBindingNames } from "./config-BQFq7QvD.mjs";
|
|
7
|
+
import { r as detectFramework } from "./plugin-inference-BDRfZngg.mjs";
|
|
8
|
+
import { c as collectMigrations, d as stripSqlExt, f as writeJournal, n as listDrizzleArtifacts, r as validateMigrations, t as assertJournalCoherence, u as readJournal } from "./validate-tBBN_dXH.mjs";
|
|
9
|
+
import { t as resolveLocalD1Target } from "./local-d1-D2I6Ox5F.mjs";
|
|
10
|
+
import { a as loadLocalEnv } from "./env-D4Emu-M_.mjs";
|
|
11
|
+
import { n as PlatformClient, t as PlatformApiError } from "./client-Clirrol3.mjs";
|
|
12
|
+
import { formatTimestamp } from "./gen-DI2YwdBM.mjs";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
11
14
|
import { existsSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
12
15
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
13
16
|
import { execFileSync } from "node:child_process";
|
|
17
|
+
//#region src/cli/db-export-sequences.ts
|
|
18
|
+
function quoteSqlIdentifier(value) {
|
|
19
|
+
return `"${value.replaceAll("\"", "\"\"")}"`;
|
|
20
|
+
}
|
|
21
|
+
function quoteSqlString(value) {
|
|
22
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
23
|
+
}
|
|
24
|
+
/** Restore SERIAL dependencies before tables, ownership/state after their data. */
|
|
25
|
+
async function exportPgSequences(client, tables, options) {
|
|
26
|
+
const result = await client.query(`SELECT ns.nspname AS schema_name, seq.relname AS sequence_name,
|
|
27
|
+
tbl.relname AS table_name, col.attname AS column_name,
|
|
28
|
+
format_type(s.seqtypid, NULL) AS data_type,
|
|
29
|
+
s.seqstart::text AS start_value, s.seqincrement::text AS increment_by,
|
|
30
|
+
s.seqmin::text AS min_value, s.seqmax::text AS max_value,
|
|
31
|
+
s.seqcache::text AS cache_size, s.seqcycle AS cycle
|
|
32
|
+
FROM pg_sequence s
|
|
33
|
+
JOIN pg_class seq ON seq.oid = s.seqrelid
|
|
34
|
+
JOIN pg_namespace ns ON ns.oid = seq.relnamespace
|
|
35
|
+
JOIN pg_depend dep ON dep.objid = seq.oid AND dep.classid = 'pg_class'::regclass AND dep.deptype = 'a'
|
|
36
|
+
JOIN pg_class tbl ON tbl.oid = dep.refobjid
|
|
37
|
+
JOIN pg_namespace tblns ON tblns.oid = tbl.relnamespace
|
|
38
|
+
JOIN pg_attribute col ON col.attrelid = tbl.oid AND col.attnum = dep.refobjsubid
|
|
39
|
+
WHERE tblns.nspname = 'public' AND tbl.relname = ANY($1::text[])
|
|
40
|
+
ORDER BY ns.nspname, seq.relname`, [tables]);
|
|
41
|
+
const before = [];
|
|
42
|
+
const after = [];
|
|
43
|
+
for (const seq of result.rows) {
|
|
44
|
+
const name = `${quoteSqlIdentifier(seq.schema_name)}.${quoteSqlIdentifier(seq.sequence_name)}`;
|
|
45
|
+
if (!options.noSchema) {
|
|
46
|
+
before.push(`CREATE SEQUENCE ${name} AS ${seq.data_type} INCREMENT BY ${seq.increment_by} MINVALUE ${seq.min_value} MAXVALUE ${seq.max_value} START WITH ${seq.start_value} CACHE ${seq.cache_size} ${seq.cycle ? "CYCLE" : "NO CYCLE"};`);
|
|
47
|
+
after.push(`ALTER SEQUENCE ${name} OWNED BY "public".${quoteSqlIdentifier(seq.table_name)}.${quoteSqlIdentifier(seq.column_name)};`);
|
|
48
|
+
}
|
|
49
|
+
if (!options.noData) {
|
|
50
|
+
const value = (await client.query(`SELECT last_value::text, is_called FROM ${name}`)).rows[0];
|
|
51
|
+
after.push(`SELECT pg_catalog.setval(${quoteSqlString(name)}, ${value.last_value}, ${value.is_called});`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
before,
|
|
56
|
+
after
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Add constraints after all tables/data so cross-table references can resolve. */
|
|
60
|
+
async function exportPgConstraints(client, tables) {
|
|
61
|
+
const constraints = await client.query(`
|
|
62
|
+
SELECT tbl.relname AS table_name, con.conname AS name, pg_get_constraintdef(con.oid) AS definition
|
|
63
|
+
FROM pg_constraint con JOIN pg_class tbl ON tbl.oid = con.conrelid
|
|
64
|
+
JOIN pg_namespace ns ON ns.oid = tbl.relnamespace
|
|
65
|
+
WHERE ns.nspname = 'public' AND tbl.relname = ANY($1::text[])
|
|
66
|
+
AND con.contype IN ('p', 'u', 'f', 'c', 'x')
|
|
67
|
+
ORDER BY CASE WHEN con.contype = 'f' THEN 1 ELSE 0 END, tbl.relname, con.conname`, [tables]);
|
|
68
|
+
const indexes = await client.query(`
|
|
69
|
+
SELECT pg_get_indexdef(idx.indexrelid) AS definition
|
|
70
|
+
FROM pg_index idx JOIN pg_class tbl ON tbl.oid = idx.indrelid
|
|
71
|
+
JOIN pg_namespace ns ON ns.oid = tbl.relnamespace
|
|
72
|
+
WHERE ns.nspname = 'public' AND tbl.relname = ANY($1::text[])
|
|
73
|
+
AND NOT EXISTS (SELECT 1 FROM pg_constraint con WHERE con.conindid = idx.indexrelid)
|
|
74
|
+
ORDER BY idx.indexrelid`, [tables]);
|
|
75
|
+
return [...constraints.rows.map((row) => `ALTER TABLE "public".${quoteSqlIdentifier(row.table_name)} ADD CONSTRAINT ${quoteSqlIdentifier(row.name)} ${row.definition};`), ...indexes.rows.map((row) => row.definition + ";")];
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
14
78
|
//#region src/cli/db.ts
|
|
15
79
|
const drizzleKitBin = join(fileURLToPath(import.meta.resolve("drizzle-kit")), "..", "bin.cjs");
|
|
16
80
|
const DEFAULT_SEED_FILES = [
|
|
@@ -26,9 +90,15 @@ const MODULE_SEED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
26
90
|
".js",
|
|
27
91
|
".mjs"
|
|
28
92
|
]);
|
|
29
|
-
function
|
|
93
|
+
function getLocalD1Target(root) {
|
|
30
94
|
const detected = detectFramework(root);
|
|
31
|
-
|
|
95
|
+
const defaultPersistRoot = detected && (detected.class === "b" || detected.class === "c") ? join(root, ".wrangler", "state") : join(root, ".void");
|
|
96
|
+
const bindingName = resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB";
|
|
97
|
+
return resolveLocalD1Target(root, {
|
|
98
|
+
bindingName,
|
|
99
|
+
defaultPersistRoot,
|
|
100
|
+
readPersistState: true
|
|
101
|
+
});
|
|
32
102
|
}
|
|
33
103
|
function runDrizzleKit(root, args) {
|
|
34
104
|
execFileSync(process.execPath, [drizzleKitBin, ...args], {
|
|
@@ -39,26 +109,14 @@ function runDrizzleKit(root, args) {
|
|
|
39
109
|
function getErrorMessage(error) {
|
|
40
110
|
return error instanceof Error ? error.message : String(error);
|
|
41
111
|
}
|
|
42
|
-
function readEnvLocal(root) {
|
|
43
|
-
const envPath = join(root, ".env.local");
|
|
44
|
-
if (!existsSync(envPath)) return {};
|
|
45
|
-
const content = readFileSync(envPath, "utf-8");
|
|
46
|
-
const vars = {};
|
|
47
|
-
for (const line of content.split("\n")) {
|
|
48
|
-
const trimmed = line.trim();
|
|
49
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
50
|
-
const eqIndex = trimmed.indexOf("=");
|
|
51
|
-
if (eqIndex === -1) continue;
|
|
52
|
-
const key = trimmed.slice(0, eqIndex).trim();
|
|
53
|
-
let value = trimmed.slice(eqIndex + 1).trim();
|
|
54
|
-
if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
|
|
55
|
-
vars[key] = value;
|
|
56
|
-
}
|
|
57
|
-
return vars;
|
|
58
|
-
}
|
|
59
112
|
function getPgUrl(root) {
|
|
60
|
-
const url =
|
|
61
|
-
if (!url) throw new Error("DATABASE_URL not found in .env.
|
|
113
|
+
const url = loadLocalEnv(root).DATABASE_URL;
|
|
114
|
+
if (!url) throw new Error("DATABASE_URL not found in .env. Add it to connect to your local PostgreSQL database.");
|
|
115
|
+
return url;
|
|
116
|
+
}
|
|
117
|
+
function getMySqlUrl(root) {
|
|
118
|
+
const url = loadLocalEnv(root).DATABASE_URL;
|
|
119
|
+
if (!url) throw new Error("DATABASE_URL not found in .env. Add it to connect to your local MySQL database.");
|
|
62
120
|
return url;
|
|
63
121
|
}
|
|
64
122
|
async function withPgClient(root, fn) {
|
|
@@ -72,6 +130,27 @@ async function withPgClient(root, fn) {
|
|
|
72
130
|
await client.end();
|
|
73
131
|
}
|
|
74
132
|
}
|
|
133
|
+
async function withMySqlClient(root, fn) {
|
|
134
|
+
const { createConnection } = await import("mysql2/promise");
|
|
135
|
+
const connection = await createConnection({
|
|
136
|
+
uri: getMySqlUrl(root),
|
|
137
|
+
multipleStatements: true
|
|
138
|
+
});
|
|
139
|
+
const client = {
|
|
140
|
+
async query(sql, params) {
|
|
141
|
+
const [rows] = await connection.query(sql, params);
|
|
142
|
+
return Array.isArray(rows) ? rows : [];
|
|
143
|
+
},
|
|
144
|
+
async end() {
|
|
145
|
+
await connection.end();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
return await fn(client);
|
|
150
|
+
} finally {
|
|
151
|
+
await client.end();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
75
154
|
function validatePendingMigrations(migrations, appliedNames) {
|
|
76
155
|
const pending = migrations.filter((migration) => !appliedNames.has(migration.name));
|
|
77
156
|
if (pending.length === 0) return;
|
|
@@ -92,18 +171,98 @@ async function runDbCommand(root, args) {
|
|
|
92
171
|
else if (args.action === "migrate") await runMigrate(root, dialect, args.remote);
|
|
93
172
|
else if (args.action === "studio") await runStudio(root, dialect, args.remote);
|
|
94
173
|
else if (args.action === "set-url") await runSetUrl(root);
|
|
174
|
+
else if (args.action === "connect") await runConnect(root, dialect, args);
|
|
95
175
|
else if (args.action === "rename-migrations") await runRenameMigrations(root, dialect);
|
|
96
176
|
else await runExport(root, args, dialect);
|
|
97
177
|
}
|
|
178
|
+
function writeLocalDatabaseUrl(root, connectionString) {
|
|
179
|
+
const envPath = join(root, ".env");
|
|
180
|
+
const original = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
|
|
181
|
+
const lines = original ? original.replace(/\r\n/g, "\n").split("\n") : [];
|
|
182
|
+
const assignment = `DATABASE_URL=${JSON.stringify(connectionString)}`;
|
|
183
|
+
const index = lines.findIndex((line) => /^\s*(?:export\s+)?DATABASE_URL\s*=/.test(line));
|
|
184
|
+
if (index === -1) {
|
|
185
|
+
while (lines.at(-1) === "") lines.pop();
|
|
186
|
+
if (lines.length > 0) lines.push("");
|
|
187
|
+
lines.push(assignment);
|
|
188
|
+
} else {
|
|
189
|
+
lines[index] = assignment;
|
|
190
|
+
for (let i = lines.length - 1; i > index; i--) if (/^\s*(?:export\s+)?DATABASE_URL\s*=/.test(lines[i])) lines.splice(i, 1);
|
|
191
|
+
}
|
|
192
|
+
while (lines.at(-1) === "") lines.pop();
|
|
193
|
+
writeFileSync(envPath, `${lines.join("\n")}\n`);
|
|
194
|
+
}
|
|
195
|
+
function assertDatabaseProvider(value, source) {
|
|
196
|
+
if (!value || typeof value !== "object") throw new Error(`Database provider '${source}' did not export an adapter object.`);
|
|
197
|
+
const adapter = value;
|
|
198
|
+
if (typeof adapter.id !== "string" || typeof adapter.label !== "string" || !Array.isArray(adapter.dialects) || typeof adapter.provision !== "function") throw new Error(`Database provider '${source}' does not implement DatabaseProviderAdapter.`);
|
|
199
|
+
return adapter;
|
|
200
|
+
}
|
|
201
|
+
async function loadDatabaseProvider(root, provider) {
|
|
202
|
+
if (provider === "neon") {
|
|
203
|
+
const { createNeonDatabaseProvider } = await import("./neon-DHwd2zvC.mjs");
|
|
204
|
+
return createNeonDatabaseProvider();
|
|
205
|
+
}
|
|
206
|
+
const requireFromProject = createRequire(join(root, "package.json"));
|
|
207
|
+
let resolved;
|
|
208
|
+
try {
|
|
209
|
+
resolved = provider.startsWith(".") || provider.startsWith("/") ? resolve(root, provider) : requireFromProject.resolve(provider);
|
|
210
|
+
} catch {
|
|
211
|
+
throw new Error(`Could not resolve database provider adapter '${provider}' from this project. Install it first or pass a file path.`);
|
|
212
|
+
}
|
|
213
|
+
const mod = await import(pathToFileURL(resolved).href);
|
|
214
|
+
return assertDatabaseProvider(mod.default ?? mod.databaseProvider, provider);
|
|
215
|
+
}
|
|
216
|
+
async function runConnect(root, dialect, args) {
|
|
217
|
+
if (dialect === "sqlite") {
|
|
218
|
+
log.error("db: `void db connect` requires an external database. Set \"database\" to \"pg\" or \"mysql\" in void.json first.");
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
let connectionString = args.url;
|
|
222
|
+
if (args.provider) {
|
|
223
|
+
const adapter = await loadDatabaseProvider(root, args.provider);
|
|
224
|
+
if (!adapter.dialects.includes(dialect)) throw new Error(`${adapter.label} does not support the configured ${dialect} dialect.`);
|
|
225
|
+
log.info(`Provisioning ${adapter.label} database...`);
|
|
226
|
+
const result = await adapter.provision({
|
|
227
|
+
name: args.name ?? basename(root),
|
|
228
|
+
dialect,
|
|
229
|
+
region: args.region
|
|
230
|
+
});
|
|
231
|
+
connectionString = result.connectionString;
|
|
232
|
+
log.success(`Provisioned ${adapter.label} database.`);
|
|
233
|
+
if (result.dashboardUrl) log.info(`Dashboard: ${result.dashboardUrl}`);
|
|
234
|
+
}
|
|
235
|
+
if (!connectionString) {
|
|
236
|
+
const { text: promptText, isCancel: isCancelCheck } = await import("./output-tFQLLj26.mjs").then((n) => n.T);
|
|
237
|
+
const answer = await promptText({
|
|
238
|
+
message: `Enter your ${dialect === "mysql" ? "MySQL" : "PostgreSQL"} connection string:`,
|
|
239
|
+
placeholder: dialect === "mysql" ? "mysql://user:pass@host:3306/database" : "postgresql://user:pass@host:5432/database"
|
|
240
|
+
});
|
|
241
|
+
if (isCancelCheck(answer)) process.exit(0);
|
|
242
|
+
connectionString = answer;
|
|
243
|
+
}
|
|
244
|
+
const parsed = new URL(connectionString);
|
|
245
|
+
if (!(dialect === "mysql" ? ["mysql:"] : ["postgres:", "postgresql:"]).includes(parsed.protocol)) throw new Error(`Connection string protocol '${parsed.protocol}' does not match the configured ${dialect} dialect.`);
|
|
246
|
+
writeLocalDatabaseUrl(root, connectionString);
|
|
247
|
+
log.success("Saved DATABASE_URL to .env.");
|
|
248
|
+
if (!args.localOnly) {
|
|
249
|
+
const token = getToken(root);
|
|
250
|
+
const projectConfig = readProjectConfig(root);
|
|
251
|
+
if (token && projectConfig) {
|
|
252
|
+
await new PlatformClient(token, { root }).setDatabaseUrl(projectConfig.projectId, connectionString);
|
|
253
|
+
log.success("Updated the linked Void project database URL.");
|
|
254
|
+
} else log.info("No authenticated Void project is linked, so only local configuration was updated.");
|
|
255
|
+
}
|
|
256
|
+
outro("Database connected.");
|
|
257
|
+
}
|
|
98
258
|
async function runPush(root, dialect) {
|
|
99
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
259
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
100
260
|
let configPath;
|
|
101
|
-
if (dialect
|
|
261
|
+
if (dialect !== "sqlite") configPath = writeDrizzleConfig(root, dialect === "mysql" ? getMySqlUrl(root) : getPgUrl(root), dialect);
|
|
102
262
|
else {
|
|
103
263
|
const { mkdirSync } = await import("node:fs");
|
|
104
|
-
const { dirname } = await import("
|
|
105
|
-
const {
|
|
106
|
-
const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
|
|
264
|
+
const { dirname } = await import("./dist-BrsS7cai.mjs").then((n) => n.r);
|
|
265
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
107
266
|
mkdirSync(dirname(dbPath), { recursive: true });
|
|
108
267
|
configPath = writeDrizzleConfig(root, dbPath);
|
|
109
268
|
}
|
|
@@ -119,15 +278,29 @@ async function runPush(root, dialect) {
|
|
|
119
278
|
outro("Done.");
|
|
120
279
|
}
|
|
121
280
|
async function runGenerate(root, dialect) {
|
|
122
|
-
const {
|
|
123
|
-
const
|
|
281
|
+
const { prepareProject } = await import("./prepare-CBetXvsN.mjs");
|
|
282
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
283
|
+
await prepareProject(root);
|
|
284
|
+
const authSchemaPath = join(root, ".void", "better-auth-schema.ts");
|
|
285
|
+
const additionalSchemas = existsSync(authSchemaPath) ? [authSchemaPath] : void 0;
|
|
286
|
+
const configPath = writeDrizzleConfig(root, dialect === "postgresql" ? "postgresql://dummy" : dialect === "mysql" ? "mysql://dummy" : ":memory:", dialect, { additionalSchemas });
|
|
124
287
|
try {
|
|
125
|
-
|
|
288
|
+
if (dialect === "sqlite") {
|
|
289
|
+
const { generateValidatedSqliteMigrations } = await import("./generate-RTK8_kK1.mjs");
|
|
290
|
+
await generateValidatedSqliteMigrations(readProjectPaths(root).migrationsDir, () => {
|
|
291
|
+
runDrizzleKit(root, [
|
|
292
|
+
"generate",
|
|
293
|
+
"--config",
|
|
294
|
+
configPath
|
|
295
|
+
]);
|
|
296
|
+
});
|
|
297
|
+
} else runDrizzleKit(root, [
|
|
126
298
|
"generate",
|
|
127
299
|
"--config",
|
|
128
300
|
configPath
|
|
129
301
|
]);
|
|
130
|
-
} catch {
|
|
302
|
+
} catch (error) {
|
|
303
|
+
log.error(getErrorMessage(error));
|
|
131
304
|
process.exit(1);
|
|
132
305
|
}
|
|
133
306
|
outro("Done.");
|
|
@@ -159,17 +332,47 @@ async function runStatus(root, dialect) {
|
|
|
159
332
|
} catch {
|
|
160
333
|
localApplied = [];
|
|
161
334
|
}
|
|
335
|
+
else if (dialect === "mysql") try {
|
|
336
|
+
localApplied = await withMySqlClient(root, async (client) => {
|
|
337
|
+
try {
|
|
338
|
+
return await client.query("SELECT `name` FROM `_void_migrations` ORDER BY `name`");
|
|
339
|
+
} catch {
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
} catch {
|
|
344
|
+
localApplied = [];
|
|
345
|
+
}
|
|
162
346
|
else {
|
|
163
|
-
const {
|
|
164
|
-
|
|
347
|
+
const { getAppliedMigrations } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
348
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
349
|
+
localApplied = await getAppliedMigrations(dbPath);
|
|
165
350
|
}
|
|
166
351
|
const localSet = new Set(localApplied.map((m) => m.name));
|
|
167
352
|
let remoteApplied = null;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
353
|
+
if (readDeploymentPlatform(root) === "cloudflare") try {
|
|
354
|
+
if (dialect !== "sqlite") {
|
|
355
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
356
|
+
if (!databaseUrl) throw new Error("DATABASE_URL is not available.");
|
|
357
|
+
remoteApplied = (dialect === "postgresql" ? await (await import("./runner-pg-BkEza-dX.mjs").then((n) => n.n)).getPgAppliedMigrations(databaseUrl) : await (await import("./runner-mysql-7BPUNGmL.mjs").then((n) => n.n)).getMySqlAppliedMigrations(databaseUrl)).map((name) => ({
|
|
358
|
+
name,
|
|
359
|
+
applied_at: ""
|
|
360
|
+
}));
|
|
361
|
+
} else {
|
|
362
|
+
const { readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-CPTpRW6d.mjs").then((n) => n.t);
|
|
363
|
+
remoteApplied = (await readCloudflareD1Migrations(resolveCloudflareD1Context(root, resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB"))).map((name) => ({
|
|
364
|
+
name,
|
|
365
|
+
applied_at: ""
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
172
368
|
} catch {}
|
|
369
|
+
else {
|
|
370
|
+
const token = getToken(root);
|
|
371
|
+
const config = readProjectConfig(root);
|
|
372
|
+
if (token && config) try {
|
|
373
|
+
remoteApplied = (await new PlatformClient(token, { root }).getMigrationStatus(config.projectId, dialect)).applied;
|
|
374
|
+
} catch {}
|
|
375
|
+
}
|
|
173
376
|
const remoteSet = remoteApplied ? new Set(remoteApplied.map((m) => m.name)) : null;
|
|
174
377
|
const lines = [];
|
|
175
378
|
for (const migration of allMigrations) {
|
|
@@ -218,8 +421,27 @@ async function resetDatabase(root, dialect) {
|
|
|
218
421
|
});
|
|
219
422
|
return migrations.length;
|
|
220
423
|
}
|
|
221
|
-
|
|
222
|
-
|
|
424
|
+
if (dialect === "mysql") {
|
|
425
|
+
await withMySqlClient(root, async (client) => {
|
|
426
|
+
const tables = await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'");
|
|
427
|
+
await client.query("SET FOREIGN_KEY_CHECKS = 0");
|
|
428
|
+
try {
|
|
429
|
+
for (const row of tables) {
|
|
430
|
+
const table = String(row.table_name).replaceAll("`", "``");
|
|
431
|
+
await client.query(`DROP TABLE IF EXISTS \`${table}\``);
|
|
432
|
+
}
|
|
433
|
+
} finally {
|
|
434
|
+
await client.query("SET FOREIGN_KEY_CHECKS = 1");
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
if (migrations.length > 0) {
|
|
438
|
+
const { applyMySqlMigrations } = await import("./runner-mysql-7BPUNGmL.mjs").then((n) => n.n);
|
|
439
|
+
await withMySqlClient(root, (client) => applyMySqlMigrations(client, migrations));
|
|
440
|
+
}
|
|
441
|
+
return migrations.length;
|
|
442
|
+
}
|
|
443
|
+
const { runMigrations } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
444
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
223
445
|
rmSync(dbPath, { force: true });
|
|
224
446
|
rmSync(dbPath + "-wal", { force: true });
|
|
225
447
|
rmSync(dbPath + "-shm", { force: true });
|
|
@@ -228,7 +450,7 @@ async function resetDatabase(root, dialect) {
|
|
|
228
450
|
async function runReset(root, dialect) {
|
|
229
451
|
const count = await resetDatabase(root, dialect);
|
|
230
452
|
log.success(`Database reset. Applied ${count} migration(s).`);
|
|
231
|
-
if (dialect
|
|
453
|
+
if (dialect === "sqlite") log.info(dim("Restart your dev server if it's running."));
|
|
232
454
|
outro("Done.");
|
|
233
455
|
}
|
|
234
456
|
async function runSeed(root, file, dialect) {
|
|
@@ -245,8 +467,17 @@ async function runSeed(root, file, dialect) {
|
|
|
245
467
|
outro("Done.");
|
|
246
468
|
return;
|
|
247
469
|
}
|
|
248
|
-
|
|
249
|
-
|
|
470
|
+
if (dialect === "mysql") {
|
|
471
|
+
await withMySqlClient(root, async (client) => {
|
|
472
|
+
await client.query(sql);
|
|
473
|
+
});
|
|
474
|
+
log.success(`Seeded from ${seed.displayPath}.`);
|
|
475
|
+
outro("Done.");
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const { openSqliteDatabase } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
479
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
480
|
+
const db = await openSqliteDatabase(dbPath);
|
|
250
481
|
try {
|
|
251
482
|
db.exec(sql);
|
|
252
483
|
} finally {
|
|
@@ -318,6 +549,33 @@ async function fetchRemoteDatabaseUrl(client, projectId) {
|
|
|
318
549
|
throw err;
|
|
319
550
|
}
|
|
320
551
|
}
|
|
552
|
+
async function executeExternalRemoteSql(dialect, dbUrl, sql) {
|
|
553
|
+
if (dialect === "postgresql") {
|
|
554
|
+
const { Client } = await import("pg");
|
|
555
|
+
const pgClient = new Client({ connectionString: dbUrl });
|
|
556
|
+
await pgClient.connect();
|
|
557
|
+
try {
|
|
558
|
+
const result = await pgClient.query(sql);
|
|
559
|
+
if (result.rows && result.rows.length > 0) printTable(result.rows);
|
|
560
|
+
else log.success("Executed successfully.");
|
|
561
|
+
} finally {
|
|
562
|
+
await pgClient.end();
|
|
563
|
+
}
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const { createConnection } = await import("mysql2/promise");
|
|
567
|
+
const mySqlClient = await createConnection({
|
|
568
|
+
uri: dbUrl,
|
|
569
|
+
multipleStatements: true
|
|
570
|
+
});
|
|
571
|
+
try {
|
|
572
|
+
const [rows] = await mySqlClient.query(sql);
|
|
573
|
+
if (Array.isArray(rows) && rows.length > 0) printTable(rows);
|
|
574
|
+
else log.success("Executed successfully.");
|
|
575
|
+
} finally {
|
|
576
|
+
await mySqlClient.end();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
321
579
|
/**
|
|
322
580
|
* Prompt the user to confirm a destructive remote query when running in a TTY.
|
|
323
581
|
* Returns true if execution should proceed, false if it was cancelled.
|
|
@@ -331,11 +589,33 @@ async function confirmDestructiveRemote(sql) {
|
|
|
331
589
|
}
|
|
332
590
|
async function runExecute(root, command, file, dialect, remote) {
|
|
333
591
|
if (remote) {
|
|
334
|
-
|
|
592
|
+
const directCloudflare = readDeploymentPlatform(root) === "cloudflare";
|
|
593
|
+
if (dialect === "sqlite" && file && !directCloudflare) {
|
|
335
594
|
log.error("--file is not yet supported with --remote D1; pipe statements through stdin or run them one at a time.");
|
|
336
595
|
process.exit(1);
|
|
337
596
|
}
|
|
338
597
|
const sql = file ? readFileSync(join(root, file), "utf-8") : command;
|
|
598
|
+
if (directCloudflare) {
|
|
599
|
+
if (!await confirmDestructiveRemote(sql)) {
|
|
600
|
+
log.info("Cancelled.");
|
|
601
|
+
process.exit(0);
|
|
602
|
+
}
|
|
603
|
+
if (dialect === "sqlite") {
|
|
604
|
+
const { executeCloudflareD1Sql, resolveCloudflareD1Context } = await import("./cloudflare-operations-CPTpRW6d.mjs").then((n) => n.t);
|
|
605
|
+
const rows = await executeCloudflareD1Sql(resolveCloudflareD1Context(root, resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB"), sql);
|
|
606
|
+
if (rows.length > 0) printTable(rows);
|
|
607
|
+
else log.success("Executed successfully.");
|
|
608
|
+
} else {
|
|
609
|
+
const dbUrl = process.env.DATABASE_URL;
|
|
610
|
+
if (!dbUrl) {
|
|
611
|
+
log.error("DATABASE_URL is required in the shell for a direct Cloudflare remote database command.");
|
|
612
|
+
process.exit(1);
|
|
613
|
+
}
|
|
614
|
+
await executeExternalRemoteSql(dialect, dbUrl, sql);
|
|
615
|
+
}
|
|
616
|
+
outro("Done.");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
339
619
|
const token = getToken(root);
|
|
340
620
|
if (!token) {
|
|
341
621
|
log.error("Not logged in. Run `void auth login` first.");
|
|
@@ -350,34 +630,25 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
350
630
|
log.info("Cancelled.");
|
|
351
631
|
process.exit(0);
|
|
352
632
|
}
|
|
353
|
-
if (dialect
|
|
354
|
-
|
|
355
|
-
const { Client } = await import("pg");
|
|
356
|
-
const pgClient = new Client({ connectionString: dbUrl });
|
|
357
|
-
await pgClient.connect();
|
|
358
|
-
try {
|
|
359
|
-
const result = await pgClient.query(sql);
|
|
360
|
-
if (result.rows && result.rows.length > 0) printTable(result.rows);
|
|
361
|
-
else log.success("Executed successfully.");
|
|
362
|
-
} finally {
|
|
363
|
-
await pgClient.end();
|
|
364
|
-
}
|
|
633
|
+
if (dialect !== "sqlite") {
|
|
634
|
+
await executeExternalRemoteSql(dialect, await fetchRemoteDatabaseUrl(new PlatformClient(token, { root }), projectConfig.projectId), sql);
|
|
365
635
|
outro("Done.");
|
|
366
636
|
return;
|
|
367
637
|
}
|
|
368
638
|
const platformClient = new PlatformClient(token, { root });
|
|
369
|
-
|
|
639
|
+
const voidConfig = readConfig(root);
|
|
640
|
+
let binding = resolveBindingNames(voidConfig.inference?.bindings)?.d1 ?? "DB";
|
|
370
641
|
try {
|
|
371
642
|
const d1Resource = (await platformClient.getResources(projectConfig.projectId)).find((r) => r.type === "d1");
|
|
372
643
|
if (d1Resource) binding = d1Resource.binding_name;
|
|
373
644
|
} catch {}
|
|
374
|
-
const proxyUrl =
|
|
645
|
+
const proxyUrl = getProxyUrl(root);
|
|
375
646
|
const res = await fetch(`${proxyUrl}/d1/query`, {
|
|
376
647
|
method: "POST",
|
|
377
648
|
headers: {
|
|
378
649
|
Authorization: `Bearer ${token}`,
|
|
379
650
|
"Content-Type": "application/json",
|
|
380
|
-
...cfAccessHeaders(process.env)
|
|
651
|
+
...cfAccessHeaders(process.env, proxyUrl)
|
|
381
652
|
},
|
|
382
653
|
body: JSON.stringify({
|
|
383
654
|
projectId: projectConfig.projectId,
|
|
@@ -408,8 +679,18 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
408
679
|
outro("Done.");
|
|
409
680
|
return;
|
|
410
681
|
}
|
|
411
|
-
|
|
412
|
-
|
|
682
|
+
if (dialect === "mysql") {
|
|
683
|
+
const sql = file ? readFileSync(join(root, file), "utf-8") : command;
|
|
684
|
+
await withMySqlClient(root, async (client) => {
|
|
685
|
+
const rows = await client.query(sql);
|
|
686
|
+
if (rows.length > 0) printTable(rows);
|
|
687
|
+
else log.success("Executed successfully.");
|
|
688
|
+
});
|
|
689
|
+
outro("Done.");
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const { openSqliteDatabase } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
693
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
413
694
|
if (!existsSync(dbPath)) {
|
|
414
695
|
log.error("No local database found. Run `void dev` first.");
|
|
415
696
|
process.exit(1);
|
|
@@ -456,9 +737,91 @@ async function runMigrate(root, dialect, remote) {
|
|
|
456
737
|
process.exit(1);
|
|
457
738
|
}
|
|
458
739
|
if (remote) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
740
|
+
const deploymentPlatform = readDeploymentPlatform(root);
|
|
741
|
+
if (dialect !== "sqlite") {
|
|
742
|
+
if (deploymentPlatform !== "cloudflare") {
|
|
743
|
+
log.error(`db: \`void db migrate --remote\` is only supported for D1 projects. ${dialect === "mysql" ? "MySQL" : "PostgreSQL"} remote migrations run during \`void deploy\` through the project Hyperdrive binding.`);
|
|
744
|
+
process.exit(1);
|
|
745
|
+
}
|
|
746
|
+
if (rawMigrations.length === 0) {
|
|
747
|
+
log.info(`No migration files found in ${paths.sourceRelative("db/migrations")}/`);
|
|
748
|
+
outro("Done.");
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
752
|
+
if (!databaseUrl) {
|
|
753
|
+
log.error("DATABASE_URL is required in the shell for a direct Cloudflare remote database command.");
|
|
754
|
+
process.exit(1);
|
|
755
|
+
}
|
|
756
|
+
try {
|
|
757
|
+
let appliedNames;
|
|
758
|
+
let applyMigrations;
|
|
759
|
+
if (dialect === "postgresql") {
|
|
760
|
+
const { getPgAppliedMigrations, runPgMigrations } = await import("./runner-pg-BkEza-dX.mjs").then((n) => n.n);
|
|
761
|
+
appliedNames = await getPgAppliedMigrations(databaseUrl);
|
|
762
|
+
applyMigrations = () => runPgMigrations(migrationsDir, databaseUrl);
|
|
763
|
+
} else {
|
|
764
|
+
const { getMySqlAppliedMigrations, runMySqlMigrations } = await import("./runner-mysql-7BPUNGmL.mjs").then((n) => n.n);
|
|
765
|
+
appliedNames = await getMySqlAppliedMigrations(databaseUrl);
|
|
766
|
+
applyMigrations = () => runMySqlMigrations(migrationsDir, databaseUrl);
|
|
767
|
+
}
|
|
768
|
+
const appliedSet = new Set(appliedNames);
|
|
769
|
+
const pending = rawMigrations.filter((migration) => !appliedSet.has(migration.name));
|
|
770
|
+
if (pending.length === 0) {
|
|
771
|
+
log.info("Remote database is up to date.");
|
|
772
|
+
outro("Done.");
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
validateMigrations(pending);
|
|
776
|
+
const applied = await applyMigrations();
|
|
777
|
+
for (const migration of applied) log.step(migration);
|
|
778
|
+
log.success(`Applied ${applied.length} migration(s) to remote database.`);
|
|
779
|
+
outro("Done.");
|
|
780
|
+
return;
|
|
781
|
+
} catch (error) {
|
|
782
|
+
log.error(`db: Remote ${dialect} migrations failed — ${getErrorMessage(error)}`);
|
|
783
|
+
process.exit(1);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (deploymentPlatform === "cloudflare") {
|
|
787
|
+
if (rawMigrations.length === 0) {
|
|
788
|
+
log.info(`No migration files found in ${paths.sourceRelative("db/migrations")}/`);
|
|
789
|
+
outro("Done.");
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
const { applyCloudflareD1Migrations, readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-CPTpRW6d.mjs").then((n) => n.t);
|
|
793
|
+
const binding = resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB";
|
|
794
|
+
const context = resolveCloudflareD1Context(root, binding);
|
|
795
|
+
const remoteBefore = new Set(await readCloudflareD1Migrations(context));
|
|
796
|
+
const pending = rawMigrations.filter((migration) => !remoteBefore.has(migration.name));
|
|
797
|
+
if (pending.length === 0) {
|
|
798
|
+
log.info("Remote database is up to date.");
|
|
799
|
+
outro("Done.");
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
try {
|
|
803
|
+
validateMigrations(pending);
|
|
804
|
+
} catch (error) {
|
|
805
|
+
log.error(getErrorMessage(error));
|
|
806
|
+
process.exit(1);
|
|
807
|
+
}
|
|
808
|
+
const { checkWranglerMigrationApplySet, parseRootWranglerConfig } = await import("./deploy-iXZ3F0N6.mjs").then((n) => n.n);
|
|
809
|
+
const applySet = await checkWranglerMigrationApplySet(context.operation.configPath, parseRootWranglerConfig(context.operation.configPath), binding, context.migrationsDir, rawMigrations);
|
|
810
|
+
if (!applySet.ok) {
|
|
811
|
+
log.error(applySet.reason);
|
|
812
|
+
process.exit(1);
|
|
813
|
+
}
|
|
814
|
+
await applyCloudflareD1Migrations(context);
|
|
815
|
+
const remoteAfter = new Set(await readCloudflareD1Migrations(context));
|
|
816
|
+
const unapplied = rawMigrations.filter((migration) => !remoteAfter.has(migration.name));
|
|
817
|
+
if (unapplied.length > 0) {
|
|
818
|
+
log.error(`db: Remote D1 still has unapplied migrations: ${unapplied.map((migration) => migration.name).join(", ")}.`);
|
|
819
|
+
process.exit(1);
|
|
820
|
+
}
|
|
821
|
+
for (const migration of pending) log.step(migration.name);
|
|
822
|
+
log.success(`Applied ${pending.length} migration(s) to remote database.`);
|
|
823
|
+
outro("Done.");
|
|
824
|
+
return;
|
|
462
825
|
}
|
|
463
826
|
const token = getToken(root);
|
|
464
827
|
if (!token) {
|
|
@@ -511,7 +874,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
511
874
|
return;
|
|
512
875
|
}
|
|
513
876
|
if (dialect === "postgresql") {
|
|
514
|
-
const { applyPgMigrations } = await import("./runner-pg-
|
|
877
|
+
const { applyPgMigrations } = await import("./runner-pg-BkEza-dX.mjs").then((n) => n.n);
|
|
515
878
|
const applied = await withPgClient(root, async (client) => {
|
|
516
879
|
let existingRows = [];
|
|
517
880
|
try {
|
|
@@ -535,8 +898,33 @@ async function runMigrate(root, dialect, remote) {
|
|
|
535
898
|
outro("Done.");
|
|
536
899
|
return;
|
|
537
900
|
}
|
|
538
|
-
|
|
539
|
-
|
|
901
|
+
if (dialect === "mysql") {
|
|
902
|
+
const { applyMySqlMigrations } = await import("./runner-mysql-7BPUNGmL.mjs").then((n) => n.n);
|
|
903
|
+
const applied = await withMySqlClient(root, async (client) => {
|
|
904
|
+
let existingRows = [];
|
|
905
|
+
try {
|
|
906
|
+
existingRows = await client.query("SELECT `name` FROM `_void_migrations`");
|
|
907
|
+
} catch {
|
|
908
|
+
existingRows = [];
|
|
909
|
+
}
|
|
910
|
+
try {
|
|
911
|
+
validatePendingMigrations(rawMigrations, new Set(existingRows.map((row) => row.name)));
|
|
912
|
+
} catch (err) {
|
|
913
|
+
log.error(getErrorMessage(err));
|
|
914
|
+
process.exit(1);
|
|
915
|
+
}
|
|
916
|
+
return applyMySqlMigrations(client, rawMigrations);
|
|
917
|
+
});
|
|
918
|
+
if (applied.length === 0) log.info("All migrations are up to date.");
|
|
919
|
+
else {
|
|
920
|
+
for (const name of applied) log.step(name);
|
|
921
|
+
log.success(`Applied ${applied.length} migration(s).`);
|
|
922
|
+
}
|
|
923
|
+
outro("Done.");
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
const { getAppliedMigrations, runMigrations } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
927
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
540
928
|
try {
|
|
541
929
|
const existingRows = await getAppliedMigrations(dbPath);
|
|
542
930
|
validatePendingMigrations(rawMigrations, new Set(existingRows.map((row) => row.name)));
|
|
@@ -555,23 +943,32 @@ async function runMigrate(root, dialect, remote) {
|
|
|
555
943
|
}
|
|
556
944
|
async function runStudio(root, dialect, remote) {
|
|
557
945
|
if (remote) {
|
|
558
|
-
if (dialect
|
|
946
|
+
if (dialect === "sqlite") {
|
|
559
947
|
log.error("Remote D1 studio is not yet supported. Use `void db execute --remote` for ad-hoc queries against your deployed D1 database.");
|
|
560
948
|
process.exit(1);
|
|
561
949
|
}
|
|
562
|
-
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
950
|
+
let dbUrl;
|
|
951
|
+
if (readDeploymentPlatform(root) === "cloudflare") {
|
|
952
|
+
dbUrl = process.env.DATABASE_URL ?? "";
|
|
953
|
+
if (!dbUrl) {
|
|
954
|
+
log.error("DATABASE_URL is required in the shell for direct Cloudflare remote Studio.");
|
|
955
|
+
process.exit(1);
|
|
956
|
+
}
|
|
957
|
+
} else {
|
|
958
|
+
const token = getToken(root);
|
|
959
|
+
if (!token) {
|
|
960
|
+
log.error("Not logged in. Run `void auth login` first.");
|
|
961
|
+
process.exit(1);
|
|
962
|
+
}
|
|
963
|
+
const projectConfig = readProjectConfig(root);
|
|
964
|
+
if (!projectConfig) {
|
|
965
|
+
log.error("No project linked. Run `void deploy` first or link a project.");
|
|
966
|
+
process.exit(1);
|
|
967
|
+
}
|
|
968
|
+
dbUrl = await fetchRemoteDatabaseUrl(new PlatformClient(token, { root }), projectConfig.projectId);
|
|
571
969
|
}
|
|
572
|
-
const
|
|
573
|
-
const
|
|
574
|
-
const configPath = writeDrizzleConfig(root, dbUrl, "postgresql");
|
|
970
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
971
|
+
const configPath = writeDrizzleConfig(root, dbUrl, dialect);
|
|
575
972
|
log.info("Opening Drizzle Studio (remote)...");
|
|
576
973
|
try {
|
|
577
974
|
runDrizzleKit(root, [
|
|
@@ -584,9 +981,9 @@ async function runStudio(root, dialect, remote) {
|
|
|
584
981
|
}
|
|
585
982
|
return;
|
|
586
983
|
}
|
|
587
|
-
if (dialect
|
|
588
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
589
|
-
const configPath = writeDrizzleConfig(root, getPgUrl(root),
|
|
984
|
+
if (dialect !== "sqlite") {
|
|
985
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
986
|
+
const configPath = writeDrizzleConfig(root, dialect === "mysql" ? getMySqlUrl(root) : getPgUrl(root), dialect);
|
|
590
987
|
log.info("Opening Drizzle Studio...");
|
|
591
988
|
try {
|
|
592
989
|
runDrizzleKit(root, [
|
|
@@ -599,9 +996,8 @@ async function runStudio(root, dialect, remote) {
|
|
|
599
996
|
}
|
|
600
997
|
return;
|
|
601
998
|
}
|
|
602
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
603
|
-
const {
|
|
604
|
-
const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
|
|
999
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
1000
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
605
1001
|
if (!existsSync(dbPath)) {
|
|
606
1002
|
log.error("No local database found. Run `void dev` first.");
|
|
607
1003
|
process.exit(1);
|
|
@@ -678,7 +1074,8 @@ async function runRenameMigrations(root, dialect) {
|
|
|
678
1074
|
const missingSnapshots = [];
|
|
679
1075
|
for (const { from } of renames) {
|
|
680
1076
|
const fromTag = stripSqlExt(from);
|
|
681
|
-
|
|
1077
|
+
const snapshotFrom = snapshotPathFor(fromTag);
|
|
1078
|
+
if (!existsSync(snapshotFrom)) missingSnapshots.push(`meta/${snapshotPrefix(fromTag)}_snapshot.json`);
|
|
682
1079
|
}
|
|
683
1080
|
if (missingSnapshots.length > 0) {
|
|
684
1081
|
log.error("db: Cannot rename migrations because one or more Drizzle snapshot files are missing:");
|
|
@@ -819,9 +1216,25 @@ async function runRenameMigrations(root, dialect) {
|
|
|
819
1216
|
log.error(String(err));
|
|
820
1217
|
process.exit(1);
|
|
821
1218
|
}
|
|
1219
|
+
else if (dialect === "mysql") try {
|
|
1220
|
+
await withMySqlClient(root, async (client) => {
|
|
1221
|
+
if ((await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = '_void_migrations' LIMIT 1")).length === 0) return;
|
|
1222
|
+
for (const { from, to } of renames) await client.query("UPDATE `_void_migrations` SET `name` = ? WHERE `name` = ?", [to, from]);
|
|
1223
|
+
});
|
|
1224
|
+
} catch (err) {
|
|
1225
|
+
reverseSnapshotRenames();
|
|
1226
|
+
for (const { from, to } of renames) try {
|
|
1227
|
+
renameSync(join(migrationsDir, to), join(migrationsDir, from));
|
|
1228
|
+
} catch {}
|
|
1229
|
+
restoreJournal();
|
|
1230
|
+
await reverseRemote();
|
|
1231
|
+
log.error("db: Failed to update MySQL tracking table. File renames have been reverted.\nFix the database connection and run `void db rename-migrations` again.");
|
|
1232
|
+
log.error(String(err));
|
|
1233
|
+
process.exit(1);
|
|
1234
|
+
}
|
|
822
1235
|
else {
|
|
823
|
-
const {
|
|
824
|
-
const dbPath =
|
|
1236
|
+
const { openSqliteDatabase } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
1237
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
825
1238
|
if (existsSync(dbPath)) try {
|
|
826
1239
|
const db = await openSqliteDatabase(dbPath);
|
|
827
1240
|
try {
|
|
@@ -852,6 +1265,13 @@ async function runRenameMigrations(root, dialect) {
|
|
|
852
1265
|
log.success(`Renamed ${renames.length} migration(s) to timestamp format.`);
|
|
853
1266
|
outro("Done.");
|
|
854
1267
|
}
|
|
1268
|
+
function formatMySqlExportValue(value) {
|
|
1269
|
+
if (value === null || value === void 0) return "NULL";
|
|
1270
|
+
if (typeof value === "number" || typeof value === "bigint") return String(value);
|
|
1271
|
+
if (typeof value === "boolean") return value ? "1" : "0";
|
|
1272
|
+
if (value instanceof Uint8Array) return `X'${Array.from(value, (byte) => byte.toString(16).padStart(2, "0")).join("")}'`;
|
|
1273
|
+
return `'${(value instanceof Date ? value.toISOString() : String(value)).replaceAll("\\", "\\\\").replaceAll("'", "''")}'`;
|
|
1274
|
+
}
|
|
855
1275
|
async function runExport(root, args, dialect) {
|
|
856
1276
|
const errOut = { output: process.stderr };
|
|
857
1277
|
if (dialect === "postgresql") {
|
|
@@ -865,18 +1285,23 @@ async function runExport(root, args, dialect) {
|
|
|
865
1285
|
}
|
|
866
1286
|
tables = [args.table];
|
|
867
1287
|
} else tables = (await client.query("SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename NOT LIKE '\\_%' ORDER BY tablename")).rows.map((row) => String(row.tablename));
|
|
1288
|
+
const sequences = await exportPgSequences(client, tables, args);
|
|
1289
|
+
parts.push(...sequences.before);
|
|
868
1290
|
for (const table of tables) {
|
|
1291
|
+
const cols = await client.query(`SELECT column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_name = $1 AND table_schema = 'public' ORDER BY ordinal_position`, [table]);
|
|
1292
|
+
const names = cols.rows.map((column) => quoteSqlIdentifier(String(column.column_name)));
|
|
1293
|
+
const tableName = `"public".${quoteSqlIdentifier(table)}`;
|
|
869
1294
|
if (!args.noSchema) {
|
|
870
|
-
const colDefs =
|
|
871
|
-
let def = `
|
|
1295
|
+
const colDefs = cols.rows.map((column) => {
|
|
1296
|
+
let def = ` ${quoteSqlIdentifier(String(column.column_name))} ${String(column.data_type)}`;
|
|
872
1297
|
if (column.is_nullable === "NO") def += " NOT NULL";
|
|
873
1298
|
if (column.column_default) def += ` DEFAULT ${String(column.column_default)}`;
|
|
874
1299
|
return def;
|
|
875
1300
|
});
|
|
876
|
-
parts.push(`CREATE TABLE
|
|
1301
|
+
parts.push(`CREATE TABLE ${tableName} (\n${colDefs.join(",\n")}\n);`);
|
|
877
1302
|
}
|
|
878
1303
|
if (!args.noData) {
|
|
879
|
-
const rows = await client.query(`SELECT
|
|
1304
|
+
const rows = await client.query(`SELECT ${names.map((name) => `${name}::text AS ${name}`).join(", ")} FROM ${tableName}`);
|
|
880
1305
|
for (const row of rows.rows) {
|
|
881
1306
|
const cols = Object.keys(row);
|
|
882
1307
|
const vals = cols.map((column) => {
|
|
@@ -885,11 +1310,13 @@ async function runExport(root, args, dialect) {
|
|
|
885
1310
|
if (typeof value === "number") return String(value);
|
|
886
1311
|
return `'${String(value).replace(/'/g, "''")}'`;
|
|
887
1312
|
});
|
|
888
|
-
parts.push(`INSERT INTO
|
|
1313
|
+
parts.push(`INSERT INTO ${tableName} (${cols.map(quoteSqlIdentifier).join(", ")}) VALUES (${vals.join(", ")});`);
|
|
889
1314
|
}
|
|
890
1315
|
}
|
|
891
1316
|
parts.push("");
|
|
892
1317
|
}
|
|
1318
|
+
parts.push(...sequences.after);
|
|
1319
|
+
if (!args.noSchema) parts.push(...await exportPgConstraints(client, tables));
|
|
893
1320
|
});
|
|
894
1321
|
const output = parts.join("\n");
|
|
895
1322
|
if (args.output) {
|
|
@@ -899,8 +1326,45 @@ async function runExport(root, args, dialect) {
|
|
|
899
1326
|
} else process.stdout.write(output);
|
|
900
1327
|
return;
|
|
901
1328
|
}
|
|
902
|
-
|
|
903
|
-
|
|
1329
|
+
if (dialect === "mysql") {
|
|
1330
|
+
const parts = [];
|
|
1331
|
+
await withMySqlClient(root, async (client) => {
|
|
1332
|
+
let tables;
|
|
1333
|
+
if (args.table) {
|
|
1334
|
+
if ((await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ?", [args.table])).length === 0) {
|
|
1335
|
+
log.error(`db: Table '${args.table}' not found.`, errOut);
|
|
1336
|
+
process.exit(1);
|
|
1337
|
+
}
|
|
1338
|
+
tables = [args.table];
|
|
1339
|
+
} else tables = (await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE' AND table_name NOT LIKE '\\_%' ORDER BY table_name")).map((row) => String(row.table_name));
|
|
1340
|
+
for (const table of tables) {
|
|
1341
|
+
const escapedTable = table.replaceAll("`", "``");
|
|
1342
|
+
if (!args.noSchema) {
|
|
1343
|
+
const createSql = (await client.query(`SHOW CREATE TABLE \`${escapedTable}\``))[0]?.["Create Table"];
|
|
1344
|
+
if (createSql) parts.push(`${String(createSql)};`);
|
|
1345
|
+
}
|
|
1346
|
+
if (!args.noData) {
|
|
1347
|
+
const rows = await client.query(`SELECT * FROM \`${escapedTable}\``);
|
|
1348
|
+
for (const row of rows) {
|
|
1349
|
+
const columns = Object.keys(row);
|
|
1350
|
+
const values = columns.map((column) => formatMySqlExportValue(row[column]));
|
|
1351
|
+
const names = columns.map((column) => `\`${column.replaceAll("`", "``")}\``);
|
|
1352
|
+
parts.push(`INSERT INTO \`${escapedTable}\` (${names.join(", ")}) VALUES (${values.join(", ")});`);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
parts.push("");
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
const output = parts.join("\n");
|
|
1359
|
+
if (args.output) {
|
|
1360
|
+
writeFileSync(join(root, args.output), output);
|
|
1361
|
+
log.success(`Exported to ${args.output}`);
|
|
1362
|
+
outro("Done.");
|
|
1363
|
+
} else process.stdout.write(output);
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
const { openSqliteDatabase } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
1367
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
904
1368
|
if (!existsSync(dbPath)) {
|
|
905
1369
|
log.error("No local database found. Run `void dev` first.", errOut);
|
|
906
1370
|
process.exit(1);
|
|
@@ -914,7 +1378,7 @@ async function runExport(root, args, dialect) {
|
|
|
914
1378
|
process.exit(1);
|
|
915
1379
|
}
|
|
916
1380
|
tables = [args.table];
|
|
917
|
-
} else tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '\\_%' ESCAPE '\\' ORDER BY name").all().map((row) => String(row.name));
|
|
1381
|
+
} else tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '\\_%' ESCAPE '\\' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !name.startsWith("sqlite_"));
|
|
918
1382
|
const parts = [];
|
|
919
1383
|
for (const table of tables) {
|
|
920
1384
|
if (!args.noSchema) {
|
|
@@ -922,7 +1386,7 @@ async function runExport(root, args, dialect) {
|
|
|
922
1386
|
parts.push(row.sql + ";");
|
|
923
1387
|
}
|
|
924
1388
|
if (!args.noData) {
|
|
925
|
-
const rows = db.prepare(`SELECT * FROM
|
|
1389
|
+
const rows = db.prepare(`SELECT * FROM ${quoteSqlIdentifier(table)}`).all();
|
|
926
1390
|
for (const row of rows) {
|
|
927
1391
|
const cols = Object.keys(row);
|
|
928
1392
|
const vals = cols.map((column) => {
|
|
@@ -931,11 +1395,19 @@ async function runExport(root, args, dialect) {
|
|
|
931
1395
|
if (typeof value === "number") return String(value);
|
|
932
1396
|
return `'${String(value).replace(/'/g, "''")}'`;
|
|
933
1397
|
});
|
|
934
|
-
parts.push(`INSERT INTO
|
|
1398
|
+
parts.push(`INSERT INTO ${quoteSqlIdentifier(table)} (${cols.map(quoteSqlIdentifier).join(", ")}) VALUES (${vals.join(", ")});`);
|
|
935
1399
|
}
|
|
936
1400
|
}
|
|
937
1401
|
parts.push("");
|
|
938
1402
|
}
|
|
1403
|
+
if (!args.noData && db.prepare("SELECT name FROM sqlite_master WHERE name='sqlite_sequence'").get()) {
|
|
1404
|
+
const sequences = db.prepare("SELECT name, seq FROM sqlite_sequence").all();
|
|
1405
|
+
for (const sequence of sequences) if (tables.includes(sequence.name)) {
|
|
1406
|
+
const name = quoteSqlString(sequence.name);
|
|
1407
|
+
parts.push(`DELETE FROM sqlite_sequence WHERE name = ${name};`);
|
|
1408
|
+
parts.push(`INSERT INTO sqlite_sequence (name, seq) VALUES (${name}, ${sequence.seq});`);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
939
1411
|
const output = parts.join("\n");
|
|
940
1412
|
if (args.output) {
|
|
941
1413
|
writeFileSync(join(root, args.output), output);
|
|
@@ -947,9 +1419,10 @@ async function runExport(root, args, dialect) {
|
|
|
947
1419
|
}
|
|
948
1420
|
}
|
|
949
1421
|
async function runSetUrl(root) {
|
|
950
|
-
const { readConfig: readVoidConfig, getDatabaseDialect: getDialect } = await import("./config-
|
|
951
|
-
|
|
952
|
-
|
|
1422
|
+
const { readConfig: readVoidConfig, getDatabaseDialect: getDialect } = await import("./config-BQFq7QvD.mjs").then((n) => n.n);
|
|
1423
|
+
const dialect = getDialect(readVoidConfig(root));
|
|
1424
|
+
if (dialect === "sqlite") {
|
|
1425
|
+
log.error("db: This command is only for PostgreSQL and MySQL projects. Set \"database\" to \"pg\" or \"mysql\" in void.json.");
|
|
953
1426
|
process.exit(1);
|
|
954
1427
|
}
|
|
955
1428
|
const token = getToken(root);
|
|
@@ -962,12 +1435,14 @@ async function runSetUrl(root) {
|
|
|
962
1435
|
log.error("No project linked. Run `void deploy` first or link a project.");
|
|
963
1436
|
process.exit(1);
|
|
964
1437
|
}
|
|
965
|
-
const { text: promptText, isCancel: isCancelCheck } = await import("./
|
|
1438
|
+
const { text: promptText, isCancel: isCancelCheck } = await import("./output-tFQLLj26.mjs").then((n) => n.T);
|
|
966
1439
|
const connectionString = await promptText({
|
|
967
|
-
message:
|
|
968
|
-
placeholder: "postgresql://user:pass@host:5432/dbname",
|
|
1440
|
+
message: `Enter your ${dialect === "mysql" ? "MySQL" : "PostgreSQL"} connection string:`,
|
|
1441
|
+
placeholder: dialect === "mysql" ? "mysql://user:pass@host:3306/dbname" : "postgresql://user:pass@host:5432/dbname",
|
|
969
1442
|
validate(value = "") {
|
|
970
|
-
if (
|
|
1443
|
+
if (dialect === "mysql") {
|
|
1444
|
+
if (!value.startsWith("mysql://")) return "Connection string must start with \"mysql://\"";
|
|
1445
|
+
} else if (!value.startsWith("postgres://") && !value.startsWith("postgresql://")) return "Connection string must start with \"postgres://\" or \"postgresql://\"";
|
|
971
1446
|
}
|
|
972
1447
|
});
|
|
973
1448
|
if (isCancelCheck(connectionString)) process.exit(0);
|
|
@@ -1027,9 +1502,29 @@ async function runSeedModule(root, seedPath, dialect) {
|
|
|
1027
1502
|
});
|
|
1028
1503
|
return;
|
|
1029
1504
|
}
|
|
1505
|
+
if (dialect === "mysql") {
|
|
1506
|
+
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
1507
|
+
const { createConnection } = await import("mysql2/promise");
|
|
1508
|
+
const connection = await createConnection(getMySqlUrl(root));
|
|
1509
|
+
try {
|
|
1510
|
+
const options = getDrizzleSchemaOptions(schema);
|
|
1511
|
+
await seed({
|
|
1512
|
+
dialect,
|
|
1513
|
+
db: options ? drizzle(connection, {
|
|
1514
|
+
...options,
|
|
1515
|
+
mode: "default"
|
|
1516
|
+
}) : drizzle(connection),
|
|
1517
|
+
schema
|
|
1518
|
+
});
|
|
1519
|
+
} finally {
|
|
1520
|
+
await connection.end();
|
|
1521
|
+
}
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1030
1524
|
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
|
1031
|
-
const {
|
|
1032
|
-
const
|
|
1525
|
+
const { openSqliteDatabase } = await import("./local-d1-D2I6Ox5F.mjs").then((n) => n.i);
|
|
1526
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
1527
|
+
const sqlite = await openSqliteDatabase(dbPath);
|
|
1033
1528
|
try {
|
|
1034
1529
|
const options = getDrizzleSchemaOptions(schema);
|
|
1035
1530
|
await seed({
|
|
@@ -1048,7 +1543,7 @@ async function loadSeedFunction(seedPath) {
|
|
|
1048
1543
|
return seed;
|
|
1049
1544
|
}
|
|
1050
1545
|
async function loadSeedSchema(root) {
|
|
1051
|
-
const { discoverSchema } = await import("./discover-
|
|
1546
|
+
const { discoverSchema } = await import("./discover-xvfrgJeo.mjs").then((n) => n.n);
|
|
1052
1547
|
const location = discoverSchema(root, readProjectPaths(root));
|
|
1053
1548
|
if (!location) return {};
|
|
1054
1549
|
if (location.type === "file") {
|