void 0.10.12 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-CYVhSNFy.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-CkVD1uOh.mjs} +6 -4
- package/dist/{cache-C11V8Fxq.mjs → cache-QcUfR-ff.mjs} +9 -5
- package/dist/{cancel-deploy-fwFYF04b.mjs → cancel-deploy-DsvWKFTe.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 +1592 -153
- 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-CyCHWSO_.mjs} +61 -463
- package/dist/cloudflare-auth-DRkGe7-s.mjs +170 -0
- package/dist/cloudflare-cmd-D3ME2GAe.mjs +62 -0
- package/dist/cloudflare-connect-BivMefMA.mjs +56 -0
- package/dist/cloudflare-operations-CPTpRW6d.mjs +566 -0
- package/dist/{config-BkTvs43g.mjs → config-BQFq7QvD.mjs} +85 -41
- package/dist/{config-CutEMNGJ.mjs → config-NOG_U1aK.mjs} +10 -15
- package/dist/connect-D9Yr-T5f.mjs +79 -0
- package/dist/{create-project-DsYvl3TB.mjs → create-project-DMV-csEm.mjs} +26 -16
- package/dist/database-provider.d.mts +21 -0
- package/dist/database-provider.mjs +6 -0
- package/dist/{db-DOiJMRt2.mjs → db-BxoUWL0F.mjs} +600 -115
- package/dist/{delete-mh6p-zkQ.mjs → delete-iJOqxBz1.mjs} +9 -6
- package/dist/{deploy-u7Rv9q_q.mjs → deploy-CcDoeBIf.mjs} +3451 -1986
- 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-gu_iaHmn.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-r6DHJyAB.mjs +262 -0
- package/dist/{entry-D7yy4xVH.mjs → entry-DU3oDoQ3.mjs} +2 -2
- package/dist/env-D4Emu-M_.mjs +95 -0
- package/dist/env-DmU2To0C.mjs +73 -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-o_w-8yI8.mjs → gen-BKw6qHIg.mjs} +70 -15
- package/dist/{github-cmd-DKcGUNsj.mjs → github-cmd-DJS5Ab-H.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-nsHIFixA.mjs → headers-D8QfRX9Y.mjs} +12 -10
- package/dist/inbound-BJ70in1n.d.mts +354 -0
- package/dist/inbound-CNKxb3FY.mjs +694 -0
- package/dist/index.d.mts +61 -34
- package/dist/index.mjs +1048 -321
- package/dist/{init-3rgHKBVi.mjs → init-Dx5cgKqK.mjs} +329 -271
- package/dist/link-D_rm5sRH.mjs +52 -0
- package/dist/{list-CPwFDZ_c.mjs → list-M8XShti7.mjs} +37 -5
- package/dist/{runner-kapo9aPs.mjs → local-d1-BE8KBbMy.mjs} +116 -6
- package/dist/{login-BT3H8PN3.mjs → login-C8-UuLnp.mjs} +17 -15
- package/dist/{logs-Bt313ax7.mjs → logs-DwFU7dMW.mjs} +16 -2
- package/dist/mime-BJD7d_qL.mjs +1216 -0
- package/dist/neon-DHwd2zvC.mjs +54 -0
- package/dist/{node-Da0UcsGA.mjs → node-BkaXcpAc.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-BEOVv1PN.mjs +123 -0
- package/dist/platform-domain-BszUfiS8.mjs +228 -0
- package/dist/platform-lifecycle-CjSr6xf0.mjs +4450 -0
- package/dist/platform-management-W30iCaTL.mjs +698 -0
- package/dist/platform-recovery-pHHv4ZSg.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-BoKHgMNx.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-DCpk1cDt.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-rShh6MKY.mjs → provision-Blnstcm2.mjs} +78 -45
- package/dist/r2-conditions-D1Wk8i7b.mjs +30 -0
- package/dist/{requests-B8sZxaFM.mjs → requests-Dn8Vheh1.mjs} +5 -3
- package/dist/{resolve-project-BBMtLLV9.mjs → resolve-project--Vxawf7z.mjs} +2 -2
- package/dist/rollback-CtlPXEBi.mjs +166 -0
- package/dist/{rolldown-runtime-DJK8HYOj.mjs → rolldown-runtime-rQ84J-ij.mjs} +1 -1
- package/dist/{route-types-COI2DsZv.mjs → route-types-Da-DpyUp.mjs} +85 -26
- package/dist/routes-stub.d.mts +22 -23
- package/dist/runner-mysql-CgRFl3s6.mjs +61 -0
- package/dist/{runner-pg-CHM76xuC.mjs → runner-pg-DCkWPsWS.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-DYXkrasO.mjs → scan-BMH4rzlv.mjs} +53 -31
- package/dist/{scan-DEwlM_Xy.mjs → scan-CpK-57ug.mjs} +9 -5
- package/dist/{secret-Dt32J6RI.mjs → secret-BqTxGqki.mjs} +62 -5
- package/dist/{skills-CLjN0uUO.mjs → skills-Q46GZMO-.mjs} +6 -4
- 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-Bihr8WBi.mjs} +3 -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 +35 -3
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +1 -1
- 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 +163 -22
- 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 +23 -8
- package/skills/void/docs/guide/email.md +609 -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 +235 -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 +25 -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 +18 -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 +637 -159
- package/skills/void/docs/reference/config.md +80 -25
- package/skills/void/docs/reference/resource-inference.md +13 -9
- package/skills/void/docs/reference/structure.md +10 -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 -219
- 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-Bihr8WBi.mjs";
|
|
9
|
+
import { t as resolveLocalD1Target } from "./local-d1-BE8KBbMy.mjs";
|
|
10
|
+
import { a as loadLocalEnv } from "./env-D4Emu-M_.mjs";
|
|
11
|
+
import { n as PlatformClient, t as PlatformApiError } from "./client-CyCHWSO_.mjs";
|
|
12
|
+
import { formatTimestamp } from "./gen-BKw6qHIg.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,8 +278,12 @@ 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
|
runDrizzleKit(root, [
|
|
126
289
|
"generate",
|
|
@@ -159,17 +322,47 @@ async function runStatus(root, dialect) {
|
|
|
159
322
|
} catch {
|
|
160
323
|
localApplied = [];
|
|
161
324
|
}
|
|
325
|
+
else if (dialect === "mysql") try {
|
|
326
|
+
localApplied = await withMySqlClient(root, async (client) => {
|
|
327
|
+
try {
|
|
328
|
+
return await client.query("SELECT `name` FROM `_void_migrations` ORDER BY `name`");
|
|
329
|
+
} catch {
|
|
330
|
+
return [];
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
} catch {
|
|
334
|
+
localApplied = [];
|
|
335
|
+
}
|
|
162
336
|
else {
|
|
163
|
-
const {
|
|
164
|
-
|
|
337
|
+
const { getAppliedMigrations } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
338
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
339
|
+
localApplied = await getAppliedMigrations(dbPath);
|
|
165
340
|
}
|
|
166
341
|
const localSet = new Set(localApplied.map((m) => m.name));
|
|
167
342
|
let remoteApplied = null;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
343
|
+
if (readDeploymentPlatform(root) === "cloudflare") try {
|
|
344
|
+
if (dialect !== "sqlite") {
|
|
345
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
346
|
+
if (!databaseUrl) throw new Error("DATABASE_URL is not available.");
|
|
347
|
+
remoteApplied = (dialect === "postgresql" ? await (await import("./runner-pg-DCkWPsWS.mjs").then((n) => n.n)).getPgAppliedMigrations(databaseUrl) : await (await import("./runner-mysql-CgRFl3s6.mjs").then((n) => n.n)).getMySqlAppliedMigrations(databaseUrl)).map((name) => ({
|
|
348
|
+
name,
|
|
349
|
+
applied_at: ""
|
|
350
|
+
}));
|
|
351
|
+
} else {
|
|
352
|
+
const { readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-CPTpRW6d.mjs").then((n) => n.t);
|
|
353
|
+
remoteApplied = (await readCloudflareD1Migrations(resolveCloudflareD1Context(root, resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB"))).map((name) => ({
|
|
354
|
+
name,
|
|
355
|
+
applied_at: ""
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
172
358
|
} catch {}
|
|
359
|
+
else {
|
|
360
|
+
const token = getToken(root);
|
|
361
|
+
const config = readProjectConfig(root);
|
|
362
|
+
if (token && config) try {
|
|
363
|
+
remoteApplied = (await new PlatformClient(token, { root }).getMigrationStatus(config.projectId, dialect)).applied;
|
|
364
|
+
} catch {}
|
|
365
|
+
}
|
|
173
366
|
const remoteSet = remoteApplied ? new Set(remoteApplied.map((m) => m.name)) : null;
|
|
174
367
|
const lines = [];
|
|
175
368
|
for (const migration of allMigrations) {
|
|
@@ -218,8 +411,27 @@ async function resetDatabase(root, dialect) {
|
|
|
218
411
|
});
|
|
219
412
|
return migrations.length;
|
|
220
413
|
}
|
|
221
|
-
|
|
222
|
-
|
|
414
|
+
if (dialect === "mysql") {
|
|
415
|
+
await withMySqlClient(root, async (client) => {
|
|
416
|
+
const tables = await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'");
|
|
417
|
+
await client.query("SET FOREIGN_KEY_CHECKS = 0");
|
|
418
|
+
try {
|
|
419
|
+
for (const row of tables) {
|
|
420
|
+
const table = String(row.table_name).replaceAll("`", "``");
|
|
421
|
+
await client.query(`DROP TABLE IF EXISTS \`${table}\``);
|
|
422
|
+
}
|
|
423
|
+
} finally {
|
|
424
|
+
await client.query("SET FOREIGN_KEY_CHECKS = 1");
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
if (migrations.length > 0) {
|
|
428
|
+
const { applyMySqlMigrations } = await import("./runner-mysql-CgRFl3s6.mjs").then((n) => n.n);
|
|
429
|
+
await withMySqlClient(root, (client) => applyMySqlMigrations(client, migrations));
|
|
430
|
+
}
|
|
431
|
+
return migrations.length;
|
|
432
|
+
}
|
|
433
|
+
const { runMigrations } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
434
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
223
435
|
rmSync(dbPath, { force: true });
|
|
224
436
|
rmSync(dbPath + "-wal", { force: true });
|
|
225
437
|
rmSync(dbPath + "-shm", { force: true });
|
|
@@ -228,7 +440,7 @@ async function resetDatabase(root, dialect) {
|
|
|
228
440
|
async function runReset(root, dialect) {
|
|
229
441
|
const count = await resetDatabase(root, dialect);
|
|
230
442
|
log.success(`Database reset. Applied ${count} migration(s).`);
|
|
231
|
-
if (dialect
|
|
443
|
+
if (dialect === "sqlite") log.info(dim("Restart your dev server if it's running."));
|
|
232
444
|
outro("Done.");
|
|
233
445
|
}
|
|
234
446
|
async function runSeed(root, file, dialect) {
|
|
@@ -245,8 +457,17 @@ async function runSeed(root, file, dialect) {
|
|
|
245
457
|
outro("Done.");
|
|
246
458
|
return;
|
|
247
459
|
}
|
|
248
|
-
|
|
249
|
-
|
|
460
|
+
if (dialect === "mysql") {
|
|
461
|
+
await withMySqlClient(root, async (client) => {
|
|
462
|
+
await client.query(sql);
|
|
463
|
+
});
|
|
464
|
+
log.success(`Seeded from ${seed.displayPath}.`);
|
|
465
|
+
outro("Done.");
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const { openSqliteDatabase } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
469
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
470
|
+
const db = await openSqliteDatabase(dbPath);
|
|
250
471
|
try {
|
|
251
472
|
db.exec(sql);
|
|
252
473
|
} finally {
|
|
@@ -318,6 +539,33 @@ async function fetchRemoteDatabaseUrl(client, projectId) {
|
|
|
318
539
|
throw err;
|
|
319
540
|
}
|
|
320
541
|
}
|
|
542
|
+
async function executeExternalRemoteSql(dialect, dbUrl, sql) {
|
|
543
|
+
if (dialect === "postgresql") {
|
|
544
|
+
const { Client } = await import("pg");
|
|
545
|
+
const pgClient = new Client({ connectionString: dbUrl });
|
|
546
|
+
await pgClient.connect();
|
|
547
|
+
try {
|
|
548
|
+
const result = await pgClient.query(sql);
|
|
549
|
+
if (result.rows && result.rows.length > 0) printTable(result.rows);
|
|
550
|
+
else log.success("Executed successfully.");
|
|
551
|
+
} finally {
|
|
552
|
+
await pgClient.end();
|
|
553
|
+
}
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const { createConnection } = await import("mysql2/promise");
|
|
557
|
+
const mySqlClient = await createConnection({
|
|
558
|
+
uri: dbUrl,
|
|
559
|
+
multipleStatements: true
|
|
560
|
+
});
|
|
561
|
+
try {
|
|
562
|
+
const [rows] = await mySqlClient.query(sql);
|
|
563
|
+
if (Array.isArray(rows) && rows.length > 0) printTable(rows);
|
|
564
|
+
else log.success("Executed successfully.");
|
|
565
|
+
} finally {
|
|
566
|
+
await mySqlClient.end();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
321
569
|
/**
|
|
322
570
|
* Prompt the user to confirm a destructive remote query when running in a TTY.
|
|
323
571
|
* Returns true if execution should proceed, false if it was cancelled.
|
|
@@ -331,11 +579,33 @@ async function confirmDestructiveRemote(sql) {
|
|
|
331
579
|
}
|
|
332
580
|
async function runExecute(root, command, file, dialect, remote) {
|
|
333
581
|
if (remote) {
|
|
334
|
-
|
|
582
|
+
const directCloudflare = readDeploymentPlatform(root) === "cloudflare";
|
|
583
|
+
if (dialect === "sqlite" && file && !directCloudflare) {
|
|
335
584
|
log.error("--file is not yet supported with --remote D1; pipe statements through stdin or run them one at a time.");
|
|
336
585
|
process.exit(1);
|
|
337
586
|
}
|
|
338
587
|
const sql = file ? readFileSync(join(root, file), "utf-8") : command;
|
|
588
|
+
if (directCloudflare) {
|
|
589
|
+
if (!await confirmDestructiveRemote(sql)) {
|
|
590
|
+
log.info("Cancelled.");
|
|
591
|
+
process.exit(0);
|
|
592
|
+
}
|
|
593
|
+
if (dialect === "sqlite") {
|
|
594
|
+
const { executeCloudflareD1Sql, resolveCloudflareD1Context } = await import("./cloudflare-operations-CPTpRW6d.mjs").then((n) => n.t);
|
|
595
|
+
const rows = await executeCloudflareD1Sql(resolveCloudflareD1Context(root, resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB"), sql);
|
|
596
|
+
if (rows.length > 0) printTable(rows);
|
|
597
|
+
else log.success("Executed successfully.");
|
|
598
|
+
} else {
|
|
599
|
+
const dbUrl = process.env.DATABASE_URL;
|
|
600
|
+
if (!dbUrl) {
|
|
601
|
+
log.error("DATABASE_URL is required in the shell for a direct Cloudflare remote database command.");
|
|
602
|
+
process.exit(1);
|
|
603
|
+
}
|
|
604
|
+
await executeExternalRemoteSql(dialect, dbUrl, sql);
|
|
605
|
+
}
|
|
606
|
+
outro("Done.");
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
339
609
|
const token = getToken(root);
|
|
340
610
|
if (!token) {
|
|
341
611
|
log.error("Not logged in. Run `void auth login` first.");
|
|
@@ -350,34 +620,25 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
350
620
|
log.info("Cancelled.");
|
|
351
621
|
process.exit(0);
|
|
352
622
|
}
|
|
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
|
-
}
|
|
623
|
+
if (dialect !== "sqlite") {
|
|
624
|
+
await executeExternalRemoteSql(dialect, await fetchRemoteDatabaseUrl(new PlatformClient(token, { root }), projectConfig.projectId), sql);
|
|
365
625
|
outro("Done.");
|
|
366
626
|
return;
|
|
367
627
|
}
|
|
368
628
|
const platformClient = new PlatformClient(token, { root });
|
|
369
|
-
|
|
629
|
+
const voidConfig = readConfig(root);
|
|
630
|
+
let binding = resolveBindingNames(voidConfig.inference?.bindings)?.d1 ?? "DB";
|
|
370
631
|
try {
|
|
371
632
|
const d1Resource = (await platformClient.getResources(projectConfig.projectId)).find((r) => r.type === "d1");
|
|
372
633
|
if (d1Resource) binding = d1Resource.binding_name;
|
|
373
634
|
} catch {}
|
|
374
|
-
const proxyUrl =
|
|
635
|
+
const proxyUrl = getProxyUrl(root);
|
|
375
636
|
const res = await fetch(`${proxyUrl}/d1/query`, {
|
|
376
637
|
method: "POST",
|
|
377
638
|
headers: {
|
|
378
639
|
Authorization: `Bearer ${token}`,
|
|
379
640
|
"Content-Type": "application/json",
|
|
380
|
-
...cfAccessHeaders(process.env)
|
|
641
|
+
...cfAccessHeaders(process.env, proxyUrl)
|
|
381
642
|
},
|
|
382
643
|
body: JSON.stringify({
|
|
383
644
|
projectId: projectConfig.projectId,
|
|
@@ -408,8 +669,18 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
408
669
|
outro("Done.");
|
|
409
670
|
return;
|
|
410
671
|
}
|
|
411
|
-
|
|
412
|
-
|
|
672
|
+
if (dialect === "mysql") {
|
|
673
|
+
const sql = file ? readFileSync(join(root, file), "utf-8") : command;
|
|
674
|
+
await withMySqlClient(root, async (client) => {
|
|
675
|
+
const rows = await client.query(sql);
|
|
676
|
+
if (rows.length > 0) printTable(rows);
|
|
677
|
+
else log.success("Executed successfully.");
|
|
678
|
+
});
|
|
679
|
+
outro("Done.");
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const { openSqliteDatabase } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
683
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
413
684
|
if (!existsSync(dbPath)) {
|
|
414
685
|
log.error("No local database found. Run `void dev` first.");
|
|
415
686
|
process.exit(1);
|
|
@@ -456,9 +727,91 @@ async function runMigrate(root, dialect, remote) {
|
|
|
456
727
|
process.exit(1);
|
|
457
728
|
}
|
|
458
729
|
if (remote) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
730
|
+
const deploymentPlatform = readDeploymentPlatform(root);
|
|
731
|
+
if (dialect !== "sqlite") {
|
|
732
|
+
if (deploymentPlatform !== "cloudflare") {
|
|
733
|
+
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.`);
|
|
734
|
+
process.exit(1);
|
|
735
|
+
}
|
|
736
|
+
if (rawMigrations.length === 0) {
|
|
737
|
+
log.info(`No migration files found in ${paths.sourceRelative("db/migrations")}/`);
|
|
738
|
+
outro("Done.");
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
742
|
+
if (!databaseUrl) {
|
|
743
|
+
log.error("DATABASE_URL is required in the shell for a direct Cloudflare remote database command.");
|
|
744
|
+
process.exit(1);
|
|
745
|
+
}
|
|
746
|
+
try {
|
|
747
|
+
let appliedNames;
|
|
748
|
+
let applyMigrations;
|
|
749
|
+
if (dialect === "postgresql") {
|
|
750
|
+
const { getPgAppliedMigrations, runPgMigrations } = await import("./runner-pg-DCkWPsWS.mjs").then((n) => n.n);
|
|
751
|
+
appliedNames = await getPgAppliedMigrations(databaseUrl);
|
|
752
|
+
applyMigrations = () => runPgMigrations(migrationsDir, databaseUrl);
|
|
753
|
+
} else {
|
|
754
|
+
const { getMySqlAppliedMigrations, runMySqlMigrations } = await import("./runner-mysql-CgRFl3s6.mjs").then((n) => n.n);
|
|
755
|
+
appliedNames = await getMySqlAppliedMigrations(databaseUrl);
|
|
756
|
+
applyMigrations = () => runMySqlMigrations(migrationsDir, databaseUrl);
|
|
757
|
+
}
|
|
758
|
+
const appliedSet = new Set(appliedNames);
|
|
759
|
+
const pending = rawMigrations.filter((migration) => !appliedSet.has(migration.name));
|
|
760
|
+
if (pending.length === 0) {
|
|
761
|
+
log.info("Remote database is up to date.");
|
|
762
|
+
outro("Done.");
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
validateMigrations(pending);
|
|
766
|
+
const applied = await applyMigrations();
|
|
767
|
+
for (const migration of applied) log.step(migration);
|
|
768
|
+
log.success(`Applied ${applied.length} migration(s) to remote database.`);
|
|
769
|
+
outro("Done.");
|
|
770
|
+
return;
|
|
771
|
+
} catch (error) {
|
|
772
|
+
log.error(`db: Remote ${dialect} migrations failed — ${getErrorMessage(error)}`);
|
|
773
|
+
process.exit(1);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (deploymentPlatform === "cloudflare") {
|
|
777
|
+
if (rawMigrations.length === 0) {
|
|
778
|
+
log.info(`No migration files found in ${paths.sourceRelative("db/migrations")}/`);
|
|
779
|
+
outro("Done.");
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
const { applyCloudflareD1Migrations, readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-CPTpRW6d.mjs").then((n) => n.t);
|
|
783
|
+
const binding = resolveBindingNames(readConfig(root).inference?.bindings)?.d1 ?? "DB";
|
|
784
|
+
const context = resolveCloudflareD1Context(root, binding);
|
|
785
|
+
const remoteBefore = new Set(await readCloudflareD1Migrations(context));
|
|
786
|
+
const pending = rawMigrations.filter((migration) => !remoteBefore.has(migration.name));
|
|
787
|
+
if (pending.length === 0) {
|
|
788
|
+
log.info("Remote database is up to date.");
|
|
789
|
+
outro("Done.");
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
try {
|
|
793
|
+
validateMigrations(pending);
|
|
794
|
+
} catch (error) {
|
|
795
|
+
log.error(getErrorMessage(error));
|
|
796
|
+
process.exit(1);
|
|
797
|
+
}
|
|
798
|
+
const { checkWranglerMigrationApplySet, parseRootWranglerConfig } = await import("./deploy-CcDoeBIf.mjs").then((n) => n.n);
|
|
799
|
+
const applySet = await checkWranglerMigrationApplySet(context.operation.configPath, parseRootWranglerConfig(context.operation.configPath), binding, context.migrationsDir, rawMigrations);
|
|
800
|
+
if (!applySet.ok) {
|
|
801
|
+
log.error(applySet.reason);
|
|
802
|
+
process.exit(1);
|
|
803
|
+
}
|
|
804
|
+
await applyCloudflareD1Migrations(context);
|
|
805
|
+
const remoteAfter = new Set(await readCloudflareD1Migrations(context));
|
|
806
|
+
const unapplied = rawMigrations.filter((migration) => !remoteAfter.has(migration.name));
|
|
807
|
+
if (unapplied.length > 0) {
|
|
808
|
+
log.error(`db: Remote D1 still has unapplied migrations: ${unapplied.map((migration) => migration.name).join(", ")}.`);
|
|
809
|
+
process.exit(1);
|
|
810
|
+
}
|
|
811
|
+
for (const migration of pending) log.step(migration.name);
|
|
812
|
+
log.success(`Applied ${pending.length} migration(s) to remote database.`);
|
|
813
|
+
outro("Done.");
|
|
814
|
+
return;
|
|
462
815
|
}
|
|
463
816
|
const token = getToken(root);
|
|
464
817
|
if (!token) {
|
|
@@ -511,7 +864,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
511
864
|
return;
|
|
512
865
|
}
|
|
513
866
|
if (dialect === "postgresql") {
|
|
514
|
-
const { applyPgMigrations } = await import("./runner-pg-
|
|
867
|
+
const { applyPgMigrations } = await import("./runner-pg-DCkWPsWS.mjs").then((n) => n.n);
|
|
515
868
|
const applied = await withPgClient(root, async (client) => {
|
|
516
869
|
let existingRows = [];
|
|
517
870
|
try {
|
|
@@ -535,8 +888,33 @@ async function runMigrate(root, dialect, remote) {
|
|
|
535
888
|
outro("Done.");
|
|
536
889
|
return;
|
|
537
890
|
}
|
|
538
|
-
|
|
539
|
-
|
|
891
|
+
if (dialect === "mysql") {
|
|
892
|
+
const { applyMySqlMigrations } = await import("./runner-mysql-CgRFl3s6.mjs").then((n) => n.n);
|
|
893
|
+
const applied = await withMySqlClient(root, async (client) => {
|
|
894
|
+
let existingRows = [];
|
|
895
|
+
try {
|
|
896
|
+
existingRows = await client.query("SELECT `name` FROM `_void_migrations`");
|
|
897
|
+
} catch {
|
|
898
|
+
existingRows = [];
|
|
899
|
+
}
|
|
900
|
+
try {
|
|
901
|
+
validatePendingMigrations(rawMigrations, new Set(existingRows.map((row) => row.name)));
|
|
902
|
+
} catch (err) {
|
|
903
|
+
log.error(getErrorMessage(err));
|
|
904
|
+
process.exit(1);
|
|
905
|
+
}
|
|
906
|
+
return applyMySqlMigrations(client, rawMigrations);
|
|
907
|
+
});
|
|
908
|
+
if (applied.length === 0) log.info("All migrations are up to date.");
|
|
909
|
+
else {
|
|
910
|
+
for (const name of applied) log.step(name);
|
|
911
|
+
log.success(`Applied ${applied.length} migration(s).`);
|
|
912
|
+
}
|
|
913
|
+
outro("Done.");
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
const { getAppliedMigrations, runMigrations } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
917
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
540
918
|
try {
|
|
541
919
|
const existingRows = await getAppliedMigrations(dbPath);
|
|
542
920
|
validatePendingMigrations(rawMigrations, new Set(existingRows.map((row) => row.name)));
|
|
@@ -555,23 +933,32 @@ async function runMigrate(root, dialect, remote) {
|
|
|
555
933
|
}
|
|
556
934
|
async function runStudio(root, dialect, remote) {
|
|
557
935
|
if (remote) {
|
|
558
|
-
if (dialect
|
|
936
|
+
if (dialect === "sqlite") {
|
|
559
937
|
log.error("Remote D1 studio is not yet supported. Use `void db execute --remote` for ad-hoc queries against your deployed D1 database.");
|
|
560
938
|
process.exit(1);
|
|
561
939
|
}
|
|
562
|
-
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
940
|
+
let dbUrl;
|
|
941
|
+
if (readDeploymentPlatform(root) === "cloudflare") {
|
|
942
|
+
dbUrl = process.env.DATABASE_URL ?? "";
|
|
943
|
+
if (!dbUrl) {
|
|
944
|
+
log.error("DATABASE_URL is required in the shell for direct Cloudflare remote Studio.");
|
|
945
|
+
process.exit(1);
|
|
946
|
+
}
|
|
947
|
+
} else {
|
|
948
|
+
const token = getToken(root);
|
|
949
|
+
if (!token) {
|
|
950
|
+
log.error("Not logged in. Run `void auth login` first.");
|
|
951
|
+
process.exit(1);
|
|
952
|
+
}
|
|
953
|
+
const projectConfig = readProjectConfig(root);
|
|
954
|
+
if (!projectConfig) {
|
|
955
|
+
log.error("No project linked. Run `void deploy` first or link a project.");
|
|
956
|
+
process.exit(1);
|
|
957
|
+
}
|
|
958
|
+
dbUrl = await fetchRemoteDatabaseUrl(new PlatformClient(token, { root }), projectConfig.projectId);
|
|
571
959
|
}
|
|
572
|
-
const
|
|
573
|
-
const
|
|
574
|
-
const configPath = writeDrizzleConfig(root, dbUrl, "postgresql");
|
|
960
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
961
|
+
const configPath = writeDrizzleConfig(root, dbUrl, dialect);
|
|
575
962
|
log.info("Opening Drizzle Studio (remote)...");
|
|
576
963
|
try {
|
|
577
964
|
runDrizzleKit(root, [
|
|
@@ -584,9 +971,9 @@ async function runStudio(root, dialect, remote) {
|
|
|
584
971
|
}
|
|
585
972
|
return;
|
|
586
973
|
}
|
|
587
|
-
if (dialect
|
|
588
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
589
|
-
const configPath = writeDrizzleConfig(root, getPgUrl(root),
|
|
974
|
+
if (dialect !== "sqlite") {
|
|
975
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
976
|
+
const configPath = writeDrizzleConfig(root, dialect === "mysql" ? getMySqlUrl(root) : getPgUrl(root), dialect);
|
|
590
977
|
log.info("Opening Drizzle Studio...");
|
|
591
978
|
try {
|
|
592
979
|
runDrizzleKit(root, [
|
|
@@ -599,9 +986,8 @@ async function runStudio(root, dialect, remote) {
|
|
|
599
986
|
}
|
|
600
987
|
return;
|
|
601
988
|
}
|
|
602
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
603
|
-
const {
|
|
604
|
-
const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
|
|
989
|
+
const { writeDrizzleConfig } = await import("./config-NOG_U1aK.mjs").then((n) => n.t);
|
|
990
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
605
991
|
if (!existsSync(dbPath)) {
|
|
606
992
|
log.error("No local database found. Run `void dev` first.");
|
|
607
993
|
process.exit(1);
|
|
@@ -678,7 +1064,8 @@ async function runRenameMigrations(root, dialect) {
|
|
|
678
1064
|
const missingSnapshots = [];
|
|
679
1065
|
for (const { from } of renames) {
|
|
680
1066
|
const fromTag = stripSqlExt(from);
|
|
681
|
-
|
|
1067
|
+
const snapshotFrom = snapshotPathFor(fromTag);
|
|
1068
|
+
if (!existsSync(snapshotFrom)) missingSnapshots.push(`meta/${snapshotPrefix(fromTag)}_snapshot.json`);
|
|
682
1069
|
}
|
|
683
1070
|
if (missingSnapshots.length > 0) {
|
|
684
1071
|
log.error("db: Cannot rename migrations because one or more Drizzle snapshot files are missing:");
|
|
@@ -819,9 +1206,25 @@ async function runRenameMigrations(root, dialect) {
|
|
|
819
1206
|
log.error(String(err));
|
|
820
1207
|
process.exit(1);
|
|
821
1208
|
}
|
|
1209
|
+
else if (dialect === "mysql") try {
|
|
1210
|
+
await withMySqlClient(root, async (client) => {
|
|
1211
|
+
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;
|
|
1212
|
+
for (const { from, to } of renames) await client.query("UPDATE `_void_migrations` SET `name` = ? WHERE `name` = ?", [to, from]);
|
|
1213
|
+
});
|
|
1214
|
+
} catch (err) {
|
|
1215
|
+
reverseSnapshotRenames();
|
|
1216
|
+
for (const { from, to } of renames) try {
|
|
1217
|
+
renameSync(join(migrationsDir, to), join(migrationsDir, from));
|
|
1218
|
+
} catch {}
|
|
1219
|
+
restoreJournal();
|
|
1220
|
+
await reverseRemote();
|
|
1221
|
+
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.");
|
|
1222
|
+
log.error(String(err));
|
|
1223
|
+
process.exit(1);
|
|
1224
|
+
}
|
|
822
1225
|
else {
|
|
823
|
-
const {
|
|
824
|
-
const dbPath =
|
|
1226
|
+
const { openSqliteDatabase } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
1227
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
825
1228
|
if (existsSync(dbPath)) try {
|
|
826
1229
|
const db = await openSqliteDatabase(dbPath);
|
|
827
1230
|
try {
|
|
@@ -852,6 +1255,13 @@ async function runRenameMigrations(root, dialect) {
|
|
|
852
1255
|
log.success(`Renamed ${renames.length} migration(s) to timestamp format.`);
|
|
853
1256
|
outro("Done.");
|
|
854
1257
|
}
|
|
1258
|
+
function formatMySqlExportValue(value) {
|
|
1259
|
+
if (value === null || value === void 0) return "NULL";
|
|
1260
|
+
if (typeof value === "number" || typeof value === "bigint") return String(value);
|
|
1261
|
+
if (typeof value === "boolean") return value ? "1" : "0";
|
|
1262
|
+
if (value instanceof Uint8Array) return `X'${Array.from(value, (byte) => byte.toString(16).padStart(2, "0")).join("")}'`;
|
|
1263
|
+
return `'${(value instanceof Date ? value.toISOString() : String(value)).replaceAll("\\", "\\\\").replaceAll("'", "''")}'`;
|
|
1264
|
+
}
|
|
855
1265
|
async function runExport(root, args, dialect) {
|
|
856
1266
|
const errOut = { output: process.stderr };
|
|
857
1267
|
if (dialect === "postgresql") {
|
|
@@ -865,18 +1275,23 @@ async function runExport(root, args, dialect) {
|
|
|
865
1275
|
}
|
|
866
1276
|
tables = [args.table];
|
|
867
1277
|
} 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));
|
|
1278
|
+
const sequences = await exportPgSequences(client, tables, args);
|
|
1279
|
+
parts.push(...sequences.before);
|
|
868
1280
|
for (const table of tables) {
|
|
1281
|
+
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]);
|
|
1282
|
+
const names = cols.rows.map((column) => quoteSqlIdentifier(String(column.column_name)));
|
|
1283
|
+
const tableName = `"public".${quoteSqlIdentifier(table)}`;
|
|
869
1284
|
if (!args.noSchema) {
|
|
870
|
-
const colDefs =
|
|
871
|
-
let def = `
|
|
1285
|
+
const colDefs = cols.rows.map((column) => {
|
|
1286
|
+
let def = ` ${quoteSqlIdentifier(String(column.column_name))} ${String(column.data_type)}`;
|
|
872
1287
|
if (column.is_nullable === "NO") def += " NOT NULL";
|
|
873
1288
|
if (column.column_default) def += ` DEFAULT ${String(column.column_default)}`;
|
|
874
1289
|
return def;
|
|
875
1290
|
});
|
|
876
|
-
parts.push(`CREATE TABLE
|
|
1291
|
+
parts.push(`CREATE TABLE ${tableName} (\n${colDefs.join(",\n")}\n);`);
|
|
877
1292
|
}
|
|
878
1293
|
if (!args.noData) {
|
|
879
|
-
const rows = await client.query(`SELECT
|
|
1294
|
+
const rows = await client.query(`SELECT ${names.map((name) => `${name}::text AS ${name}`).join(", ")} FROM ${tableName}`);
|
|
880
1295
|
for (const row of rows.rows) {
|
|
881
1296
|
const cols = Object.keys(row);
|
|
882
1297
|
const vals = cols.map((column) => {
|
|
@@ -885,7 +1300,46 @@ async function runExport(root, args, dialect) {
|
|
|
885
1300
|
if (typeof value === "number") return String(value);
|
|
886
1301
|
return `'${String(value).replace(/'/g, "''")}'`;
|
|
887
1302
|
});
|
|
888
|
-
parts.push(`INSERT INTO
|
|
1303
|
+
parts.push(`INSERT INTO ${tableName} (${cols.map(quoteSqlIdentifier).join(", ")}) VALUES (${vals.join(", ")});`);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
parts.push("");
|
|
1307
|
+
}
|
|
1308
|
+
parts.push(...sequences.after);
|
|
1309
|
+
if (!args.noSchema) parts.push(...await exportPgConstraints(client, tables));
|
|
1310
|
+
});
|
|
1311
|
+
const output = parts.join("\n");
|
|
1312
|
+
if (args.output) {
|
|
1313
|
+
writeFileSync(join(root, args.output), output);
|
|
1314
|
+
log.success(`Exported to ${args.output}`);
|
|
1315
|
+
outro("Done.");
|
|
1316
|
+
} else process.stdout.write(output);
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
if (dialect === "mysql") {
|
|
1320
|
+
const parts = [];
|
|
1321
|
+
await withMySqlClient(root, async (client) => {
|
|
1322
|
+
let tables;
|
|
1323
|
+
if (args.table) {
|
|
1324
|
+
if ((await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ?", [args.table])).length === 0) {
|
|
1325
|
+
log.error(`db: Table '${args.table}' not found.`, errOut);
|
|
1326
|
+
process.exit(1);
|
|
1327
|
+
}
|
|
1328
|
+
tables = [args.table];
|
|
1329
|
+
} 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));
|
|
1330
|
+
for (const table of tables) {
|
|
1331
|
+
const escapedTable = table.replaceAll("`", "``");
|
|
1332
|
+
if (!args.noSchema) {
|
|
1333
|
+
const createSql = (await client.query(`SHOW CREATE TABLE \`${escapedTable}\``))[0]?.["Create Table"];
|
|
1334
|
+
if (createSql) parts.push(`${String(createSql)};`);
|
|
1335
|
+
}
|
|
1336
|
+
if (!args.noData) {
|
|
1337
|
+
const rows = await client.query(`SELECT * FROM \`${escapedTable}\``);
|
|
1338
|
+
for (const row of rows) {
|
|
1339
|
+
const columns = Object.keys(row);
|
|
1340
|
+
const values = columns.map((column) => formatMySqlExportValue(row[column]));
|
|
1341
|
+
const names = columns.map((column) => `\`${column.replaceAll("`", "``")}\``);
|
|
1342
|
+
parts.push(`INSERT INTO \`${escapedTable}\` (${names.join(", ")}) VALUES (${values.join(", ")});`);
|
|
889
1343
|
}
|
|
890
1344
|
}
|
|
891
1345
|
parts.push("");
|
|
@@ -899,8 +1353,8 @@ async function runExport(root, args, dialect) {
|
|
|
899
1353
|
} else process.stdout.write(output);
|
|
900
1354
|
return;
|
|
901
1355
|
}
|
|
902
|
-
const {
|
|
903
|
-
const dbPath =
|
|
1356
|
+
const { openSqliteDatabase } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
1357
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
904
1358
|
if (!existsSync(dbPath)) {
|
|
905
1359
|
log.error("No local database found. Run `void dev` first.", errOut);
|
|
906
1360
|
process.exit(1);
|
|
@@ -914,7 +1368,7 @@ async function runExport(root, args, dialect) {
|
|
|
914
1368
|
process.exit(1);
|
|
915
1369
|
}
|
|
916
1370
|
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));
|
|
1371
|
+
} 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
1372
|
const parts = [];
|
|
919
1373
|
for (const table of tables) {
|
|
920
1374
|
if (!args.noSchema) {
|
|
@@ -922,7 +1376,7 @@ async function runExport(root, args, dialect) {
|
|
|
922
1376
|
parts.push(row.sql + ";");
|
|
923
1377
|
}
|
|
924
1378
|
if (!args.noData) {
|
|
925
|
-
const rows = db.prepare(`SELECT * FROM
|
|
1379
|
+
const rows = db.prepare(`SELECT * FROM ${quoteSqlIdentifier(table)}`).all();
|
|
926
1380
|
for (const row of rows) {
|
|
927
1381
|
const cols = Object.keys(row);
|
|
928
1382
|
const vals = cols.map((column) => {
|
|
@@ -931,11 +1385,19 @@ async function runExport(root, args, dialect) {
|
|
|
931
1385
|
if (typeof value === "number") return String(value);
|
|
932
1386
|
return `'${String(value).replace(/'/g, "''")}'`;
|
|
933
1387
|
});
|
|
934
|
-
parts.push(`INSERT INTO
|
|
1388
|
+
parts.push(`INSERT INTO ${quoteSqlIdentifier(table)} (${cols.map(quoteSqlIdentifier).join(", ")}) VALUES (${vals.join(", ")});`);
|
|
935
1389
|
}
|
|
936
1390
|
}
|
|
937
1391
|
parts.push("");
|
|
938
1392
|
}
|
|
1393
|
+
if (!args.noData && db.prepare("SELECT name FROM sqlite_master WHERE name='sqlite_sequence'").get()) {
|
|
1394
|
+
const sequences = db.prepare("SELECT name, seq FROM sqlite_sequence").all();
|
|
1395
|
+
for (const sequence of sequences) if (tables.includes(sequence.name)) {
|
|
1396
|
+
const name = quoteSqlString(sequence.name);
|
|
1397
|
+
parts.push(`DELETE FROM sqlite_sequence WHERE name = ${name};`);
|
|
1398
|
+
parts.push(`INSERT INTO sqlite_sequence (name, seq) VALUES (${name}, ${sequence.seq});`);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
939
1401
|
const output = parts.join("\n");
|
|
940
1402
|
if (args.output) {
|
|
941
1403
|
writeFileSync(join(root, args.output), output);
|
|
@@ -947,9 +1409,10 @@ async function runExport(root, args, dialect) {
|
|
|
947
1409
|
}
|
|
948
1410
|
}
|
|
949
1411
|
async function runSetUrl(root) {
|
|
950
|
-
const { readConfig: readVoidConfig, getDatabaseDialect: getDialect } = await import("./config-
|
|
951
|
-
|
|
952
|
-
|
|
1412
|
+
const { readConfig: readVoidConfig, getDatabaseDialect: getDialect } = await import("./config-BQFq7QvD.mjs").then((n) => n.n);
|
|
1413
|
+
const dialect = getDialect(readVoidConfig(root));
|
|
1414
|
+
if (dialect === "sqlite") {
|
|
1415
|
+
log.error("db: This command is only for PostgreSQL and MySQL projects. Set \"database\" to \"pg\" or \"mysql\" in void.json.");
|
|
953
1416
|
process.exit(1);
|
|
954
1417
|
}
|
|
955
1418
|
const token = getToken(root);
|
|
@@ -962,12 +1425,14 @@ async function runSetUrl(root) {
|
|
|
962
1425
|
log.error("No project linked. Run `void deploy` first or link a project.");
|
|
963
1426
|
process.exit(1);
|
|
964
1427
|
}
|
|
965
|
-
const { text: promptText, isCancel: isCancelCheck } = await import("./
|
|
1428
|
+
const { text: promptText, isCancel: isCancelCheck } = await import("./output-tFQLLj26.mjs").then((n) => n.T);
|
|
966
1429
|
const connectionString = await promptText({
|
|
967
|
-
message:
|
|
968
|
-
placeholder: "postgresql://user:pass@host:5432/dbname",
|
|
1430
|
+
message: `Enter your ${dialect === "mysql" ? "MySQL" : "PostgreSQL"} connection string:`,
|
|
1431
|
+
placeholder: dialect === "mysql" ? "mysql://user:pass@host:3306/dbname" : "postgresql://user:pass@host:5432/dbname",
|
|
969
1432
|
validate(value = "") {
|
|
970
|
-
if (
|
|
1433
|
+
if (dialect === "mysql") {
|
|
1434
|
+
if (!value.startsWith("mysql://")) return "Connection string must start with \"mysql://\"";
|
|
1435
|
+
} else if (!value.startsWith("postgres://") && !value.startsWith("postgresql://")) return "Connection string must start with \"postgres://\" or \"postgresql://\"";
|
|
971
1436
|
}
|
|
972
1437
|
});
|
|
973
1438
|
if (isCancelCheck(connectionString)) process.exit(0);
|
|
@@ -1027,9 +1492,29 @@ async function runSeedModule(root, seedPath, dialect) {
|
|
|
1027
1492
|
});
|
|
1028
1493
|
return;
|
|
1029
1494
|
}
|
|
1495
|
+
if (dialect === "mysql") {
|
|
1496
|
+
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
1497
|
+
const { createConnection } = await import("mysql2/promise");
|
|
1498
|
+
const connection = await createConnection(getMySqlUrl(root));
|
|
1499
|
+
try {
|
|
1500
|
+
const options = getDrizzleSchemaOptions(schema);
|
|
1501
|
+
await seed({
|
|
1502
|
+
dialect,
|
|
1503
|
+
db: options ? drizzle(connection, {
|
|
1504
|
+
...options,
|
|
1505
|
+
mode: "default"
|
|
1506
|
+
}) : drizzle(connection),
|
|
1507
|
+
schema
|
|
1508
|
+
});
|
|
1509
|
+
} finally {
|
|
1510
|
+
await connection.end();
|
|
1511
|
+
}
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1030
1514
|
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
|
1031
|
-
const {
|
|
1032
|
-
const
|
|
1515
|
+
const { openSqliteDatabase } = await import("./local-d1-BE8KBbMy.mjs").then((n) => n.i);
|
|
1516
|
+
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
1517
|
+
const sqlite = await openSqliteDatabase(dbPath);
|
|
1033
1518
|
try {
|
|
1034
1519
|
const options = getDrizzleSchemaOptions(schema);
|
|
1035
1520
|
await seed({
|
|
@@ -1048,7 +1533,7 @@ async function loadSeedFunction(seedPath) {
|
|
|
1048
1533
|
return seed;
|
|
1049
1534
|
}
|
|
1050
1535
|
async function loadSeedSchema(root) {
|
|
1051
|
-
const { discoverSchema } = await import("./discover-
|
|
1536
|
+
const { discoverSchema } = await import("./discover-xvfrgJeo.mjs").then((n) => n.n);
|
|
1052
1537
|
const location = discoverSchema(root, readProjectPaths(root));
|
|
1053
1538
|
if (!location) return {};
|
|
1054
1539
|
if (location.type === "file") {
|