void 0.20.3 → 0.21.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/README.md +2 -2
- package/dist/agents-gni4eqBu.mjs +111 -0
- package/dist/auth-3sGB0zJ1.mjs +22 -0
- package/dist/{auth-DPl6kck4.mjs → auth-B9_D6ygs.mjs} +6 -241
- package/dist/auth-CAw7zHqj.mjs +2 -0
- package/dist/auth-client-BWBT8HLp.mjs +6 -0
- package/dist/auth-client-Bawdj38n.d.mts +7 -0
- package/dist/auth-client-react-7GFffu8R.d.mts +7 -0
- package/dist/auth-client-react-CMLwT2xI.mjs +6 -0
- package/dist/auth-client-solid-DyTFL4cq.d.mts +7 -0
- package/dist/auth-client-solid-UoreJWZG.mjs +6 -0
- package/dist/auth-client-svelte-Cv_WvrRk.mjs +6 -0
- package/dist/auth-client-svelte-zetW0KIH.d.mts +7 -0
- package/dist/auth-client-vue-CFk7Xbv3.mjs +6 -0
- package/dist/auth-client-vue-bChShbQP.d.mts +7 -0
- package/dist/{auth-cmd-CzwquNiP.mjs → auth-cmd-g_ymMkUe.mjs} +5 -5
- package/dist/{auth-link-ElDTgF7j.mjs → auth-link-DFvxIyZi.mjs} +5 -5
- package/dist/{better-auth-shared-DSCeohOK.d.mts → better-auth-shared-BoVwA5Vm.d.mts} +1 -6
- package/dist/{better-auth-shared-CYw1T3k4.mjs → better-auth-shared-syGYYmnY.mjs} +1 -1
- package/dist/{build-cmd-BpJe6boP.mjs → build-cmd-wJAv808h.mjs} +6 -4
- package/dist/{cache-D98YTqeE.mjs → cache-Be0Fu5Ka.mjs} +6 -4
- package/dist/{cancel-deploy-CPbEQLMG.mjs → cancel-deploy-BgmyOwhe.mjs} +5 -3
- package/dist/cf-access-rAZxzMkL.mjs +181 -0
- package/dist/cf-build-output-CTdlo6Rt.mjs +520 -0
- package/dist/cli/cf-compat.d.mts +1 -0
- package/dist/cli/cf-compat.mjs +944 -0
- package/dist/cli/cli.mjs +60 -38
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-DAAivdid.mjs +2 -0
- package/dist/{client-BQBrZoCX.mjs → client-PdAJ-F0t.mjs} +6 -12
- package/dist/{cloudflare-auth-6M5llVPC.mjs → cloudflare-auth-BCmTc1X_.mjs} +13 -44
- package/dist/{cloudflare-cmd-4RPGN3KB.mjs → cloudflare-cmd-D6PrKn7o.mjs} +4 -7
- package/dist/{cloudflare-connect-t1UU5svD.mjs → cloudflare-connect-DloREDlc.mjs} +6 -6
- package/dist/cloudflare-operations-BHNJVDbN.mjs +2 -0
- package/dist/{cloudflare-operations-BzWnlC1_.mjs → cloudflare-operations-CPEdHYhM.mjs} +37 -39
- package/dist/cloudflare-user-output-Q-k0QoNQ.mjs +20 -0
- package/dist/collect-DAUItMDS.mjs +2 -0
- package/dist/collect-DXHNWHcT.mjs +48 -0
- package/dist/config--T87TD8T.mjs +2 -0
- package/dist/{config-NOG_U1aK.mjs → config-BSe70f4T.mjs} +4 -6
- package/dist/config-DDIFxQYx.mjs +2 -0
- package/dist/{config-uNGuFsI2.mjs → config-Dxr6cTXn.mjs} +22 -37
- package/dist/config-DywxBLQC.d.mts +185 -0
- package/dist/config-entry.d.mts +6 -0
- package/dist/config-entry.mjs +7 -0
- package/dist/config-uP7ZDtVZ.mjs +21 -0
- package/dist/config-write-y3CBI_ux.mjs +60 -0
- package/dist/{connect-WCQZ_u3m.mjs → connect-LnvW4HKx.mjs} +8 -6
- package/dist/{create-project-D0oXA090.mjs → create-project-BZBl_gQ0.mjs} +8 -23
- package/dist/create-project-JV9-6ICF.mjs +2 -0
- package/dist/database-provider-Cx525bwX.mjs +6 -0
- package/dist/database-provider.mjs +1 -5
- package/dist/{db-DJ-9qs3S.mjs → db-Mzv88E1C.mjs} +48 -44
- package/dist/{delete-BZ4-WaGm.mjs → delete-Ri6JemSU.mjs} +6 -4
- package/dist/deploy-DAH2-m_-.mjs +2 -0
- package/dist/{deploy-BAhhcg5q.mjs → deploy-DEsMVrCY.mjs} +796 -198
- package/dist/discover-BBzDZe_o.mjs +2 -0
- package/dist/{discover-xvfrgJeo.mjs → discover-C4O6YxVS.mjs} +3 -8
- package/dist/{dist-BrsS7cai.mjs → dist-4WkAWhWx.mjs} +1 -15
- package/dist/{dist-m40_XgNh.mjs → dist-Bn8Kodjp.mjs} +1 -1
- package/dist/dist-C5fND3R0.mjs +2 -0
- package/dist/dist-D7-nEOXi.mjs +2 -0
- package/dist/{output-B0cfNSx5.mjs → dist-Dn6nn2IU.mjs} +3 -926
- package/dist/{domain-BxAyhxXN.mjs → domain-BA37Ye7T.mjs} +7 -5
- package/dist/{route-types-Da-DpyUp.mjs → drizzle-Beb2Am5S.mjs} +1 -280
- package/dist/{email-Bj7Cvdwp.mjs → email-C5NsxrQG.mjs} +14 -12
- package/dist/{email-Ce6SQq-i.mjs → email-C5kaZXzJ.mjs} +2 -2
- package/dist/{entry-DU3oDoQ3.mjs → entry-DdRFGK0y.mjs} +2 -2
- package/dist/{env-DBKmK4vc.mjs → env-DX_v-Q-v.mjs} +1 -1
- package/dist/{env-DP_EErve.mjs → env-U_ohASB0.mjs} +9 -7
- package/dist/env-Yz4HcvHs.mjs +78 -0
- package/dist/env-helpers--wFmQ_5Q.mjs +136 -0
- package/dist/{env-types-BNPhro-M.mjs → env-types-CWDtqHgw.mjs} +6 -2
- package/dist/{env-validation-CF6KvTRf.mjs → env-validation-BsFEXps5.mjs} +19 -28
- package/dist/env-validation-DIDGM7h4.mjs +2 -0
- package/dist/fetch-CXDChK7B.mjs +18 -0
- package/dist/fetch-_SeGZao9.d.mts +57 -0
- package/dist/fetch-stream-AOByI7Ki.mjs +81 -0
- package/dist/fetch-stream-Bjf0hoZb.d.mts +49 -0
- package/dist/gen-B87rlalt.mjs +2 -0
- package/dist/{gen-B_wPnVTK.mjs → gen-pg-Ojg8Y.mjs} +13 -11
- package/dist/{generate-RTK8_kK1.mjs → generate-C0VY6RVf.mjs} +2 -2
- package/dist/{github-cmd-C-z_xRrQ.mjs → github-cmd-DsrkweIl.mjs} +6 -4
- package/dist/{handler-D1hLsObx.d.mts → handler-BXJTXd02.d.mts} +6 -1
- package/dist/handler-DghKr6dU.mjs +150 -0
- package/dist/head-D_QRR5Yd.mjs +112 -0
- package/dist/head-client-DzmJGN4C.mjs +90 -0
- package/dist/{headers-BAHwgHdW.mjs → headers-B_HBMgi0.mjs} +2 -2
- package/dist/help-B403BLBB.mjs +2 -0
- package/dist/{help-CwOX-zmI.mjs → help-sBhFH6pi.mjs} +17 -12
- package/dist/index.d.mts +2 -20
- package/dist/index.mjs +116 -60
- package/dist/{init-BGktCXgA.mjs → init-C--Yyj1b.mjs} +49 -50
- package/dist/{link-D2kbqhWb.mjs → link-BC-mNG9-.mjs} +7 -5
- package/dist/{list-CvkK_G7k.mjs → list-DHU1Wj6c.mjs} +7 -5
- package/dist/live-CB1y5IuC.mjs +411 -0
- package/dist/live-CKiJilLr.d.mts +105 -0
- package/dist/local-d1-DzykTWY8.mjs +104 -0
- package/dist/login-BwiopVdg.mjs +2 -0
- package/dist/{login-WIjNc77c.mjs → login-jKe_0QZL.mjs} +6 -11
- package/dist/{logs-dLUFCapG.mjs → logs-BG11f5PR.mjs} +6 -4
- package/dist/migrate-BV8qHiCb.mjs +285 -0
- package/dist/migrate-BXY3B3m7.mjs +2 -0
- package/dist/migration-handler-DM4clYj5.d.mts +51 -0
- package/dist/{neon-DHwd2zvC.mjs → neon-n74ta1Pr.mjs} +1 -1
- package/dist/{node-Ez5KW5rn.mjs → node-Cupyf7-s.mjs} +6 -6
- package/dist/{operator-auth-B3e08unv.mjs → operator-auth-BkVgJqv-.mjs} +2 -2
- package/dist/{operator-client-LUZnlnYk.mjs → operator-client-A0iex2yi.mjs} +2 -1
- package/dist/{operator-cmd-CKJ7xIRs.mjs → operator-cmd-BwAS2XZt.mjs} +6 -6
- package/dist/output-CCH48AMM.mjs +146 -0
- package/dist/{package-json-CPoWX79C.mjs → package-json-iCbMg5XF.mjs} +1 -1
- package/dist/pages/client.d.mts +5 -2
- package/dist/pages/client.mjs +5 -3
- package/dist/pages/head-client.mjs +1 -89
- package/dist/pages/head.mjs +1 -111
- package/dist/pages/index.d.mts +2 -3
- package/dist/pages/index.mjs +7 -7
- package/dist/pages/islands-plugin.mjs +2 -2
- package/dist/pages/prefetch.d.mts +2 -30
- package/dist/pages/prefetch.mjs +1 -89
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +3 -3
- package/dist/pages/serialize.d.mts +2 -9
- package/dist/pages/serialize.mjs +1 -13
- package/dist/plan-BEZ8VJW0.mjs +256 -0
- package/dist/plan-DpuOr14e.mjs +2 -0
- package/dist/{platform-auth-config-CdVWRRJr.mjs → platform-auth-config-C-hv-_Ok.mjs} +6 -6
- package/dist/{platform-auth-protection-Drl0qhrn.mjs → platform-auth-protection-DjTE5Hj-.mjs} +7 -5
- package/dist/{platform-auth-recovery-CmKEWpDo.mjs → platform-auth-recovery-Cr0r8TEb.mjs} +6 -5
- package/dist/{platform-cmd-5q_k56xS.mjs → platform-cmd-0tEh2ZtA.mjs} +8 -5
- package/dist/platform-cmd-DE6dw45v.mjs +2 -0
- package/dist/{platform-domain-4GiDlcqx.mjs → platform-domain-B_7x6Iqx.mjs} +4 -3
- package/dist/platform-lifecycle-Dhx9Pnub.mjs +2 -0
- package/dist/{platform-lifecycle-R9xAxvtG.mjs → platform-lifecycle-Di0LbhPM.mjs} +208 -37
- package/dist/platform-management-B9LUtMt9.mjs +2 -0
- package/dist/{platform-management-BfWsXHEW.mjs → platform-management-eaiaU3uM.mjs} +8 -5
- package/dist/{platform-recovery-CbK-I1FB.mjs → platform-recovery-BxfA8E5C.mjs} +3 -3
- package/dist/platform-registry-BJbgZLS1.mjs +431 -0
- package/dist/{plugin-inference-BDRfZngg.mjs → plugin-inference-DsvtJLll.mjs} +4 -4
- package/dist/prefetch-Bsc_Pb6c.mjs +90 -0
- package/dist/prefetch-Ce6la4EI.d.mts +31 -0
- package/dist/prepare-D4CkM3_v.mjs +2 -0
- package/dist/{prepare-blNRQvQl.mjs → prepare-_T-Haxrr.mjs} +3 -2
- package/dist/{prepare-CtDJjoOj.mjs → prepare-pcWcxSCh.mjs} +13 -11
- package/dist/prerender-render-Cf_WDE9W.mjs +111 -0
- package/dist/prerender-render.mjs +1 -110
- package/dist/{preset-lAy0B0BQ.mjs → preset-Dowh9tTt.mjs} +16 -118
- package/dist/project-BEBFDFLz.mjs +2 -0
- package/dist/project-CWNIPoXc.mjs +209 -0
- package/dist/{project-cmd-CTdmnzvc.mjs → project-cmd-DrnRJdep.mjs} +18 -16
- package/dist/{project-paths-SK8nMHPp.mjs → project-paths-CKQ-Q5JS.mjs} +47 -14
- package/dist/project-slug-23TpquG4.mjs +8 -0
- package/dist/project-slug-DofjTFd-.mjs +2 -0
- package/dist/{project-team-CGxsQe3_.mjs → project-team-CzRbO_kA.mjs} +6 -4
- package/dist/{project-token-Cirx7uwZ.mjs → project-token-Bwxjf4y6.mjs} +6 -4
- package/dist/{project-tsconfig-Ql2XsSQp.mjs → project-tsconfig-CwfqUnVp.mjs} +2 -2
- package/dist/{protocol-C-pqYJjE.d.mts → protocol-ZH3jP4a7.d.mts} +1 -1
- package/dist/providers-BNKRacMr.d.mts +7 -0
- package/dist/provision-CNgEBkVA.mjs +3 -0
- package/dist/{provision-CSJOjjQk.mjs → provision-Cck2m3jJ.mjs} +11 -25
- package/dist/queues-BWKt1Xo4.d.mts +7 -0
- package/dist/{requests-4Nq59hOr.mjs → requests-DwrqUQZ8.mjs} +5 -3
- package/dist/resolve-project-BTotl8Nn.mjs +2 -0
- package/dist/{resolve-project--Vxawf7z.mjs → resolve-project-Xvis70DG.mjs} +2 -8
- package/dist/response-Tn7rU0MV.mjs +30 -0
- package/dist/{rollback-Dr7u0Ljx.mjs → rollback-B4tFWmkN.mjs} +6 -4
- package/dist/{rolldown-runtime-rQ84J-ij.mjs → rolldown-runtime-DXIUcv95.mjs} +1 -10
- package/dist/route-types-Id82-veQ.mjs +280 -0
- package/dist/{local-d1-D2I6Ox5F.mjs → runner-BGVsGgkb.mjs} +6 -114
- package/dist/runner-CQs_cDSG.mjs +2 -0
- package/dist/runner-mysql-1o47achK.mjs +2 -0
- package/dist/{runner-mysql-7BPUNGmL.mjs → runner-mysql-BhwMk2Bm.mjs} +2 -9
- package/dist/{runner-pg-BkEza-dX.mjs → runner-pg-CJ_JeGF6.mjs} +2 -9
- package/dist/runner-pg-D7z01mQS.mjs +2 -0
- package/dist/runtime/ai.mjs +1 -1
- package/dist/runtime/auth-client-react.d.mts +2 -6
- package/dist/runtime/auth-client-react.mjs +1 -5
- package/dist/runtime/auth-client-solid.d.mts +2 -6
- package/dist/runtime/auth-client-solid.mjs +1 -5
- package/dist/runtime/auth-client-svelte.d.mts +2 -6
- package/dist/runtime/auth-client-svelte.mjs +1 -5
- package/dist/runtime/auth-client-vue.d.mts +2 -6
- package/dist/runtime/auth-client-vue.mjs +1 -5
- package/dist/runtime/auth-client.d.mts +2 -6
- package/dist/runtime/auth-client.mjs +1 -5
- package/dist/runtime/auth.mjs +1 -21
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.d.mts +3 -3
- package/dist/runtime/client-react.mjs +3 -3
- package/dist/runtime/client-solid.d.mts +3 -3
- package/dist/runtime/client-solid.mjs +3 -3
- package/dist/runtime/client-svelte.d.mts +3 -3
- package/dist/runtime/client-svelte.mjs +3 -3
- package/dist/runtime/client-vue.d.mts +3 -3
- package/dist/runtime/client-vue.mjs +3 -3
- package/dist/runtime/client.d.mts +3 -3
- package/dist/runtime/client.mjs +3 -3
- package/dist/runtime/db.mjs +1 -1
- package/dist/runtime/durable.mjs +1 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/env-helpers.mjs +1 -135
- package/dist/runtime/env-public-client.mjs +1 -1
- package/dist/runtime/env-public.mjs +2 -2
- package/dist/runtime/env.mjs +1 -77
- package/dist/runtime/fetch-stream.d.mts +2 -49
- package/dist/runtime/fetch-stream.mjs +2 -80
- package/dist/runtime/fetch.d.mts +2 -57
- package/dist/runtime/fetch.mjs +2 -17
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/handler.mjs +1 -149
- package/dist/runtime/kv.mjs +1 -1
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +2 -2
- package/dist/runtime/live.d.mts +2 -104
- package/dist/runtime/live.mjs +1 -410
- package/dist/runtime/migration-handler-mysql.d.mts +1 -1
- package/dist/runtime/migration-handler-pg.d.mts +1 -1
- package/dist/runtime/migration-handler.d.mts +2 -50
- package/dist/runtime/queues.d.mts +2 -6
- package/dist/runtime/queues.mjs +1 -1
- package/dist/runtime/response.mjs +1 -29
- package/dist/runtime/sandbox.mjs +1 -1
- package/dist/runtime/sse.mjs +1 -171
- package/dist/runtime/storage.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/validator.mjs +1 -71
- package/dist/runtime/ws-server.d.mts +2 -2
- package/dist/runtime/ws-server.mjs +2 -2
- package/dist/runtime/ws.d.mts +2 -121
- package/dist/{scan-CpK-57ug.mjs → scan-DJbooZm2.mjs} +3 -3
- package/dist/{scan-BMH4rzlv.mjs → scan-DdDvRCU1.mjs} +8 -26
- package/dist/{secret-AcPi-FoA.mjs → secret-UtrRjhEO.mjs} +8 -6
- package/dist/serialize-BPvnNQuA.mjs +14 -0
- package/dist/serialize-CfSwWfF2.d.mts +10 -0
- package/dist/{skills-C0RvGjeE.mjs → skills-B-690E7h.mjs} +3 -2
- package/dist/sse-BaC1jXko.mjs +172 -0
- package/dist/{subcommand-prompt-Bmyn5Rlc.mjs → subcommand-prompt-BuGYkAkC.mjs} +2 -1
- package/dist/sveltekit.d.mts +2 -1
- package/dist/sveltekit.mjs +3 -2
- package/dist/validate-DqJ33oHj.mjs +2 -0
- package/dist/validate-qNhV00PD.mjs +180 -0
- package/dist/validator-BTOu0fB0.mjs +72 -0
- package/dist/{wrangler--imS8n0d.mjs → wrangler-D01qs6VB.mjs} +259 -71
- package/dist/ws-BwcqizuH.d.mts +122 -0
- package/dist/{yarn-pnp-DxSInkzL.mjs → yarn-pnp-CVEc3gE7.mjs} +1 -1
- package/package.json +19 -8
- package/skills/void/SKILL.md +6 -4
- package/skills/void/docs/guide/ai.md +3 -3
- package/skills/void/docs/guide/app-types.md +12 -11
- package/skills/void/docs/guide/auth.md +2 -2
- package/skills/void/docs/guide/database/d1.md +1 -1
- package/skills/void/docs/guide/database/mysql.md +1 -1
- package/skills/void/docs/guide/database/postgresql.md +3 -3
- package/skills/void/docs/guide/deployment.md +8 -15
- package/skills/void/docs/guide/durable-state.md +2 -2
- package/skills/void/docs/guide/edge/headers.md +3 -3
- package/skills/void/docs/guide/edge/prerendering.md +1 -1
- package/skills/void/docs/guide/edge/redirects.md +4 -4
- package/skills/void/docs/guide/edge/revalidation.md +6 -6
- package/skills/void/docs/guide/edge/rewrites.md +28 -27
- package/skills/void/docs/guide/edge/static-assets.md +1 -1
- package/skills/void/docs/guide/email.md +60 -66
- package/skills/void/docs/guide/env-migration.md +1 -1
- package/skills/void/docs/guide/index.md +15 -41
- package/skills/void/docs/guide/pages-routing/head.md +1 -1
- package/skills/void/docs/guide/platform/administration/access.md +13 -5
- package/skills/void/docs/guide/platform/administration/projects.md +3 -1
- package/skills/void/docs/guide/platform/installation/ci.md +3 -0
- package/skills/void/docs/guide/platform/installation/credentials.md +15 -5
- package/skills/void/docs/guide/platform/installation/prerequisites.md +2 -0
- package/skills/void/docs/guide/platform/installation/setup.md +1 -1
- package/skills/void/docs/guide/quickstart.md +11 -78
- package/skills/void/docs/guide/remote-dev.md +2 -2
- package/skills/void/docs/guide/sandboxes.md +1 -1
- package/skills/void/docs/guide/ssg.md +1 -1
- package/skills/void/docs/guide/websockets.md +1 -1
- package/skills/void/docs/index.md +17 -17
- package/skills/void/docs/integrations/cloudflare.md +91 -96
- package/skills/void/docs/integrations/frameworks/analog.md +14 -9
- package/skills/void/docs/integrations/frameworks/astro.md +14 -10
- package/skills/void/docs/integrations/frameworks/nuxt.md +14 -9
- package/skills/void/docs/integrations/frameworks/overview.md +35 -29
- package/skills/void/docs/integrations/frameworks/react-router.md +1 -1
- package/skills/void/docs/integrations/frameworks/sveltekit.md +33 -30
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +1 -1
- package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -5
- package/skills/void/docs/reference/api.md +21 -4
- package/skills/void/docs/reference/cli.md +40 -25
- package/skills/void/docs/reference/config.md +58 -35
- package/skills/void/docs/reference/structure.md +2 -2
- package/dist/validate-tBBN_dXH.mjs +0 -505
|
@@ -1,505 +0,0 @@
|
|
|
1
|
-
import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.mjs";
|
|
2
|
-
import { n as dirname, o as join } from "./dist-BrsS7cai.mjs";
|
|
3
|
-
import { t as canonicalJson } from "./canonical-json-DuDiiUsQ.mjs";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { createHash } from "node:crypto";
|
|
6
|
-
//#region src/migrations/collect.ts
|
|
7
|
-
var collect_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
collectMigrations: () => collectMigrations,
|
|
9
|
-
readJournal: () => readJournal,
|
|
10
|
-
stripSqlExt: () => stripSqlExt,
|
|
11
|
-
writeJournal: () => writeJournal
|
|
12
|
-
});
|
|
13
|
-
/**
|
|
14
|
-
* Collect all .sql migration files from the migrations directory,
|
|
15
|
-
* sorted by filename (lexicographic order).
|
|
16
|
-
*/
|
|
17
|
-
function collectMigrations(migrationsDir) {
|
|
18
|
-
if (!existsSync(migrationsDir)) return [];
|
|
19
|
-
return readdirSync(migrationsDir).filter((f) => f.endsWith(".sql") && f !== "seed.sql").sort().map((name) => ({
|
|
20
|
-
name,
|
|
21
|
-
sql: readFileSync(join(migrationsDir, name), "utf-8")
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Read `db/migrations/meta/_journal.json` if it exists. Drizzle maintains
|
|
26
|
-
* this file whenever `drizzle-kit generate` runs; every `.sql` migration
|
|
27
|
-
* under `db/migrations/` should correspond to an entry whose `tag` is the
|
|
28
|
-
* filename without the `.sql` suffix.
|
|
29
|
-
*/
|
|
30
|
-
function readJournal(migrationsDir) {
|
|
31
|
-
const journalPath = join(migrationsDir, "meta", "_journal.json");
|
|
32
|
-
if (!existsSync(journalPath)) return;
|
|
33
|
-
try {
|
|
34
|
-
return JSON.parse(readFileSync(journalPath, "utf-8"));
|
|
35
|
-
} catch (err) {
|
|
36
|
-
throw new Error(`db: Failed to parse db/migrations/meta/_journal.json: '${err.message}'.`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Write `db/migrations/meta/_journal.json` with pretty-printed JSON and a
|
|
41
|
-
* trailing newline, matching the format Drizzle itself emits. Creates the
|
|
42
|
-
* `meta/` directory if it does not yet exist.
|
|
43
|
-
*/
|
|
44
|
-
function writeJournal(migrationsDir, journal) {
|
|
45
|
-
const journalPath = join(migrationsDir, "meta", "_journal.json");
|
|
46
|
-
mkdirSync(dirname(journalPath), { recursive: true });
|
|
47
|
-
writeFileSync(journalPath, JSON.stringify(journal, null, 2) + "\n");
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Drop the `.sql` extension from a migration filename, leaving any other
|
|
51
|
-
* suffix untouched. Used to line filenames up with journal `tag` values.
|
|
52
|
-
*/
|
|
53
|
-
function stripSqlExt(name) {
|
|
54
|
-
return name.endsWith(".sql") ? name.slice(0, -4) : name;
|
|
55
|
-
}
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/migrations/tokenize.ts
|
|
58
|
-
function* tokenizeSql(sql) {
|
|
59
|
-
const sqlLength = sql.length;
|
|
60
|
-
let index = 0;
|
|
61
|
-
let runStart = 0;
|
|
62
|
-
const flushRun = (upTo) => {
|
|
63
|
-
if (upTo > runStart) return {
|
|
64
|
-
kind: "sql",
|
|
65
|
-
start: runStart,
|
|
66
|
-
end: upTo
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
while (index < sqlLength) {
|
|
70
|
-
const character = sql[index];
|
|
71
|
-
const next = index + 1 < sqlLength ? sql[index + 1] : "";
|
|
72
|
-
if (character === "-" && next === "-") {
|
|
73
|
-
const run = flushRun(index);
|
|
74
|
-
if (run) yield run;
|
|
75
|
-
let scanIndex = index + 2;
|
|
76
|
-
while (scanIndex < sqlLength && sql[scanIndex] !== "\n") scanIndex++;
|
|
77
|
-
yield {
|
|
78
|
-
kind: "line-comment",
|
|
79
|
-
start: index,
|
|
80
|
-
end: scanIndex
|
|
81
|
-
};
|
|
82
|
-
index = scanIndex;
|
|
83
|
-
runStart = index;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (character === "/" && next === "*") {
|
|
87
|
-
const run = flushRun(index);
|
|
88
|
-
if (run) yield run;
|
|
89
|
-
let scanIndex = index + 2;
|
|
90
|
-
while (scanIndex < sqlLength - 1 && !(sql[scanIndex] === "*" && sql[scanIndex + 1] === "/")) scanIndex++;
|
|
91
|
-
const end = Math.min(scanIndex + 2, sqlLength);
|
|
92
|
-
yield {
|
|
93
|
-
kind: "block-comment",
|
|
94
|
-
start: index,
|
|
95
|
-
end
|
|
96
|
-
};
|
|
97
|
-
index = end;
|
|
98
|
-
runStart = index;
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (character === "'") {
|
|
102
|
-
const run = flushRun(index);
|
|
103
|
-
if (run) yield run;
|
|
104
|
-
let scanIndex = index + 1;
|
|
105
|
-
while (scanIndex < sqlLength) {
|
|
106
|
-
if (sql[scanIndex] === "'" && sql[scanIndex + 1] === "'") {
|
|
107
|
-
scanIndex += 2;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (sql[scanIndex] === "'") {
|
|
111
|
-
scanIndex++;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
scanIndex++;
|
|
115
|
-
}
|
|
116
|
-
yield {
|
|
117
|
-
kind: "string",
|
|
118
|
-
start: index,
|
|
119
|
-
end: scanIndex
|
|
120
|
-
};
|
|
121
|
-
index = scanIndex;
|
|
122
|
-
runStart = index;
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
if (character === "\"" || character === "`" || character === "[") {
|
|
126
|
-
const run = flushRun(index);
|
|
127
|
-
if (run) yield run;
|
|
128
|
-
const close = character === "[" ? "]" : character;
|
|
129
|
-
let scanIndex = index + 1;
|
|
130
|
-
while (scanIndex < sqlLength) {
|
|
131
|
-
if (close !== "]" && sql[scanIndex] === close && sql[scanIndex + 1] === close) {
|
|
132
|
-
scanIndex += 2;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (sql[scanIndex] === close) {
|
|
136
|
-
scanIndex++;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
scanIndex++;
|
|
140
|
-
}
|
|
141
|
-
yield {
|
|
142
|
-
kind: "ident-quote",
|
|
143
|
-
open: character,
|
|
144
|
-
start: index,
|
|
145
|
-
end: scanIndex
|
|
146
|
-
};
|
|
147
|
-
index = scanIndex;
|
|
148
|
-
runStart = index;
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
index++;
|
|
152
|
-
}
|
|
153
|
-
const tail = flushRun(sqlLength);
|
|
154
|
-
if (tail) yield tail;
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/migrations/plan.ts
|
|
158
|
-
var plan_exports = /* @__PURE__ */ __exportAll({
|
|
159
|
-
DESTRUCTIVE_PRAGMA: () => DESTRUCTIVE_PRAGMA,
|
|
160
|
-
MIGRATION_CLASSIFIER_VERSION: () => 1,
|
|
161
|
-
UNSPLIT_MULTI_STATEMENT_PRAGMA: () => UNSPLIT_MULTI_STATEMENT_PRAGMA,
|
|
162
|
-
buildMigrationPlanBundle: () => buildMigrationPlanBundle,
|
|
163
|
-
canonicalSql: () => canonicalSql,
|
|
164
|
-
classifyMigration: () => classifyMigration,
|
|
165
|
-
computeMigrationListHash: () => computeMigrationListHash,
|
|
166
|
-
hasStandalonePragma: () => hasStandalonePragma,
|
|
167
|
-
isSingleStatement: () => isSingleStatement,
|
|
168
|
-
sha256Hex: () => sha256Hex
|
|
169
|
-
});
|
|
170
|
-
const UNSPLIT_MULTI_STATEMENT_PRAGMA = "-- void:allow-unsplit-multi-statement";
|
|
171
|
-
const DESTRUCTIVE_PRAGMA = "-- void:allow-destructive";
|
|
172
|
-
function canonicalSql(sql) {
|
|
173
|
-
return (sql.charCodeAt(0) === 65279 ? sql.slice(1) : sql).replace(/\r\n?/g, "\n");
|
|
174
|
-
}
|
|
175
|
-
function sha256Hex(value) {
|
|
176
|
-
return `sha256:${createHash("sha256").update(value).digest("hex")}`;
|
|
177
|
-
}
|
|
178
|
-
function getPlanHashInput(plan) {
|
|
179
|
-
const base = {
|
|
180
|
-
classifierVersion: plan.classifierVersion,
|
|
181
|
-
dialect: plan.dialect,
|
|
182
|
-
kind: plan.kind,
|
|
183
|
-
name: plan.name,
|
|
184
|
-
sqlHash: plan.sqlHash,
|
|
185
|
-
stability: plan.stability
|
|
186
|
-
};
|
|
187
|
-
if (plan.kind === "breakpoint-framed") base.statements = plan.statements;
|
|
188
|
-
return base;
|
|
189
|
-
}
|
|
190
|
-
function hashPlan(plan) {
|
|
191
|
-
return sha256Hex(canonicalJson(getPlanHashInput(plan)));
|
|
192
|
-
}
|
|
193
|
-
function computeMigrationListHash(plans) {
|
|
194
|
-
return sha256Hex(canonicalJson(plans.map((plan) => [
|
|
195
|
-
plan.name,
|
|
196
|
-
plan.sqlHash,
|
|
197
|
-
plan.planHash
|
|
198
|
-
])));
|
|
199
|
-
}
|
|
200
|
-
function isStandalonePragmaLine(line, pragma) {
|
|
201
|
-
return line.trim() === pragma;
|
|
202
|
-
}
|
|
203
|
-
function hasStandalonePragma(sql, pragma) {
|
|
204
|
-
return canonicalSql(sql).split("\n").some((line) => isStandalonePragmaLine(line, pragma));
|
|
205
|
-
}
|
|
206
|
-
function isBreakpointComment(text) {
|
|
207
|
-
return text.trim() === "--> statement-breakpoint";
|
|
208
|
-
}
|
|
209
|
-
function splitBreakpointFramedSql(sql) {
|
|
210
|
-
const normalized = canonicalSql(sql);
|
|
211
|
-
const statements = [];
|
|
212
|
-
let cursor = 0;
|
|
213
|
-
for (const segment of tokenizeSql(normalized)) {
|
|
214
|
-
if (segment.kind !== "line-comment") continue;
|
|
215
|
-
if (isBreakpointComment(normalized.slice(segment.start, segment.end))) {
|
|
216
|
-
const statement = normalized.slice(cursor, segment.start).trim();
|
|
217
|
-
if (statement) statements.push(statement);
|
|
218
|
-
cursor = segment.end;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const statement = normalized.slice(cursor).trim();
|
|
222
|
-
if (statement) statements.push(statement);
|
|
223
|
-
return statements;
|
|
224
|
-
}
|
|
225
|
-
function getExecutableSql(sql) {
|
|
226
|
-
let out = "";
|
|
227
|
-
for (const segment of tokenizeSql(sql)) if (segment.kind === "sql") out += sql.slice(segment.start, segment.end);
|
|
228
|
-
else out += " ".repeat(segment.end - segment.start);
|
|
229
|
-
return out;
|
|
230
|
-
}
|
|
231
|
-
function hasStatementBreakpointOutsideLiterals(sql) {
|
|
232
|
-
const normalized = canonicalSql(sql);
|
|
233
|
-
for (const segment of tokenizeSql(normalized)) {
|
|
234
|
-
if (segment.kind !== "line-comment") continue;
|
|
235
|
-
if (isBreakpointComment(normalized.slice(segment.start, segment.end))) return true;
|
|
236
|
-
}
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
function isSingleStatement(sql) {
|
|
240
|
-
const normalized = canonicalSql(sql);
|
|
241
|
-
let statements = 0;
|
|
242
|
-
let inStatement = false;
|
|
243
|
-
for (const segment of tokenizeSql(normalized)) {
|
|
244
|
-
if (segment.kind === "line-comment" || segment.kind === "block-comment") continue;
|
|
245
|
-
if (segment.kind === "string" || segment.kind === "ident-quote") {
|
|
246
|
-
inStatement = true;
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
for (let index = segment.start; index < segment.end; index++) {
|
|
250
|
-
const character = normalized[index];
|
|
251
|
-
if (character === ";") {
|
|
252
|
-
if (inStatement) {
|
|
253
|
-
statements++;
|
|
254
|
-
inStatement = false;
|
|
255
|
-
}
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
if (character !== " " && character !== " " && character !== "\n" && character !== "\r") inStatement = true;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if (inStatement) statements++;
|
|
262
|
-
return statements === 1;
|
|
263
|
-
}
|
|
264
|
-
function includesTransactionControl(sql) {
|
|
265
|
-
return getExecutableSql(sql).match(/(?:^|;)\s*(BEGIN(?:\s+(?:DEFERRED|IMMEDIATE|EXCLUSIVE|TRANSACTION))?|COMMIT|ROLLBACK|SAVEPOINT|RELEASE)\b/i)?.[1]?.toUpperCase() ?? null;
|
|
266
|
-
}
|
|
267
|
-
function classifyMigration(migration) {
|
|
268
|
-
const sql = canonicalSql(migration.sql);
|
|
269
|
-
const sqlHash = sha256Hex(sql);
|
|
270
|
-
const transactionControl = includesTransactionControl(sql);
|
|
271
|
-
if (transactionControl) throw new Error(`Migration ${migration.name} contains ${transactionControl}; Void owns the stable D1 transaction boundary.`);
|
|
272
|
-
let base;
|
|
273
|
-
const warnings = [];
|
|
274
|
-
if (hasStatementBreakpointOutsideLiterals(sql)) {
|
|
275
|
-
const statements = splitBreakpointFramedSql(sql);
|
|
276
|
-
if (statements.length === 0) throw new Error(`Migration ${migration.name} has statement breakpoints but no SQL statements.`);
|
|
277
|
-
base = {
|
|
278
|
-
classifierVersion: 1,
|
|
279
|
-
dialect: "sqlite",
|
|
280
|
-
kind: "breakpoint-framed",
|
|
281
|
-
name: migration.name,
|
|
282
|
-
sqlHash,
|
|
283
|
-
stability: "stable",
|
|
284
|
-
statements
|
|
285
|
-
};
|
|
286
|
-
} else if (isSingleStatement(sql)) base = {
|
|
287
|
-
classifierVersion: 1,
|
|
288
|
-
dialect: "sqlite",
|
|
289
|
-
kind: "single-statement",
|
|
290
|
-
name: migration.name,
|
|
291
|
-
sqlHash,
|
|
292
|
-
stability: "stable"
|
|
293
|
-
};
|
|
294
|
-
else {
|
|
295
|
-
const allowLegacy = hasStandalonePragma(sql, UNSPLIT_MULTI_STATEMENT_PRAGMA);
|
|
296
|
-
warnings.push(`Migration ${migration.name} contains multiple statements without Drizzle statement breakpoints; it will run through the legacy D1 path.`);
|
|
297
|
-
base = {
|
|
298
|
-
allowLegacy,
|
|
299
|
-
classifierVersion: 1,
|
|
300
|
-
dialect: "sqlite",
|
|
301
|
-
kind: "legacy-unsplit-multi-statement",
|
|
302
|
-
name: migration.name,
|
|
303
|
-
sqlHash,
|
|
304
|
-
stability: "legacy"
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
return {
|
|
308
|
-
...base,
|
|
309
|
-
planHash: hashPlan(base),
|
|
310
|
-
...warnings.length > 0 ? { warnings } : {}
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
function buildMigrationPlanBundle(migrations) {
|
|
314
|
-
const plans = migrations.map((migration) => classifyMigration(migration));
|
|
315
|
-
return {
|
|
316
|
-
classifierVersion: 1,
|
|
317
|
-
destructiveValidation: "passed",
|
|
318
|
-
migrationListHash: computeMigrationListHash(plans),
|
|
319
|
-
plans,
|
|
320
|
-
protocolVersion: 2
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/migrations/validate.ts
|
|
325
|
-
var validate_exports = /* @__PURE__ */ __exportAll({
|
|
326
|
-
assertJournalCoherence: () => assertJournalCoherence,
|
|
327
|
-
isDestructive: () => isDestructive,
|
|
328
|
-
listDrizzleArtifacts: () => listDrizzleArtifacts,
|
|
329
|
-
validateMigrations: () => validateMigrations
|
|
330
|
-
});
|
|
331
|
-
/**
|
|
332
|
-
* Destructive SQL patterns that are rejected unless the migration
|
|
333
|
-
* contains the `-- void:allow-destructive` pragma comment.
|
|
334
|
-
*/
|
|
335
|
-
const DESTRUCTIVE_PATTERNS = [
|
|
336
|
-
/\bDROP\s+TABLE\b/i,
|
|
337
|
-
/\bDROP\s+VIEW\b/i,
|
|
338
|
-
/\bDROP\s+INDEX\b/i,
|
|
339
|
-
/\bDROP\s+TRIGGER\b/i,
|
|
340
|
-
/\bALTER\s+TABLE\b[\s\S]*\bDROP\s+COLUMN\b/i,
|
|
341
|
-
/\bALTER\s+TABLE\b[\s\S]*\bRENAME\s+TO\b/i,
|
|
342
|
-
/\bALTER\s+TABLE\b[\s\S]*\bRENAME\s+COLUMN\b/i,
|
|
343
|
-
/\bALTER\s+TABLE\b[\s\S]*\bRENAME\b[\s\S]*\bTO\b/i,
|
|
344
|
-
/\bTRUNCATE\b/i,
|
|
345
|
-
/\bINSERT\s+OR\s+REPLACE\b/i
|
|
346
|
-
];
|
|
347
|
-
function splitExecutableStatements(sql) {
|
|
348
|
-
return sql.split(";").map((statement) => statement.trim()).filter(Boolean);
|
|
349
|
-
}
|
|
350
|
-
function hasTopLevelKeyword(statement, keyword) {
|
|
351
|
-
let depth = 0;
|
|
352
|
-
for (let index = 0; index < statement.length; index++) {
|
|
353
|
-
const character = statement[index];
|
|
354
|
-
if (character === "(") {
|
|
355
|
-
depth++;
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
if (character === ")") {
|
|
359
|
-
depth = Math.max(0, depth - 1);
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
if (depth !== 0) continue;
|
|
363
|
-
if (statement.slice(index, index + keyword.length).toUpperCase() === keyword && !/[A-Z0-9_]/i.test(statement[index - 1] ?? "") && !/[A-Z0-9_]/i.test(statement[index + keyword.length] ?? "")) return true;
|
|
364
|
-
}
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
function hasUnboundedWrite(statement) {
|
|
368
|
-
if (/^(?:CREATE\s+(?:(?:TEMP|TEMPORARY|UNLOGGED)\s+)?|ALTER\s+)TABLE\b/i.test(statement)) return false;
|
|
369
|
-
if (/\bDELETE\s+FROM\b/i.test(statement)) return !hasTopLevelKeyword(statement, "WHERE");
|
|
370
|
-
if (/\bUPDATE\b[\s\S]*\bSET\b/i.test(statement)) return !hasTopLevelKeyword(statement, "WHERE");
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Check if a SQL migration contains destructive operations.
|
|
375
|
-
*/
|
|
376
|
-
function isDestructive(sql) {
|
|
377
|
-
const normalized = sql.replace(/\r\n?/g, "\n");
|
|
378
|
-
let executable = "";
|
|
379
|
-
for (const segment of tokenizeSql(normalized)) if (segment.kind === "sql") executable += normalized.slice(segment.start, segment.end);
|
|
380
|
-
else executable += " ".repeat(segment.end - segment.start);
|
|
381
|
-
return splitExecutableStatements(executable).some((statement) => {
|
|
382
|
-
return DESTRUCTIVE_PATTERNS.some((pattern) => pattern.test(statement)) || hasUnboundedWrite(statement);
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
function hasDestructivePragma(sql) {
|
|
386
|
-
return sql.replace(/\r\n?/g, "\n").split("\n").some((line) => line.trim() === DESTRUCTIVE_PRAGMA);
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Validate migration files. Returns the validated list with destructive flags.
|
|
390
|
-
* Throws if any destructive migration lacks the allow-destructive pragma.
|
|
391
|
-
*/
|
|
392
|
-
function validateMigrations(files) {
|
|
393
|
-
const results = [];
|
|
394
|
-
const errors = [];
|
|
395
|
-
for (const file of files) {
|
|
396
|
-
const destructive = isDestructive(file.sql);
|
|
397
|
-
if (destructive && !hasDestructivePragma(file.sql)) errors.push(file.name);
|
|
398
|
-
results.push({
|
|
399
|
-
name: file.name,
|
|
400
|
-
sql: file.sql,
|
|
401
|
-
destructive
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
if (errors.length > 0) throw new Error(`Destructive migrations detected without pragma:\n` + errors.map((f) => ` - ${f}`).join("\n") + `\n\nAdd "${DESTRUCTIVE_PRAGMA}" to each file to allow the migration locally and on deploy.`);
|
|
405
|
-
return results;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Enumerate drizzle-kit metadata artifacts in a migrations directory.
|
|
409
|
-
* Returns repo-relative paths like `db/migrations/meta/0000_snapshot.json`
|
|
410
|
-
* and `db/migrations/migrations.js`. Empty when none are present.
|
|
411
|
-
*
|
|
412
|
-
* Shared across `assertJournalCoherence`, `void gen migration`, and
|
|
413
|
-
* `void db rename-migrations` so all three agree on what counts as a
|
|
414
|
-
* "partial drizzle-kit state" (journal gone but other metadata lingering).
|
|
415
|
-
*/
|
|
416
|
-
function listDrizzleArtifacts(migrationsDir) {
|
|
417
|
-
const metaDir = join(migrationsDir, "meta");
|
|
418
|
-
const snapshotFiles = existsSync(metaDir) ? readdirSync(metaDir).filter((f) => f.endsWith("_snapshot.json")) : [];
|
|
419
|
-
const bundledPath = join(migrationsDir, "migrations.js");
|
|
420
|
-
const out = [];
|
|
421
|
-
for (const f of snapshotFiles) out.push(`db/migrations/meta/${f}`);
|
|
422
|
-
if (existsSync(bundledPath)) out.push("db/migrations/migrations.js");
|
|
423
|
-
return out;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Assert that every `.sql` file under `migrationsDir` has a matching entry
|
|
427
|
-
* in `meta/_journal.json`, and vice versa.
|
|
428
|
-
*
|
|
429
|
-
* Drift is a silent footgun: the local/remote runners apply files directly
|
|
430
|
-
* from disk, but `drizzle-kit generate` only sees what's in the journal.
|
|
431
|
-
* An orphan file created by hand (or by a botched scaffold/merge) gets
|
|
432
|
-
* applied to D1 without Drizzle ever acknowledging it, and a failed
|
|
433
|
-
* deploy can leave the database in a state that is impossible to recover
|
|
434
|
-
* from without manual SQL edits.
|
|
435
|
-
*
|
|
436
|
-
* A missing journal is NOT a drift error. The drift check is a diff
|
|
437
|
-
* between disk and `meta/_journal.json`; with no journal, there is nothing
|
|
438
|
-
* to diff against. Bare-legacy projects — hand-written `.sql` files with no
|
|
439
|
-
* `db/schema.ts`, no drizzle-kit, no `meta/` directory — worked long
|
|
440
|
-
* before this check existed, and the local/remote runners still track
|
|
441
|
-
* applied migrations by filename via `_void_migrations`. Gating those
|
|
442
|
-
* projects here would break `void deploy`, `void db migrate`, `void db
|
|
443
|
-
* reset`, and `void db status` for a valid path with no migration path
|
|
444
|
-
* forward (they cannot run `void db generate` because it requires
|
|
445
|
-
* `db/schema.ts`). We skip the check silently and let the filename-based
|
|
446
|
-
* runners take over.
|
|
447
|
-
*
|
|
448
|
-
* Throws a user-facing error when any mismatch is detected between the
|
|
449
|
-
* journal and disk. Returns silently otherwise.
|
|
450
|
-
*/
|
|
451
|
-
function assertJournalCoherence(migrationsDir, collected) {
|
|
452
|
-
const journal = readJournal(migrationsDir);
|
|
453
|
-
const drizzleArtifacts = listDrizzleArtifacts(migrationsDir);
|
|
454
|
-
if (journal === void 0) {
|
|
455
|
-
if (drizzleArtifacts.length > 0) throw new Error([
|
|
456
|
-
"db/migrations/meta/_journal.json is missing, but other drizzle-kit metadata is still present:",
|
|
457
|
-
...drizzleArtifacts.map((p) => ` - ${p}`),
|
|
458
|
-
"",
|
|
459
|
-
"This is a partial drizzle-kit state. Restore _journal.json from version control, or delete the orphaned metadata files above if you intended to revert to hand-written migrations."
|
|
460
|
-
].join("\n"));
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (journal === null || typeof journal !== "object" || Array.isArray(journal) || typeof journal.version !== "string" || typeof journal.dialect !== "string" || !Array.isArray(journal.entries)) throw new Error("db/migrations/meta/_journal.json is malformed: expected an object with string `version`, string `dialect`, and an `entries` array. Restore the file from version control, or delete it if you intended to revert to hand-written migrations.");
|
|
464
|
-
for (let i = 0; i < journal.entries.length; i++) {
|
|
465
|
-
const entry = journal.entries[i];
|
|
466
|
-
if (entry === null || typeof entry !== "object" || typeof entry.idx !== "number" || typeof entry.version !== "string" || typeof entry.tag !== "string" || typeof entry.breakpoints !== "boolean") throw new Error(`db/migrations/meta/_journal.json is malformed: entry at index ${i} is missing required fields (\`idx\`, \`version\`, \`tag\`, \`breakpoints\`). Restore the file from version control, or delete it if you intended to revert to hand-written migrations.`);
|
|
467
|
-
}
|
|
468
|
-
if (journal.entries.length === 0) {
|
|
469
|
-
if (drizzleArtifacts.length === 0) return;
|
|
470
|
-
throw new Error([
|
|
471
|
-
"db/migrations/meta/_journal.json has no entries, but drizzle-kit metadata is still present:",
|
|
472
|
-
...drizzleArtifacts.map((p) => ` - ${p}`),
|
|
473
|
-
"",
|
|
474
|
-
"This is a partial drizzle-kit state. Restore _journal.json from version control (or run `void db generate`), or delete the orphaned metadata files above if you intended to revert to hand-written migrations."
|
|
475
|
-
].join("\n"));
|
|
476
|
-
}
|
|
477
|
-
const tagCounts = /* @__PURE__ */ new Map();
|
|
478
|
-
for (const entry of journal.entries) tagCounts.set(entry.tag, (tagCounts.get(entry.tag) ?? 0) + 1);
|
|
479
|
-
const duplicateTags = [...tagCounts.entries()].filter(([, n]) => n > 1).map(([tag]) => tag);
|
|
480
|
-
if (duplicateTags.length > 0) throw new Error([
|
|
481
|
-
"db/migrations/meta/_journal.json has duplicate migration entries:",
|
|
482
|
-
...duplicateTags.map((t) => ` - ${t} (appears ${tagCounts.get(t)} times)`),
|
|
483
|
-
"",
|
|
484
|
-
"Each migration must have a unique tag. Restore _journal.json from version control, or hand-edit to remove the duplicates."
|
|
485
|
-
].join("\n"));
|
|
486
|
-
const journalTags = new Set(journal.entries.map((e) => e.tag));
|
|
487
|
-
const collectedTags = new Set(collected.map((m) => stripSqlExt(m.name)));
|
|
488
|
-
const orphans = collected.map((m) => m.name).filter((name) => !journalTags.has(stripSqlExt(name)));
|
|
489
|
-
const missing = journal.entries.map((e) => `${e.tag}.sql`).filter((file) => !collectedTags.has(stripSqlExt(file)));
|
|
490
|
-
if (orphans.length === 0 && missing.length === 0) return;
|
|
491
|
-
const lines = ["Migration drift detected between db/migrations/ and db/migrations/meta/_journal.json."];
|
|
492
|
-
if (orphans.length > 0) {
|
|
493
|
-
lines.push("", "These files exist on disk but are not tracked in _journal.json:");
|
|
494
|
-
for (const f of orphans) lines.push(` - db/migrations/${f}`);
|
|
495
|
-
lines.push("", "Delete the orphan file(s), or move their contents into `db/schema.ts` and re-run `void db generate`.");
|
|
496
|
-
}
|
|
497
|
-
if (missing.length > 0) {
|
|
498
|
-
lines.push("", "These entries are in _journal.json but the matching file is missing:");
|
|
499
|
-
for (const f of missing) lines.push(` - db/migrations/${f}`);
|
|
500
|
-
lines.push("", "Restore the missing file(s) from version control, or regenerate migrations.");
|
|
501
|
-
}
|
|
502
|
-
throw new Error(lines.join("\n"));
|
|
503
|
-
}
|
|
504
|
-
//#endregion
|
|
505
|
-
export { buildMigrationPlanBundle as a, collectMigrations as c, stripSqlExt as d, writeJournal as f, validate_exports as i, collect_exports as l, listDrizzleArtifacts as n, classifyMigration as o, validateMigrations as r, plan_exports as s, assertJournalCoherence as t, readJournal as u };
|