void 1.0.3 → 1.1.11
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/dist/{account-cmd-BTcUzv9L.mjs → account-cmd-R35a4Oa8.mjs} +3 -3
- package/dist/{application-analysis-AB_YYWgH.mjs → application-analysis-D7nNmNJb.mjs} +6 -6
- package/dist/{application-routing-L7V-TFhZ.mjs → application-routing-CZH66gXn.mjs} +1 -1
- package/dist/{auth-link-DUJuvRx5.mjs → auth-link-VHmiKZmP.mjs} +3 -3
- package/dist/{auth-migrations-Cgs0k6lS.mjs → auth-migrations-BO27GDNr.mjs} +38 -2
- package/dist/{auth-router-CIxiMG7i.mjs → auth-router-O_Wrs5kg.mjs} +5 -4
- package/dist/{better-auth-shared-B74NJIus.d.mts → better-auth-shared-Bv18bB-l.d.mts} +2 -0
- package/dist/{better-auth-shared-CMXlZG7W.mjs → better-auth-shared-D-6z0q0f.mjs} +28 -1
- package/dist/{build-cmd-BkIv25PA.mjs → build-cmd-CMZiMn46.mjs} +1 -1
- package/dist/{cache-Ctzfig-W.mjs → cache-TZ5Ab3d7.mjs} +1 -1
- package/dist/{cancel-deploy-CD9o-SsC.mjs → cancel-deploy-DXoR6oC3.mjs} +1 -1
- package/dist/cli/cli.mjs +69 -50
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-DrdeJgHR.mjs +1 -0
- package/dist/{client-DM9Kcf4e.mjs → client-GuSO3v_x.mjs} +1 -1
- package/dist/{cloudflare-auth-CqFBDo52.mjs → cloudflare-auth-DSvBc1Gu.mjs} +1 -1
- package/dist/{cloudflare-cmd-BIAF_BIY.mjs → cloudflare-cmd-ZSErUl6Y.mjs} +3 -3
- package/dist/{cloudflare-config-DV60XFFK.mjs → cloudflare-config-rdFOys4X.mjs} +2 -2
- package/dist/{cloudflare-connect-WjwnVOJA.mjs → cloudflare-connect-BN-k2kD-.mjs} +2 -2
- package/dist/{cloudflare-operations-CrSUFRzJ.mjs → cloudflare-operations-Cm8lVx7W.mjs} +1 -1
- package/dist/{cloudflare-operations-B42EZeJy.mjs → cloudflare-operations-DH3GedbV.mjs} +6 -6
- package/dist/{cloudflare-process-CeDWJRhj.mjs → cloudflare-process-CZJ4viYl.mjs} +2 -2
- package/dist/collect-BWhkgtAn.mjs +1 -0
- package/dist/{collect-xjffdCdk.mjs → collect-Dew86qce.mjs} +4 -3
- package/dist/{config-D0GY5ItR.mjs → config-CyUJzi3q.mjs} +1 -1
- package/dist/{config-Bx_1SpnO.mjs → config-D26zcdKy.mjs} +2 -2
- package/dist/{config-BEm9vRvS.mjs → config-DC5llZaI.mjs} +2 -2
- package/dist/{config-QrJWu0IX.mjs → config-DYJV8aEH.mjs} +1 -1
- package/dist/{connect-CKtk-EZe.mjs → connect-yQuLbuiJ.mjs} +4 -4
- package/dist/{create-project-B-ewF_Af.mjs → create-project-CGOo_OL_.mjs} +1 -1
- package/dist/{create-project-yInGo72M.mjs → create-project-DEEWJX_M.mjs} +1 -1
- package/dist/database-provider.d.mts +6 -0
- package/dist/{db-7I_gfdVq.mjs → db-COI-yTJE.mjs} +255 -110
- package/dist/{db-types-Bb4WBWIs.mjs → db-types-NGxPwnlt.mjs} +1 -1
- package/dist/{delete-Cy-M1u-r.mjs → delete-PgN6L_9N.mjs} +1 -1
- package/dist/deploy-CxNgEYr4.mjs +2 -0
- package/dist/{deploy-BYYlnsiy.mjs → deploy-DsW-PrRQ.mjs} +38 -36
- package/dist/{deploy-managed-static-Ca4TFdmx.mjs → deploy-managed-static-Dqz06S2u.mjs} +20 -20
- package/dist/{deploy-transport-DWlWBe6M.mjs → deploy-transport-nY3vLXPL.mjs} +2 -2
- package/dist/deploy.mjs +5 -5
- package/dist/discover-D4TPKo57.mjs +1 -0
- package/dist/{discover-D2PGT63u.mjs → discover-LaV0tbIu.mjs} +1 -1
- package/dist/{dispatch-DrTTk8Xg.mjs → dispatch-BAbbn3jg.mjs} +6 -6
- package/dist/{domain-CZGxPv9u.mjs → domain-DKlNI0SR.mjs} +2 -2
- package/dist/{drizzle-CF84FOVM.mjs → drizzle-BQfyvQKX.mjs} +13 -2
- package/dist/{email-DzyNVuoU.mjs → email-C0s3OvJk.mjs} +10 -11
- package/dist/{email-cloudflare-DfG6UEMm.mjs → email-cloudflare-etpKiITL.mjs} +7 -10
- package/dist/{entry-ehmBvs5w.mjs → entry-B_0IhV64.mjs} +1 -1
- package/dist/{env-Nx3yf50r.mjs → env-BX2JFsgF.mjs} +4 -4
- package/dist/{env-types-DS2_y4X8.mjs → env-types-GRchm5dw.mjs} +1 -1
- package/dist/{env-validation-BT7z-qpQ.mjs → env-validation-CuGfWRJd.mjs} +1 -1
- package/dist/{env-validation-DYxjz_Wo.mjs → env-validation-D_KyMdab.mjs} +2 -2
- package/dist/{fetch-BPCYVi3H.d.mts → fetch-DHLOuPyk.d.mts} +2 -2
- package/dist/{fetch-stream-obvZ7fvO.d.mts → fetch-stream-CNxOrBdP.d.mts} +1 -1
- package/dist/{gen-CufHEf42.mjs → gen-Bj6ZkOcI.mjs} +25 -19
- package/dist/gen-DsCukhuw.mjs +1 -0
- package/dist/{generate-Dat0UTry.mjs → generate-B1m4Cm4n.mjs} +1 -1
- package/dist/{generate-ClI89brV.mjs → generate-DkEb9rL-.mjs} +1 -1
- package/dist/{github-cmd-FU8EjFyU.mjs → github-cmd-DQDryS-5.mjs} +1 -1
- package/dist/{headers-Di1FsD3e.mjs → headers-Bi4bOAwp.mjs} +1 -1
- package/dist/{help-BT2hovNI.mjs → help-D49SL_lN.mjs} +16 -12
- package/dist/help-DOFygYi4.mjs +1 -0
- package/dist/{inbound-brj2-TM5.d.mts → inbound-Da7XsjH3.d.mts} +6 -12
- package/dist/index.mjs +103 -57
- package/dist/{info-l249eUdH.mjs → info-Bxunp14X.mjs} +4 -4
- package/dist/{init-D0A6M64Q.mjs → init-DyTEY04s.mjs} +50 -27
- package/dist/{link-WMoJFf4i.mjs → link-CgOVn9EC.mjs} +2 -2
- package/dist/{list-CQ2EQEHL.mjs → list-CUfD9RSb.mjs} +2 -2
- package/dist/{local-d1-BxvQYEFi.mjs → local-d1-CpaPbd_L.mjs} +5 -5
- package/dist/{login-C2T1oVG-.mjs → login-BJvGW5Eu.mjs} +2 -2
- package/dist/login-alAlxw4S.mjs +1 -0
- package/dist/{logs-DnC1d7xB.mjs → logs-DeizBI4j.mjs} +2 -2
- package/dist/{migrate-BDIprOYd.mjs → migrate-8rk56vV8.mjs} +4 -4
- package/dist/migrate-D2odrAmh.mjs +1 -0
- package/dist/{neon-n74ta1Pr.mjs → neon-DTZr7Bu7.mjs} +0 -1
- package/dist/nitro.mjs +3 -3
- package/dist/{node-cPadMgUO.mjs → node-uN8_zxJr.mjs} +15 -9
- package/dist/{operator-cmd-DHieWtFp.mjs → operator-cmd-CA5QQyvE.mjs} +3 -3
- package/dist/operator-cmd-D7toMPJ9.mjs +1 -0
- package/dist/pages/client.d.mts +1 -1
- package/dist/pages/index.d.mts +1 -1
- package/dist/pages/index.mjs +4 -4
- package/dist/pages/islands-plugin.d.mts +1 -1
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +1 -1
- package/dist/{platform-args-CaCL_1Ch.mjs → platform-args-B7ke06up.mjs} +1 -4
- package/dist/platform-args-B_LrqEZB.mjs +1 -0
- package/dist/{platform-auth-config-Z16-I8nT.mjs → platform-auth-config-CZaY812e.mjs} +3 -3
- package/dist/{platform-auth-protection-BXwZiJSF.mjs → platform-auth-protection-U9HCqoXv.mjs} +2 -2
- package/dist/{platform-auth-recovery-CXjfqyOv.mjs → platform-auth-recovery-B0BV2hfV.mjs} +2 -2
- package/dist/{platform-cmd-DaAOiWTl.mjs → platform-cmd-CXrjk4fb.mjs} +4 -4
- package/dist/{platform-cmd-PT4YwMLM.mjs → platform-cmd-D9lwFpcl.mjs} +1 -1
- package/dist/{platform-domain-CxpvUeo0.mjs → platform-domain-CXyq-68_.mjs} +2 -2
- package/dist/{platform-lifecycle-DBiS0cJd.mjs → platform-lifecycle-D0TdyXbN.mjs} +20 -11
- package/dist/{platform-lifecycle-u9pMOvxC.mjs → platform-lifecycle-Dz2cJsLX.mjs} +1 -1
- package/dist/{platform-management-DvBS83rC.mjs → platform-management-BvgbusqL.mjs} +1 -1
- package/dist/{platform-management-DhEFdQAf.mjs → platform-management-CnXhgxTM.mjs} +1 -3
- package/dist/{platform-recovery-BUGOB4RC.mjs → platform-recovery-CH_fThW6.mjs} +2 -2
- package/dist/{plugin-inference-DsARdQKE.mjs → plugin-inference-Bekzjuqw.mjs} +2 -2
- package/dist/{prepare-PQCgsny0.mjs → prepare-2XD6kh77.mjs} +1 -1
- package/dist/{prepare-DEB5SeVJ.mjs → prepare-DepAGBcV.mjs} +9 -9
- package/dist/prepare-EVEbQ9n2.mjs +1 -0
- package/dist/{project-cmd-DVatD8Ev.mjs → project-cmd-CpLYflCH.mjs} +16 -16
- package/dist/{project-paths-DMvEeSau.mjs → project-paths-DGu_QZ_Q.mjs} +1 -1
- package/dist/{project-team-DJrWEAG1.mjs → project-team-CTSY7W7Q.mjs} +1 -1
- package/dist/{project-token-CBgLBuL6.mjs → project-token-Cybtlfbl.mjs} +1 -1
- package/dist/{project-tsconfig-bveqhlYA.mjs → project-tsconfig-Itv1f4WC.mjs} +1 -1
- package/dist/{project-zero-trust-92gLtZ25.mjs → project-zero-trust-DKOtqyvu.mjs} +1 -1
- package/dist/{protocol-4H7V_3Os.d.mts → protocol-B8sI8dRD.d.mts} +1 -1
- package/dist/{providers-BXuhmuub.mjs → providers-BUHwJlmM.mjs} +10 -1
- package/dist/{provision-BnSSkiED.mjs → provision-BuifYvLc.mjs} +63 -64
- package/dist/provision-UcYjpTRh.mjs +1 -0
- package/dist/r2-conditions-B8xUgJRc.mjs +61 -0
- package/dist/{requests-7W1Pygt2.mjs → requests-Ryiazz9i.mjs} +1 -1
- package/dist/{rollback-BcASVnwP.mjs → rollback-Or0EV3rP.mjs} +2 -2
- package/dist/{runner-CabsQ-iM.mjs → runner-3uGC-oLF.mjs} +9 -7
- package/dist/{runner-So9mYfcm.mjs → runner-WCdfeI0q.mjs} +1 -1
- package/dist/{runner-mysql-BhRaONkO.mjs → runner-mysql-BWmbk5IE.mjs} +1 -1
- package/dist/{runner-mysql-DWwE8jKi.mjs → runner-mysql-BcHnLUuM.mjs} +1 -1
- package/dist/{runner-pg-_Xncr3H5.mjs → runner-pg-Cgp-cr_p.mjs} +1 -1
- package/dist/{runner-pg-BRemq_GX.mjs → runner-pg-Cr3qrqi4.mjs} +1 -1
- package/dist/runtime/ai.d.mts +4 -0
- package/dist/runtime/ai.mjs +2 -37
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +2 -2
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +2 -2
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +2 -2
- package/dist/runtime/client-react.d.mts +2 -2
- package/dist/runtime/client-solid.d.mts +2 -2
- package/dist/runtime/client-svelte.d.mts +2 -2
- package/dist/runtime/client-vue.d.mts +2 -2
- package/dist/runtime/client.d.mts +2 -2
- package/dist/runtime/email/testing.d.mts +1 -1
- package/dist/runtime/email.d.mts +2 -3
- package/dist/runtime/email.mjs +2 -3
- package/dist/runtime/fetch-stream.d.mts +2 -2
- package/dist/runtime/fetch.d.mts +1 -1
- package/dist/runtime/migration-handler-mysql.mjs +4 -4
- package/dist/runtime/migration-handler-pg.mjs +9 -1
- package/dist/runtime/remote/binding-handler.mjs +25 -25
- package/dist/runtime/remote/index.d.mts +3 -0
- package/dist/runtime/remote/index.mjs +86 -23
- package/dist/runtime/routing.d.mts +2 -2
- package/dist/runtime/sse-client.d.mts +4 -0
- package/dist/runtime/ws-server.d.mts +2 -2
- package/dist/runtime/ws.d.mts +1 -1
- package/dist/{scan-C0BMdmEd.mjs → scan-D2-FcLHs.mjs} +13 -5
- package/dist/{secret-bg73f1Ge.mjs → secret-CClHaFxm.mjs} +3 -3
- package/dist/{types-BAp5AEBU.d.mts → types-7AIz0OZu.d.mts} +1 -1
- package/dist/{validate-CheZGRE7.mjs → validate-CnZPMq4q.mjs} +22 -17
- package/dist/validate-D7Wn8PUX.mjs +1 -0
- package/dist/{version-metadata-DIrqEHQo.mjs → version-metadata-B1Bm2wSq.mjs} +1 -1
- package/dist/{wrangler-BYs07Rxy.mjs → wrangler-C9XSzrju.mjs} +3 -3
- package/dist/wrangler-DAdxHEzh.mjs +1 -0
- package/dist/{wrapper-CwhpNWtH.mjs → wrapper-BOigE1xJ.mjs} +4 -4
- package/dist/{ws-aKVYB-fA.d.mts → ws-CsBNxv86.d.mts} +5 -0
- package/docs/guide/auth.md +1 -1
- package/docs/guide/database/d1.md +2 -2
- package/docs/guide/database/mysql.md +1 -1
- package/docs/guide/edge/headers.md +10 -2
- package/docs/guide/edge/revalidation.md +2 -0
- package/docs/guide/email/receiving.md +1 -1
- package/docs/guide/email/sending.md +1 -1
- package/docs/guide/pages-routing/islands.md +2 -2
- package/docs/guide/platform/administration/connected-apps.md +18 -2
- package/docs/guide/remote-dev.md +2 -0
- package/docs/guide/websockets.md +2 -2
- package/docs/index.md +78 -22
- package/docs/reference/api/pages.md +7 -5
- package/docs/reference/api.md +2 -0
- package/docs/reference/cli/database.md +7 -5
- package/docs/reference/cli/deploy.md +12 -10
- package/docs/reference/cli/email.md +1 -1
- package/docs/reference/cli/generate.md +1 -1
- package/docs/reference/cli/platform-installation.md +2 -2
- package/docs/reference/cli/project.md +4 -2
- package/docs/reference/cli.md +1 -1
- package/docs/reference/config.md +11 -1
- package/package.json +7 -7
- package/dist/client-B60PwCC4.mjs +0 -1
- package/dist/collect-Cae8A7Zr.mjs +0 -1
- package/dist/deploy-9lgfhrXS.mjs +0 -2
- package/dist/discover-ClzFSwns.mjs +0 -1
- package/dist/gen-sXyp5DFO.mjs +0 -1
- package/dist/help-i2YGGnTH.mjs +0 -1
- package/dist/login-XD844Xs-.mjs +0 -1
- package/dist/migrate-BRwU-blY.mjs +0 -1
- package/dist/operator-cmd-D6gnZsnK.mjs +0 -1
- package/dist/platform-args-B0HeTh0C.mjs +0 -1
- package/dist/prepare-CYT6tAzD.mjs +0 -1
- package/dist/r2-conditions-D1Wk8i7b.mjs +0 -30
- package/dist/validate-BQFdf0Pi.mjs +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { a as join, c as resolve, n as dirname, r as extname, s as relative, t as basename } from "./dist-ipQi0Q8y.mjs";
|
|
2
|
-
import { r as detectFramework } from "./plugin-inference-
|
|
3
|
-
import { n as readProjectPaths } from "./project-paths-
|
|
4
|
-
import { d as readConfig, f as resolveBindingNames, s as getDatabaseDialect } from "./config-
|
|
5
|
-
import { i as writeJournal, n as readJournal, r as stripSqlExt, t as collectMigrations } from "./collect-
|
|
2
|
+
import { r as detectFramework } from "./plugin-inference-Bekzjuqw.mjs";
|
|
3
|
+
import { n as readProjectPaths } from "./project-paths-DGu_QZ_Q.mjs";
|
|
4
|
+
import { d as readConfig, f as resolveBindingNames, s as getDatabaseDialect } from "./config-D26zcdKy.mjs";
|
|
5
|
+
import { i as writeJournal, n as readJournal, r as stripSqlExt, t as collectMigrations } from "./collect-Dew86qce.mjs";
|
|
6
6
|
import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-rqDnVsJN.mjs";
|
|
7
|
-
import { t as resolveLocalD1Target } from "./local-d1-
|
|
7
|
+
import { t as resolveLocalD1Target } from "./local-d1-CpaPbd_L.mjs";
|
|
8
8
|
import { t as cfAccessHeaders } from "./cf-access-BM9G0lhO.mjs";
|
|
9
9
|
import { n as ensurePlatformProxyAccess, r as isCloudflareAccessChallenge, t as ensurePlatformAccessToken } from "./cf-access-CWP4avfP.mjs";
|
|
10
10
|
import { c as getToken, o as getProxyUrl } from "./auth-B6iOCjKI.mjs";
|
|
11
11
|
import { A as confirm, H as outro, L as log, X as text, tt as isCancel } from "./dist-BVdsO7Py.mjs";
|
|
12
12
|
import { f as import_picocolors, i as dim, l as formatUrl, m as printSuccess, o as formatCount, u as getErrorMessage } from "./output-Ba6ZbrzY.mjs";
|
|
13
13
|
import { o as loadLocalEnv } from "./env-BJjULvL0.mjs";
|
|
14
|
-
import { i as validateMigrations, t as assertJournalCoherence } from "./validate-
|
|
15
|
-
import { n as PlatformApiError, r as PlatformClient } from "./client-
|
|
14
|
+
import { i as validateMigrations, t as assertJournalCoherence } from "./validate-CnZPMq4q.mjs";
|
|
15
|
+
import { n as PlatformApiError, r as PlatformClient } from "./client-GuSO3v_x.mjs";
|
|
16
16
|
import { n as drizzleKitBin } from "./yarn-pnp-DLbEFMT0.mjs";
|
|
17
|
-
import { n as formatTimestamp } from "./gen-
|
|
17
|
+
import { n as formatTimestamp } from "./gen-Bj6ZkOcI.mjs";
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
20
20
|
import { pathToFileURL } from "node:url";
|
|
@@ -156,7 +156,7 @@ function runDrizzleKit(root, args) {
|
|
|
156
156
|
* already printed its own error.
|
|
157
157
|
*/
|
|
158
158
|
async function runDrizzleKitWithDatabaseUrl(root, url, dialect, command) {
|
|
159
|
-
const { withPrivateDrizzleConfig } = await import("./config-
|
|
159
|
+
const { withPrivateDrizzleConfig } = await import("./config-DYJV8aEH.mjs");
|
|
160
160
|
if (!withPrivateDrizzleConfig(root, url, dialect, (configPath) => {
|
|
161
161
|
try {
|
|
162
162
|
runDrizzleKit(root, [
|
|
@@ -186,12 +186,18 @@ async function withPgClient(root, fn) {
|
|
|
186
186
|
await client.end();
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
async function withMySqlClient(root, fn) {
|
|
190
|
-
const { toMySqlClient } = await import("./runner-mysql-
|
|
189
|
+
async function withMySqlClient(root, fn, options = {}) {
|
|
190
|
+
const { toMySqlClient } = await import("./runner-mysql-BcHnLUuM.mjs");
|
|
191
191
|
const { createConnection } = await import("mysql2/promise");
|
|
192
192
|
const connection = await createConnection({
|
|
193
193
|
uri: getLocalDatabaseUrl(root, "mysql"),
|
|
194
|
-
multipleStatements: true
|
|
194
|
+
multipleStatements: true,
|
|
195
|
+
...options.textValues ? {
|
|
196
|
+
dateStrings: true,
|
|
197
|
+
jsonStrings: true,
|
|
198
|
+
supportBigNumbers: true,
|
|
199
|
+
bigNumberStrings: true
|
|
200
|
+
} : {}
|
|
195
201
|
});
|
|
196
202
|
try {
|
|
197
203
|
return await fn(toMySqlClient(connection));
|
|
@@ -245,7 +251,7 @@ function assertDatabaseProvider(value, source) {
|
|
|
245
251
|
}
|
|
246
252
|
async function loadDatabaseProvider(root, provider) {
|
|
247
253
|
if (provider === "neon") {
|
|
248
|
-
const { createNeonDatabaseProvider } = await import("./neon-
|
|
254
|
+
const { createNeonDatabaseProvider } = await import("./neon-DTZr7Bu7.mjs");
|
|
249
255
|
return createNeonDatabaseProvider();
|
|
250
256
|
}
|
|
251
257
|
const requireFromProject = createRequire(join(root, "package.json"));
|
|
@@ -305,7 +311,7 @@ async function runPush(root, dialect) {
|
|
|
305
311
|
printSuccess("Database schema pushed.");
|
|
306
312
|
return;
|
|
307
313
|
}
|
|
308
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
314
|
+
const { writeDrizzleConfig } = await import("./config-DYJV8aEH.mjs");
|
|
309
315
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
310
316
|
mkdirSync(dirname(dbPath), { recursive: true });
|
|
311
317
|
const configPath = writeDrizzleConfig(root, dbPath);
|
|
@@ -321,15 +327,15 @@ async function runPush(root, dialect) {
|
|
|
321
327
|
printSuccess("Database schema pushed.");
|
|
322
328
|
}
|
|
323
329
|
async function runGenerate(root, dialect) {
|
|
324
|
-
const { prepareProject } = await import("./prepare-
|
|
325
|
-
const { PLACEHOLDER_DB_URL, writeDrizzleConfig } = await import("./config-
|
|
330
|
+
const { prepareProject } = await import("./prepare-EVEbQ9n2.mjs");
|
|
331
|
+
const { PLACEHOLDER_DB_URL, writeDrizzleConfig } = await import("./config-DYJV8aEH.mjs");
|
|
326
332
|
await prepareProject(root);
|
|
327
333
|
const authSchemaPath = join(root, ".void", "better-auth-schema.ts");
|
|
328
334
|
const additionalSchemas = existsSync(authSchemaPath) ? [authSchemaPath] : void 0;
|
|
329
335
|
const configPath = writeDrizzleConfig(root, PLACEHOLDER_DB_URL[dialect], dialect, { additionalSchemas });
|
|
330
336
|
try {
|
|
331
337
|
if (dialect === "sqlite") {
|
|
332
|
-
const { generateValidatedSqliteMigrations } = await import("./generate-
|
|
338
|
+
const { generateValidatedSqliteMigrations } = await import("./generate-DkEb9rL-.mjs");
|
|
333
339
|
await generateValidatedSqliteMigrations(readProjectPaths(root).migrationsDir, () => {
|
|
334
340
|
runDrizzleKit(root, [
|
|
335
341
|
"generate",
|
|
@@ -353,7 +359,7 @@ async function runStatus(root, dialect) {
|
|
|
353
359
|
const migrationsDir = paths.migrationsDir;
|
|
354
360
|
const allMigrations = collectMigrations(migrationsDir);
|
|
355
361
|
try {
|
|
356
|
-
assertJournalCoherence(migrationsDir, allMigrations);
|
|
362
|
+
assertJournalCoherence(migrationsDir, allMigrations, paths.sourceRelative);
|
|
357
363
|
} catch (err) {
|
|
358
364
|
log.error(getErrorMessage(err));
|
|
359
365
|
process.exit(1);
|
|
@@ -363,35 +369,36 @@ async function runStatus(root, dialect) {
|
|
|
363
369
|
return;
|
|
364
370
|
}
|
|
365
371
|
let localApplied;
|
|
372
|
+
let localError;
|
|
366
373
|
if (dialect === "postgresql") try {
|
|
367
|
-
const { readPgAppliedMigrations } = await import("./runner-pg-
|
|
374
|
+
const { readPgAppliedMigrations } = await import("./runner-pg-Cgp-cr_p.mjs");
|
|
368
375
|
localApplied = await withPgClient(root, readPgAppliedMigrations);
|
|
369
|
-
} catch {
|
|
370
|
-
|
|
376
|
+
} catch (error) {
|
|
377
|
+
localError = error;
|
|
371
378
|
}
|
|
372
379
|
else if (dialect === "mysql") try {
|
|
373
|
-
const { readMySqlAppliedMigrations } = await import("./runner-mysql-
|
|
380
|
+
const { readMySqlAppliedMigrations } = await import("./runner-mysql-BcHnLUuM.mjs");
|
|
374
381
|
localApplied = await withMySqlClient(root, readMySqlAppliedMigrations);
|
|
375
|
-
} catch {
|
|
376
|
-
|
|
382
|
+
} catch (error) {
|
|
383
|
+
localError = error;
|
|
377
384
|
}
|
|
378
385
|
else {
|
|
379
|
-
const { getAppliedMigrations } = await import("./runner-
|
|
386
|
+
const { getAppliedMigrations } = await import("./runner-WCdfeI0q.mjs");
|
|
380
387
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
381
388
|
localApplied = (await getAppliedMigrations(dbPath)).map((m) => m.name);
|
|
382
389
|
}
|
|
383
|
-
const localSet = new Set(localApplied);
|
|
390
|
+
const localSet = localApplied ? new Set(localApplied) : null;
|
|
384
391
|
let remoteApplied = null;
|
|
385
392
|
if (readDeploymentPlatform(root) === "cloudflare") try {
|
|
386
393
|
if (dialect !== "sqlite") {
|
|
387
394
|
const databaseUrl = process.env.DATABASE_URL;
|
|
388
395
|
if (!databaseUrl) throw new Error("DATABASE_URL is not available.");
|
|
389
|
-
remoteApplied = (dialect === "postgresql" ? await (await import("./runner-pg-
|
|
396
|
+
remoteApplied = (dialect === "postgresql" ? await (await import("./runner-pg-Cgp-cr_p.mjs")).getPgAppliedMigrations(databaseUrl) : await (await import("./runner-mysql-BcHnLUuM.mjs")).getMySqlAppliedMigrations(databaseUrl)).map((name) => ({
|
|
390
397
|
name,
|
|
391
398
|
applied_at: ""
|
|
392
399
|
}));
|
|
393
400
|
} else {
|
|
394
|
-
const { readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-
|
|
401
|
+
const { readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-Cm8lVx7W.mjs");
|
|
395
402
|
remoteApplied = (await readCloudflareD1Migrations(resolveCloudflareD1Context(root, configuredD1Binding(root)))).map((name) => ({
|
|
396
403
|
name,
|
|
397
404
|
applied_at: ""
|
|
@@ -406,19 +413,29 @@ async function runStatus(root, dialect) {
|
|
|
406
413
|
} catch {}
|
|
407
414
|
}
|
|
408
415
|
const remoteSet = remoteApplied ? new Set(remoteApplied.map((m) => m.name)) : null;
|
|
416
|
+
if (localSet === null) {
|
|
417
|
+
const message = `Local migration status is unavailable: ${getErrorMessage(localError)}`;
|
|
418
|
+
if (remoteSet === null) {
|
|
419
|
+
log.error(message);
|
|
420
|
+
process.exit(1);
|
|
421
|
+
}
|
|
422
|
+
log.warn(message);
|
|
423
|
+
}
|
|
409
424
|
const lines = [];
|
|
410
425
|
for (const migration of allMigrations) {
|
|
411
|
-
const localStatus = localSet.has(migration.name) ? import_picocolors.default.green("applied") : import_picocolors.default.yellow("pending");
|
|
426
|
+
const localStatus = localSet === null ? dim("unknown") : localSet.has(migration.name) ? import_picocolors.default.green("applied") : import_picocolors.default.yellow("pending");
|
|
412
427
|
let remotePart = "";
|
|
413
428
|
if (remoteSet !== null) remotePart = ` remote: ${remoteSet.has(migration.name) ? import_picocolors.default.green("applied") : import_picocolors.default.yellow("pending")}`;
|
|
414
429
|
lines.push(` ${migration.name} ${dim("local:")} ${localStatus}${remotePart}`);
|
|
415
430
|
}
|
|
416
431
|
log.info(lines.join("\n"));
|
|
417
|
-
const localPending = allMigrations.length - localSet.size;
|
|
418
432
|
const parts = [formatCount(allMigrations.length, "migration")];
|
|
419
|
-
if (
|
|
433
|
+
if (localSet !== null) {
|
|
434
|
+
const localPending = allMigrations.filter((m) => !localSet.has(m.name)).length;
|
|
435
|
+
if (localPending > 0) parts.push(`${localPending} pending locally`);
|
|
436
|
+
}
|
|
420
437
|
if (remoteSet !== null) {
|
|
421
|
-
const remotePending = allMigrations.
|
|
438
|
+
const remotePending = allMigrations.filter((m) => !remoteSet.has(m.name)).length;
|
|
422
439
|
if (remotePending > 0) parts.push(`${remotePending} pending remotely`);
|
|
423
440
|
}
|
|
424
441
|
outro(parts.join(", "));
|
|
@@ -431,6 +448,69 @@ const LOCAL_DATABASE_HOSTS = /* @__PURE__ */ new Set([
|
|
|
431
448
|
"[::1]"
|
|
432
449
|
]);
|
|
433
450
|
/**
|
|
451
|
+
* Objects that `void db reset` drops in `public` before it applies every migration again:
|
|
452
|
+
* tables and views first, then standalone sequences, then enum, domain, range and composite
|
|
453
|
+
* types. drizzle-kit creates them without `IF NOT EXISTS`, so any one that stays makes the
|
|
454
|
+
* migration fail. Extension members stay, and so do sequences that a column owns: the table
|
|
455
|
+
* drop removes them, and their names change when a table is renamed.
|
|
456
|
+
*/
|
|
457
|
+
const PG_RESET_OBJECTS = `SELECT kind, name FROM (
|
|
458
|
+
SELECT CASE rel.relkind WHEN 'v' THEN 'VIEW' WHEN 'm' THEN 'MATERIALIZED VIEW'
|
|
459
|
+
WHEN 'S' THEN 'SEQUENCE' ELSE 'TABLE' END AS kind,
|
|
460
|
+
rel.relname AS name, CASE rel.relkind WHEN 'S' THEN 1 ELSE 0 END AS step
|
|
461
|
+
FROM pg_class rel JOIN pg_namespace ns ON ns.oid = rel.relnamespace
|
|
462
|
+
WHERE ns.nspname = 'public' AND rel.relkind IN ('r', 'p', 'v', 'm', 'S')
|
|
463
|
+
AND NOT EXISTS (
|
|
464
|
+
SELECT 1 FROM pg_depend dep WHERE dep.classid = 'pg_class'::regclass AND dep.objid = rel.oid
|
|
465
|
+
AND (dep.deptype = 'e' OR (rel.relkind = 'S' AND dep.deptype IN ('a', 'i')))
|
|
466
|
+
)
|
|
467
|
+
UNION ALL
|
|
468
|
+
SELECT 'TYPE', typ.typname, 2
|
|
469
|
+
FROM pg_type typ JOIN pg_namespace ns ON ns.oid = typ.typnamespace
|
|
470
|
+
WHERE ns.nspname = 'public'
|
|
471
|
+
AND (typ.typtype IN ('e', 'd', 'r')
|
|
472
|
+
OR (typ.typtype = 'c' AND (SELECT relkind FROM pg_class WHERE oid = typ.typrelid) = 'c'))
|
|
473
|
+
AND NOT EXISTS (
|
|
474
|
+
SELECT 1 FROM pg_depend dep WHERE dep.classid = 'pg_type'::regclass AND dep.objid = typ.oid
|
|
475
|
+
AND dep.deptype = 'e'
|
|
476
|
+
)
|
|
477
|
+
) objects ORDER BY step, name`;
|
|
478
|
+
/**
|
|
479
|
+
* Objects in other schemas that `CASCADE` would also drop with the types ($1) and the views,
|
|
480
|
+
* materialized views and sequences ($2) that reset drops in `public`: a column of that type or
|
|
481
|
+
* its array type, a view, a function, a column default and so on, also through a type or
|
|
482
|
+
* function in `public` that goes with them. Reset must not remove these, so it stops when there
|
|
483
|
+
* are any. The TOAST table of a materialized view is part of it, so it does not count. The table
|
|
484
|
+
* drops still remove what depends on a `public` table in another schema (a view, a foreign key,
|
|
485
|
+
* an inheriting table); a view that also uses one of these objects is listed here too.
|
|
486
|
+
*/
|
|
487
|
+
const PG_RESET_OUTSIDE_DEPENDENTS = `WITH RECURSIVE dropped(classid, objid) AS (
|
|
488
|
+
SELECT 'pg_type'::regclass::oid, typ.oid FROM pg_type typ
|
|
489
|
+
WHERE typ.typnamespace = 'public'::regnamespace AND typ.typname = ANY($1::text[])
|
|
490
|
+
UNION ALL
|
|
491
|
+
SELECT 'pg_class'::regclass::oid, rel.oid FROM pg_class rel
|
|
492
|
+
WHERE rel.relnamespace = 'public'::regnamespace AND rel.relname = ANY($2::text[])
|
|
493
|
+
UNION
|
|
494
|
+
SELECT dep.classid, dep.objid FROM dropped
|
|
495
|
+
JOIN pg_depend dep ON dep.refclassid = dropped.classid AND dep.refobjid = dropped.objid
|
|
496
|
+
WHERE dep.classid IN ('pg_type'::regclass, 'pg_proc'::regclass)
|
|
497
|
+
AND (pg_identify_object(dep.classid, dep.objid, 0)).schema = 'public'
|
|
498
|
+
)
|
|
499
|
+
SELECT DISTINCT pg_describe_object(dep.classid, dep.objid, dep.objsubid) || ' uses '
|
|
500
|
+
|| pg_describe_object(dep.refclassid, dep.refobjid, 0) AS object
|
|
501
|
+
FROM dropped
|
|
502
|
+
JOIN pg_depend dep ON dep.refclassid = dropped.classid AND dep.refobjid = dropped.objid
|
|
503
|
+
WHERE NOT (dep.classid = 'pg_class'::regclass AND dep.deptype = 'i')
|
|
504
|
+
AND COALESCE((pg_identify_object(dep.classid, dep.objid, dep.objsubid)).schema, (
|
|
505
|
+
SELECT ns.nspname FROM pg_class rel JOIN pg_namespace ns ON ns.oid = rel.relnamespace
|
|
506
|
+
WHERE rel.oid = CASE dep.classid
|
|
507
|
+
WHEN 'pg_attrdef'::regclass THEN (SELECT adrelid FROM pg_attrdef WHERE oid = dep.objid)
|
|
508
|
+
WHEN 'pg_rewrite'::regclass THEN (SELECT ev_class FROM pg_rewrite WHERE oid = dep.objid)
|
|
509
|
+
WHEN 'pg_trigger'::regclass THEN (SELECT tgrelid FROM pg_trigger WHERE oid = dep.objid)
|
|
510
|
+
WHEN 'pg_policy'::regclass THEN (SELECT polrelid FROM pg_policy WHERE oid = dep.objid)
|
|
511
|
+
END)) <> 'public'
|
|
512
|
+
ORDER BY object`;
|
|
513
|
+
/**
|
|
434
514
|
* `.env` may hold the deployed database URL (`void db connect` writes it there), so ask before
|
|
435
515
|
* dropping every table on any other host. Without a TTY, require `--yes`.
|
|
436
516
|
*/
|
|
@@ -446,39 +526,56 @@ async function confirmDropAllTables(host, target, yes) {
|
|
|
446
526
|
process.exit(0);
|
|
447
527
|
}
|
|
448
528
|
}
|
|
529
|
+
async function confirmReset(root, dialect, yes) {
|
|
530
|
+
if (dialect === "postgresql") {
|
|
531
|
+
const { Client } = await import("pg");
|
|
532
|
+
const { host, port, database } = new Client({ connectionString: getLocalDatabaseUrl(root, dialect) });
|
|
533
|
+
await confirmDropAllTables(host, `database "${database}" on ${host}:${port}`, yes);
|
|
534
|
+
} else if (dialect === "mysql") {
|
|
535
|
+
const { hostname, host, pathname } = new URL(getLocalDatabaseUrl(root, dialect));
|
|
536
|
+
await confirmDropAllTables(hostname, `database "${decodeURIComponent(pathname.slice(1))}" on ${host}`, yes);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
449
539
|
async function resetDatabase(root, dialect, yes) {
|
|
450
|
-
const
|
|
540
|
+
const paths = readProjectPaths(root);
|
|
541
|
+
const migrationsDir = paths.migrationsDir;
|
|
451
542
|
const migrations = collectMigrations(migrationsDir);
|
|
452
543
|
try {
|
|
453
|
-
assertJournalCoherence(migrationsDir, migrations);
|
|
544
|
+
assertJournalCoherence(migrationsDir, migrations, paths.sourceRelative);
|
|
454
545
|
} catch (err) {
|
|
455
546
|
log.error(getErrorMessage(err));
|
|
456
547
|
process.exit(1);
|
|
457
548
|
}
|
|
549
|
+
await confirmReset(root, dialect, yes);
|
|
458
550
|
if (dialect === "postgresql") {
|
|
459
|
-
const {
|
|
460
|
-
const { host, port, database } = new Client({ connectionString: getLocalDatabaseUrl(root, dialect) });
|
|
461
|
-
await confirmDropAllTables(host, `database "${database}" on ${host}:${port}`, yes);
|
|
462
|
-
const { applyPgMigrations } = await import("./runner-pg-_Xncr3H5.mjs");
|
|
551
|
+
const { applyPgMigrations } = await import("./runner-pg-Cgp-cr_p.mjs");
|
|
463
552
|
await withPgClient(root, async (client) => {
|
|
464
|
-
const
|
|
465
|
-
|
|
553
|
+
const objects = await client.query(PG_RESET_OBJECTS);
|
|
554
|
+
const names = (kind) => objects.rows.filter((row) => row.kind === kind).map((row) => row.name);
|
|
555
|
+
const types = names("TYPE");
|
|
556
|
+
const relations = [
|
|
557
|
+
...names("VIEW"),
|
|
558
|
+
...names("MATERIALIZED VIEW"),
|
|
559
|
+
...names("SEQUENCE")
|
|
560
|
+
];
|
|
561
|
+
const outside = types.length > 0 || relations.length > 0 ? await client.query(PG_RESET_OUTSIDE_DEPENDENTS, [types, relations]) : { rows: [] };
|
|
562
|
+
if (outside.rows.length > 0) throw new Error("db: Reset stopped before dropping anything. Dropping the views, sequences and types in the public schema would also remove these objects in other schemas:\n" + outside.rows.map((row) => ` - ${row.object}\n`).join("") + "Change or drop these objects, or move the views, sequences and types they use out of the public schema, then run the command again.");
|
|
563
|
+
for (const { kind, name } of objects.rows) await client.query(`DROP ${kind} IF EXISTS public.${quoteSqlIdentifier(name)} CASCADE`);
|
|
466
564
|
await applyPgMigrations(client, migrations);
|
|
467
565
|
});
|
|
468
566
|
return migrations.length;
|
|
469
567
|
}
|
|
470
568
|
if (dialect === "mysql") {
|
|
471
|
-
const {
|
|
472
|
-
await confirmDropAllTables(hostname, `database "${decodeURIComponent(pathname.slice(1))}" on ${host}`, yes);
|
|
473
|
-
const { applyPendingMySqlMigrations, withMySqlMigrationLock } = await import("./runner-mysql-DWwE8jKi.mjs");
|
|
569
|
+
const { applyPendingMySqlMigrations, withMySqlMigrationLock } = await import("./runner-mysql-BcHnLUuM.mjs");
|
|
474
570
|
await withMySqlClient(root, (client) => withMySqlMigrationLock(client, async () => {
|
|
475
|
-
const tables = await client.query("SELECT table_name AS table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type
|
|
571
|
+
const tables = await client.query("SELECT table_name AS table_name, table_type AS table_type FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type IN ('BASE TABLE', 'VIEW')");
|
|
476
572
|
await client.query("SET FOREIGN_KEY_CHECKS = 0");
|
|
477
573
|
try {
|
|
478
574
|
for (const row of tables) {
|
|
479
575
|
if (row.table_name === "_void_migration_lock") continue;
|
|
576
|
+
const kind = row.table_type === "VIEW" ? "VIEW" : "TABLE";
|
|
480
577
|
const table = String(row.table_name).replaceAll("`", "``");
|
|
481
|
-
await client.query(`DROP
|
|
578
|
+
await client.query(`DROP ${kind} IF EXISTS \`${table}\``);
|
|
482
579
|
}
|
|
483
580
|
} finally {
|
|
484
581
|
await client.query("SET FOREIGN_KEY_CHECKS = 1");
|
|
@@ -487,7 +584,7 @@ async function resetDatabase(root, dialect, yes) {
|
|
|
487
584
|
}));
|
|
488
585
|
return migrations.length;
|
|
489
586
|
}
|
|
490
|
-
const { runMigrations } = await import("./runner-
|
|
587
|
+
const { runMigrations } = await import("./runner-WCdfeI0q.mjs");
|
|
491
588
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
492
589
|
rmSync(dbPath, { force: true });
|
|
493
590
|
rmSync(dbPath + "-wal", { force: true });
|
|
@@ -500,11 +597,13 @@ async function runReset(root, dialect, yes) {
|
|
|
500
597
|
printSuccess(`Database reset. Applied ${formatCount(count, "migration")}.`);
|
|
501
598
|
}
|
|
502
599
|
async function runSeed(root, file, dialect, yes) {
|
|
503
|
-
const migrationCount = await resetDatabase(root, dialect, yes);
|
|
504
|
-
log.step(`Reset database. Applied ${formatCount(migrationCount, "migration")}.`);
|
|
505
600
|
const seed = resolveSeedTarget(root, file);
|
|
506
|
-
|
|
507
|
-
|
|
601
|
+
const sql = seed.kind === "sql" ? readFileSync(seed.path, "utf-8") : void 0;
|
|
602
|
+
await confirmReset(root, dialect, yes);
|
|
603
|
+
const seedFn = sql === void 0 ? await loadSeedFunction(seed.path) : void 0;
|
|
604
|
+
const migrationCount = await resetDatabase(root, dialect, true);
|
|
605
|
+
log.step(`Reset database. Applied ${formatCount(migrationCount, "migration")}.`);
|
|
606
|
+
if (sql !== void 0) {
|
|
508
607
|
if (dialect === "postgresql") {
|
|
509
608
|
await withPgClient(root, async (client) => {
|
|
510
609
|
await client.query(sql);
|
|
@@ -519,7 +618,7 @@ async function runSeed(root, file, dialect, yes) {
|
|
|
519
618
|
printSuccess(`Seeded from ${seed.displayPath}.`);
|
|
520
619
|
return;
|
|
521
620
|
}
|
|
522
|
-
const { openSqliteDatabase } = await import("./runner-
|
|
621
|
+
const { openSqliteDatabase } = await import("./runner-WCdfeI0q.mjs");
|
|
523
622
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
524
623
|
const db = await openSqliteDatabase(dbPath);
|
|
525
624
|
try {
|
|
@@ -527,7 +626,7 @@ async function runSeed(root, file, dialect, yes) {
|
|
|
527
626
|
} finally {
|
|
528
627
|
db.close();
|
|
529
628
|
}
|
|
530
|
-
} else await runSeedModule(root,
|
|
629
|
+
} else await runSeedModule(root, seedFn, dialect);
|
|
531
630
|
log.info(dim("Restart your dev server if it's running."));
|
|
532
631
|
printSuccess(`Seeded from ${seed.displayPath}.`);
|
|
533
632
|
}
|
|
@@ -604,18 +703,14 @@ async function confirmDestructiveRemote(sql) {
|
|
|
604
703
|
async function runExecute(root, command, file, dialect, remote) {
|
|
605
704
|
if (remote) {
|
|
606
705
|
const directCloudflare = readDeploymentPlatform(root) === "cloudflare";
|
|
607
|
-
|
|
608
|
-
log.error("--file is not yet supported with --remote D1; pipe statements through stdin or run them one at a time.");
|
|
609
|
-
process.exit(1);
|
|
610
|
-
}
|
|
611
|
-
const sql = file ? readFileSync(join(root, file), "utf-8") : command;
|
|
706
|
+
const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
|
|
612
707
|
if (directCloudflare) {
|
|
613
708
|
if (!await confirmDestructiveRemote(sql)) {
|
|
614
709
|
log.info("Cancelled.");
|
|
615
710
|
process.exit(0);
|
|
616
711
|
}
|
|
617
712
|
if (dialect === "sqlite") {
|
|
618
|
-
const { executeCloudflareD1Sql, resolveCloudflareD1Context } = await import("./cloudflare-operations-
|
|
713
|
+
const { executeCloudflareD1Sql, resolveCloudflareD1Context } = await import("./cloudflare-operations-Cm8lVx7W.mjs");
|
|
619
714
|
const rows = await executeCloudflareD1Sql(resolveCloudflareD1Context(root, configuredD1Binding(root)), sql);
|
|
620
715
|
if (rows.length > 0) printTable(rows);
|
|
621
716
|
} else {
|
|
@@ -649,10 +744,11 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
649
744
|
return;
|
|
650
745
|
}
|
|
651
746
|
const platformClient = new PlatformClient(token, { root });
|
|
652
|
-
|
|
747
|
+
const configuredBinding = configuredD1Binding(root);
|
|
748
|
+
let binding = configuredBinding;
|
|
653
749
|
try {
|
|
654
|
-
const
|
|
655
|
-
if (
|
|
750
|
+
const d1Bindings = (await platformClient.getResources(projectConfig.projectId)).filter((r) => r.type === "d1").map((r) => r.binding_name);
|
|
751
|
+
if (!d1Bindings.includes(configuredBinding) && d1Bindings.length === 1) binding = d1Bindings[0];
|
|
656
752
|
} catch {}
|
|
657
753
|
const proxyUrl = getProxyUrl(root);
|
|
658
754
|
ensurePlatformProxyAccess(platformClient.apiUrl, proxyUrl);
|
|
@@ -698,7 +794,7 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
698
794
|
return;
|
|
699
795
|
}
|
|
700
796
|
if (dialect === "postgresql") {
|
|
701
|
-
const sql = file ? readFileSync(
|
|
797
|
+
const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
|
|
702
798
|
await withPgClient(root, async (client) => {
|
|
703
799
|
const result = await client.query(sql);
|
|
704
800
|
if (result.rows && result.rows.length > 0) printTable(result.rows);
|
|
@@ -707,7 +803,7 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
707
803
|
return;
|
|
708
804
|
}
|
|
709
805
|
if (dialect === "mysql") {
|
|
710
|
-
const sql = file ? readFileSync(
|
|
806
|
+
const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
|
|
711
807
|
await withMySqlClient(root, async (client) => {
|
|
712
808
|
const rows = await client.query(sql);
|
|
713
809
|
if (rows.length > 0) printTable(rows);
|
|
@@ -715,13 +811,13 @@ async function runExecute(root, command, file, dialect, remote) {
|
|
|
715
811
|
printSuccess("SQL executed successfully.");
|
|
716
812
|
return;
|
|
717
813
|
}
|
|
718
|
-
const { openSqliteDatabase } = await import("./runner-
|
|
814
|
+
const { openSqliteDatabase } = await import("./runner-WCdfeI0q.mjs");
|
|
719
815
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
720
816
|
if (!existsSync(dbPath)) {
|
|
721
|
-
log.error("No local database found.
|
|
817
|
+
log.error("No local database found. Start the dev server first.");
|
|
722
818
|
process.exit(1);
|
|
723
819
|
}
|
|
724
|
-
const sql = file ? readFileSync(
|
|
820
|
+
const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
|
|
725
821
|
const db = await openSqliteDatabase(dbPath);
|
|
726
822
|
try {
|
|
727
823
|
const trimmed = sql.trimStart();
|
|
@@ -754,7 +850,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
754
850
|
const migrationsDir = paths.migrationsDir;
|
|
755
851
|
const rawMigrations = collectMigrations(migrationsDir);
|
|
756
852
|
try {
|
|
757
|
-
assertJournalCoherence(migrationsDir, rawMigrations);
|
|
853
|
+
assertJournalCoherence(migrationsDir, rawMigrations, paths.sourceRelative);
|
|
758
854
|
} catch (err) {
|
|
759
855
|
log.error(getErrorMessage(err));
|
|
760
856
|
process.exit(1);
|
|
@@ -779,11 +875,11 @@ async function runMigrate(root, dialect, remote) {
|
|
|
779
875
|
let appliedNames;
|
|
780
876
|
let applyMigrations;
|
|
781
877
|
if (dialect === "postgresql") {
|
|
782
|
-
const { getPgAppliedMigrations, runPgMigrations } = await import("./runner-pg-
|
|
878
|
+
const { getPgAppliedMigrations, runPgMigrations } = await import("./runner-pg-Cgp-cr_p.mjs");
|
|
783
879
|
appliedNames = await getPgAppliedMigrations(databaseUrl);
|
|
784
880
|
applyMigrations = () => runPgMigrations(migrationsDir, databaseUrl);
|
|
785
881
|
} else {
|
|
786
|
-
const { getMySqlAppliedMigrations, runMySqlMigrations } = await import("./runner-mysql-
|
|
882
|
+
const { getMySqlAppliedMigrations, runMySqlMigrations } = await import("./runner-mysql-BcHnLUuM.mjs");
|
|
787
883
|
appliedNames = await getMySqlAppliedMigrations(databaseUrl);
|
|
788
884
|
applyMigrations = () => runMySqlMigrations(migrationsDir, databaseUrl);
|
|
789
885
|
}
|
|
@@ -808,7 +904,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
808
904
|
log.info(`No migration files found in ${paths.sourceRelative("db/migrations")}/`);
|
|
809
905
|
return;
|
|
810
906
|
}
|
|
811
|
-
const { applyCloudflareD1Migrations, readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-
|
|
907
|
+
const { applyCloudflareD1Migrations, readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-Cm8lVx7W.mjs");
|
|
812
908
|
const binding = configuredD1Binding(root);
|
|
813
909
|
const context = resolveCloudflareD1Context(root, binding);
|
|
814
910
|
const remoteBefore = new Set(await readCloudflareD1Migrations(context));
|
|
@@ -823,8 +919,13 @@ async function runMigrate(root, dialect, remote) {
|
|
|
823
919
|
log.error(getErrorMessage(error));
|
|
824
920
|
process.exit(1);
|
|
825
921
|
}
|
|
826
|
-
|
|
827
|
-
|
|
922
|
+
if (!context.migrationsDir) {
|
|
923
|
+
const dir = paths.sourceRelative("db/migrations");
|
|
924
|
+
log.error(`db: D1 binding ${binding} has no "migrations_dir", so Cloudflare would apply ./migrations instead of ${dir}/. Add "migrations_dir": "./${dir}" to that D1 binding in your Cloudflare config, then run the command again.`);
|
|
925
|
+
process.exit(1);
|
|
926
|
+
}
|
|
927
|
+
const { checkWranglerMigrationApplySet, parseRootWranglerConfig } = await import("./deploy-CxNgEYr4.mjs");
|
|
928
|
+
const applySet = await checkWranglerMigrationApplySet(context.operation.configPath, parseRootWranglerConfig(context.operation.configPath), binding, context.migrationsDir, rawMigrations, paths.sourceRelative("db/migrations"));
|
|
828
929
|
if (!applySet.ok) {
|
|
829
930
|
log.error(applySet.reason);
|
|
830
931
|
process.exit(1);
|
|
@@ -885,7 +986,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
885
986
|
return;
|
|
886
987
|
}
|
|
887
988
|
if (dialect === "postgresql") {
|
|
888
|
-
const { applyPgMigrations, readPgAppliedMigrations } = await import("./runner-pg-
|
|
989
|
+
const { applyPgMigrations, readPgAppliedMigrations } = await import("./runner-pg-Cgp-cr_p.mjs");
|
|
889
990
|
const applied = await withPgClient(root, async (client) => {
|
|
890
991
|
const appliedNames = await readPgAppliedMigrations(client).catch(() => []);
|
|
891
992
|
try {
|
|
@@ -904,7 +1005,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
904
1005
|
return;
|
|
905
1006
|
}
|
|
906
1007
|
if (dialect === "mysql") {
|
|
907
|
-
const { applyMySqlMigrations, readMySqlAppliedMigrations } = await import("./runner-mysql-
|
|
1008
|
+
const { applyMySqlMigrations, readMySqlAppliedMigrations } = await import("./runner-mysql-BcHnLUuM.mjs");
|
|
908
1009
|
const applied = await withMySqlClient(root, async (client) => {
|
|
909
1010
|
const appliedNames = await readMySqlAppliedMigrations(client).catch(() => []);
|
|
910
1011
|
try {
|
|
@@ -922,7 +1023,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
922
1023
|
}
|
|
923
1024
|
return;
|
|
924
1025
|
}
|
|
925
|
-
const { getAppliedMigrations, runMigrations } = await import("./runner-
|
|
1026
|
+
const { getAppliedMigrations, runMigrations } = await import("./runner-WCdfeI0q.mjs");
|
|
926
1027
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
927
1028
|
try {
|
|
928
1029
|
const existingRows = await getAppliedMigrations(dbPath);
|
|
@@ -931,7 +1032,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
931
1032
|
log.error(getErrorMessage(err));
|
|
932
1033
|
process.exit(1);
|
|
933
1034
|
}
|
|
934
|
-
const applied = await runMigrations(migrationsDir, dbPath);
|
|
1035
|
+
const applied = await runMigrations(migrationsDir, dbPath, paths.sourceRelative);
|
|
935
1036
|
if (applied.length === 0) log.info("All migrations are up to date.");
|
|
936
1037
|
else {
|
|
937
1038
|
for (const name of applied) log.step(name);
|
|
@@ -942,7 +1043,7 @@ async function runMigrate(root, dialect, remote) {
|
|
|
942
1043
|
async function runStudio(root, dialect, remote) {
|
|
943
1044
|
if (remote) {
|
|
944
1045
|
if (dialect === "sqlite") {
|
|
945
|
-
log.error("Remote
|
|
1046
|
+
log.error("Remote Studio supports PostgreSQL and MySQL databases. For D1, use `void db execute --remote` to query the deployed database.");
|
|
946
1047
|
process.exit(1);
|
|
947
1048
|
}
|
|
948
1049
|
let dbUrl;
|
|
@@ -975,10 +1076,10 @@ async function runStudio(root, dialect, remote) {
|
|
|
975
1076
|
await runDrizzleKitWithDatabaseUrl(root, url, dialect, "studio");
|
|
976
1077
|
return;
|
|
977
1078
|
}
|
|
978
|
-
const { writeDrizzleConfig } = await import("./config-
|
|
1079
|
+
const { writeDrizzleConfig } = await import("./config-DYJV8aEH.mjs");
|
|
979
1080
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
980
1081
|
if (!existsSync(dbPath)) {
|
|
981
|
-
log.error("No local database found.
|
|
1082
|
+
log.error("No local database found. Start the dev server first.");
|
|
982
1083
|
process.exit(1);
|
|
983
1084
|
}
|
|
984
1085
|
const configPath = writeDrizzleConfig(root, dbPath);
|
|
@@ -993,21 +1094,37 @@ async function runStudio(root, dialect, remote) {
|
|
|
993
1094
|
process.exit(1);
|
|
994
1095
|
}
|
|
995
1096
|
}
|
|
1097
|
+
/** A direct Cloudflare deploy records its D1 or Hyperdrive id in the checked-in Cloudflare config. */
|
|
1098
|
+
async function hasDeployedCloudflareDatabase(root) {
|
|
1099
|
+
const { readRootWranglerConfig } = await import("./wrangler-DAdxHEzh.mjs");
|
|
1100
|
+
const { isRealD1Id, isRealHyperdriveId } = await import("./provision-UcYjpTRh.mjs");
|
|
1101
|
+
const config = readRootWranglerConfig(root)?.config;
|
|
1102
|
+
const entries = (key) => {
|
|
1103
|
+
const value = config?.[key];
|
|
1104
|
+
return Array.isArray(value) ? value.filter((entry) => !!entry && typeof entry === "object") : [];
|
|
1105
|
+
};
|
|
1106
|
+
return entries("d1_databases").some((entry) => isRealD1Id(entry.database_id)) || entries("hyperdrive").some((entry) => isRealHyperdriveId(entry.id));
|
|
1107
|
+
}
|
|
996
1108
|
async function runRenameMigrations(root, dialect) {
|
|
997
|
-
const
|
|
1109
|
+
const paths = readProjectPaths(root);
|
|
1110
|
+
const migrationsDir = paths.migrationsDir;
|
|
1111
|
+
const dir = paths.sourceRelative("db/migrations");
|
|
998
1112
|
if (!existsSync(migrationsDir)) {
|
|
999
1113
|
log.info("No migrations directory found.");
|
|
1000
1114
|
return;
|
|
1001
1115
|
}
|
|
1002
1116
|
const currentMigrations = collectMigrations(migrationsDir);
|
|
1003
1117
|
try {
|
|
1004
|
-
assertJournalCoherence(migrationsDir, currentMigrations);
|
|
1118
|
+
assertJournalCoherence(migrationsDir, currentMigrations, paths.sourceRelative);
|
|
1005
1119
|
} catch (err) {
|
|
1006
1120
|
log.error(getErrorMessage(err));
|
|
1007
1121
|
process.exit(1);
|
|
1008
1122
|
}
|
|
1009
1123
|
if (existsSync(join(migrationsDir, "migrations.js"))) {
|
|
1010
|
-
log.error(
|
|
1124
|
+
log.error(`This project uses Drizzle's bundled migration format (${dir}/migrations.js).\n\`void db rename-migrations\` cannot rename migrations in bundled mode because
|
|
1125
|
+
\`migrations.js\` contains static imports of the SQL files by filename.
|
|
1126
|
+
|
|
1127
|
+
Delete ${dir}/migrations.js and re-run \`void db generate\` to migrate away\nfrom bundled mode, then retry \`void db rename-migrations\`.`);
|
|
1011
1128
|
process.exit(1);
|
|
1012
1129
|
}
|
|
1013
1130
|
const files = readdirSync(migrationsDir).filter((f) => f.endsWith(".sql") && f !== "seed.sql").sort();
|
|
@@ -1016,6 +1133,16 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1016
1133
|
log.info("No migrations with numeric prefixes found. Nothing to rename.");
|
|
1017
1134
|
return;
|
|
1018
1135
|
}
|
|
1136
|
+
const platform = readDeploymentPlatform(root);
|
|
1137
|
+
const config = readProjectConfig(root);
|
|
1138
|
+
if (platform === "cloudflare" || !config && platform !== "void" && await hasDeployedCloudflareDatabase(root)) {
|
|
1139
|
+
log.error("`void db rename-migrations` does not support direct Cloudflare deploys.\nVoid cannot rename the migration records in your deployed database, so the next deploy would run the renamed migrations again.\nKeep the current file names. New migrations use timestamps and run after them.");
|
|
1140
|
+
process.exit(1);
|
|
1141
|
+
}
|
|
1142
|
+
if (platform === "void" && !config) {
|
|
1143
|
+
log.error("This project deploys to Void but is not linked, so Void cannot rename the migration records in its deployed database.\nRun `void project link`, then run `void db rename-migrations` again.");
|
|
1144
|
+
process.exit(1);
|
|
1145
|
+
}
|
|
1019
1146
|
const timestampFiles = files.filter((f) => /^\d{14}_/.test(f));
|
|
1020
1147
|
let baseTime;
|
|
1021
1148
|
if (timestampFiles.length > 0) {
|
|
@@ -1042,7 +1169,7 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1042
1169
|
const metaDir = join(migrationsDir, "meta");
|
|
1043
1170
|
const journalPath = join(metaDir, "_journal.json");
|
|
1044
1171
|
const originalJournalBytes = existsSync(journalPath) ? readFileSync(journalPath) : null;
|
|
1045
|
-
const journal = readJournal(migrationsDir);
|
|
1172
|
+
const journal = readJournal(migrationsDir, paths.sourceRelative);
|
|
1046
1173
|
const snapshotPrefix = (tag) => tag.split("_")[0];
|
|
1047
1174
|
const snapshotPathFor = (tag) => join(metaDir, `${snapshotPrefix(tag)}_snapshot.json`);
|
|
1048
1175
|
if (journal && journal.entries.length > 0) {
|
|
@@ -1054,13 +1181,12 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1054
1181
|
}
|
|
1055
1182
|
if (missingSnapshots.length > 0) {
|
|
1056
1183
|
log.error("db: Cannot rename migrations because one or more Drizzle snapshot files are missing:");
|
|
1057
|
-
for (const p of missingSnapshots) log.error(` -
|
|
1184
|
+
for (const p of missingSnapshots) log.error(` - ${dir}/${p}`);
|
|
1058
1185
|
log.error("\nRestore the missing snapshot(s) from version control, or reset the migration directory with `void db generate`, then retry.");
|
|
1059
1186
|
process.exit(1);
|
|
1060
1187
|
}
|
|
1061
1188
|
}
|
|
1062
1189
|
const token = getToken(root);
|
|
1063
|
-
const config = readProjectConfig(root);
|
|
1064
1190
|
let remoteRenamed = false;
|
|
1065
1191
|
if (config && !token) {
|
|
1066
1192
|
log.error("Project is linked but you are not logged in.\nRun `void account login` first so remote migration records can be updated.");
|
|
@@ -1091,7 +1217,8 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1091
1217
|
if (journalRewritten && originalJournalBytes !== null) try {
|
|
1092
1218
|
writeFileSync(journalPath, originalJournalBytes);
|
|
1093
1219
|
} catch (error) {
|
|
1094
|
-
log.warn(
|
|
1220
|
+
log.warn(`Could not restore ${dir}/meta/_journal.json after rollback. The journal may be in a partial state.
|
|
1221
|
+
Regenerate it with \`void db generate\`, or restore it from version control.`);
|
|
1095
1222
|
log.warn(String(error));
|
|
1096
1223
|
}
|
|
1097
1224
|
if (remoteRenamed && token && config) try {
|
|
@@ -1130,8 +1257,8 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1130
1257
|
await rollback("db: Failed to rename migration files. All changes have been reverted.", err);
|
|
1131
1258
|
}
|
|
1132
1259
|
if (journal) try {
|
|
1133
|
-
const current = readJournal(migrationsDir);
|
|
1134
|
-
if (!current) throw new Error(
|
|
1260
|
+
const current = readJournal(migrationsDir, paths.sourceRelative);
|
|
1261
|
+
if (!current) throw new Error(`db: ${dir}/meta/_journal.json disappeared mid-run. File renames will be reverted.`);
|
|
1135
1262
|
const renameMap = /* @__PURE__ */ new Map();
|
|
1136
1263
|
for (const { from, to } of renames) renameMap.set(stripSqlExt(from), stripSqlExt(to));
|
|
1137
1264
|
const updatedEntries = current.entries.map((entry) => {
|
|
@@ -1148,7 +1275,7 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1148
1275
|
entries: updatedEntries
|
|
1149
1276
|
});
|
|
1150
1277
|
} catch (err) {
|
|
1151
|
-
await rollback(
|
|
1278
|
+
await rollback(`db: Failed to update ${dir}/meta/_journal.json. File renames have been reverted.`, err);
|
|
1152
1279
|
}
|
|
1153
1280
|
if (dialect === "postgresql") try {
|
|
1154
1281
|
await withPgClient(root, async (client) => {
|
|
@@ -1168,13 +1295,20 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1168
1295
|
else if (dialect === "mysql") try {
|
|
1169
1296
|
await withMySqlClient(root, async (client) => {
|
|
1170
1297
|
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;
|
|
1171
|
-
|
|
1298
|
+
await client.query("START TRANSACTION");
|
|
1299
|
+
try {
|
|
1300
|
+
for (const { from, to } of renames) await client.query("UPDATE `_void_migrations` SET `name` = ? WHERE `name` = ?", [to, from]);
|
|
1301
|
+
await client.query("COMMIT");
|
|
1302
|
+
} catch (err) {
|
|
1303
|
+
await client.query("ROLLBACK").catch(() => {});
|
|
1304
|
+
throw err;
|
|
1305
|
+
}
|
|
1172
1306
|
});
|
|
1173
1307
|
} catch (err) {
|
|
1174
1308
|
await rollback("db: Failed to update MySQL tracking table. File renames have been reverted.\nFix the database connection and run `void db rename-migrations` again.", err);
|
|
1175
1309
|
}
|
|
1176
1310
|
else {
|
|
1177
|
-
const { openSqliteDatabase } = await import("./runner-
|
|
1311
|
+
const { openSqliteDatabase } = await import("./runner-WCdfeI0q.mjs");
|
|
1178
1312
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
1179
1313
|
if (existsSync(dbPath)) try {
|
|
1180
1314
|
const db = await openSqliteDatabase(dbPath);
|
|
@@ -1197,12 +1331,23 @@ async function runRenameMigrations(root, dialect) {
|
|
|
1197
1331
|
}
|
|
1198
1332
|
printSuccess(`Renamed ${formatCount(renames.length, "migration")} to timestamp format.`);
|
|
1199
1333
|
}
|
|
1334
|
+
const INTERNAL_TABLES = /* @__PURE__ */ new Set([
|
|
1335
|
+
"_void_migrations",
|
|
1336
|
+
"_void_migration_attempts",
|
|
1337
|
+
"_void_migration_lock",
|
|
1338
|
+
"_void_migration_fences",
|
|
1339
|
+
"__drizzle_migrations"
|
|
1340
|
+
]);
|
|
1341
|
+
function isInternalTable(name, dialect) {
|
|
1342
|
+
if (INTERNAL_TABLES.has(name)) return true;
|
|
1343
|
+
return dialect === "sqlite" && (name === "_migrations" || name.startsWith("_cf_") || name.startsWith("sqlite_"));
|
|
1344
|
+
}
|
|
1200
1345
|
function formatMySqlExportValue(value) {
|
|
1201
1346
|
if (value === null || value === void 0) return "NULL";
|
|
1202
1347
|
if (typeof value === "number" || typeof value === "bigint") return String(value);
|
|
1203
1348
|
if (typeof value === "boolean") return value ? "1" : "0";
|
|
1204
1349
|
if (value instanceof Uint8Array) return `X'${Array.from(value, (byte) => byte.toString(16).padStart(2, "0")).join("")}'`;
|
|
1205
|
-
return `'${
|
|
1350
|
+
return `'${String(value).replaceAll("\\", "\\\\").replaceAll("'", "''")}'`;
|
|
1206
1351
|
}
|
|
1207
1352
|
function formatSqliteExportValue(value) {
|
|
1208
1353
|
if (value === null) return "NULL";
|
|
@@ -1222,7 +1367,7 @@ async function runExport(root, args, dialect) {
|
|
|
1222
1367
|
process.exit(1);
|
|
1223
1368
|
}
|
|
1224
1369
|
tables = [args.table];
|
|
1225
|
-
} else tables = (await client.query("SELECT tablename FROM pg_tables WHERE schemaname = 'public'
|
|
1370
|
+
} else tables = (await client.query("SELECT tablename FROM pg_tables WHERE schemaname = 'public' ORDER BY tablename")).rows.map((row) => String(row.tablename)).filter((name) => !isInternalTable(name, dialect));
|
|
1226
1371
|
if (!args.noSchema) await assertPgExportableSchema(client, tables, !args.table);
|
|
1227
1372
|
const sequences = await exportPgSequences(client, tables, args);
|
|
1228
1373
|
parts.push(...sequences.before);
|
|
@@ -1274,14 +1419,14 @@ async function runExport(root, args, dialect) {
|
|
|
1274
1419
|
});
|
|
1275
1420
|
const output = parts.join("\n");
|
|
1276
1421
|
if (args.output) {
|
|
1277
|
-
writeFileSync(
|
|
1422
|
+
writeFileSync(resolve(root, args.output), output);
|
|
1278
1423
|
printSuccess(`Exported to ${args.output}`);
|
|
1279
1424
|
} else process.stdout.write(output);
|
|
1280
1425
|
return;
|
|
1281
1426
|
}
|
|
1282
1427
|
if (dialect === "mysql") {
|
|
1283
1428
|
const parts = [];
|
|
1284
|
-
|
|
1429
|
+
const exportTables = async (client) => {
|
|
1285
1430
|
let tables;
|
|
1286
1431
|
if (args.table) {
|
|
1287
1432
|
if ((await client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ?", [args.table])).length === 0) {
|
|
@@ -1289,8 +1434,9 @@ async function runExport(root, args, dialect) {
|
|
|
1289
1434
|
process.exit(1);
|
|
1290
1435
|
}
|
|
1291
1436
|
tables = [args.table];
|
|
1292
|
-
} else tables = (await client.query("SELECT table_name AS table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'
|
|
1293
|
-
|
|
1437
|
+
} else tables = (await client.query("SELECT table_name AS table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE' ORDER BY table_name")).map((row) => String(row.table_name)).filter((name) => !isInternalTable(name, dialect));
|
|
1438
|
+
await client.query("SET time_zone = '+00:00'");
|
|
1439
|
+
parts.push("SET FOREIGN_KEY_CHECKS = 0;", "SET time_zone = '+00:00';");
|
|
1294
1440
|
for (const table of tables) {
|
|
1295
1441
|
const escapedTable = table.replaceAll("`", "``");
|
|
1296
1442
|
if (!args.noSchema) {
|
|
@@ -1309,18 +1455,19 @@ async function runExport(root, args, dialect) {
|
|
|
1309
1455
|
parts.push("");
|
|
1310
1456
|
}
|
|
1311
1457
|
parts.push("SET FOREIGN_KEY_CHECKS = 1;", "");
|
|
1312
|
-
}
|
|
1458
|
+
};
|
|
1459
|
+
await withMySqlClient(root, exportTables, { textValues: true });
|
|
1313
1460
|
const output = parts.join("\n");
|
|
1314
1461
|
if (args.output) {
|
|
1315
|
-
writeFileSync(
|
|
1462
|
+
writeFileSync(resolve(root, args.output), output);
|
|
1316
1463
|
printSuccess(`Exported to ${args.output}`);
|
|
1317
1464
|
} else process.stdout.write(output);
|
|
1318
1465
|
return;
|
|
1319
1466
|
}
|
|
1320
|
-
const { openSqliteDatabase } = await import("./runner-
|
|
1467
|
+
const { openSqliteDatabase } = await import("./runner-WCdfeI0q.mjs");
|
|
1321
1468
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
1322
1469
|
if (!existsSync(dbPath)) {
|
|
1323
|
-
log.error("No local database found.
|
|
1470
|
+
log.error("No local database found. Start the dev server first.", errOut);
|
|
1324
1471
|
process.exit(1);
|
|
1325
1472
|
}
|
|
1326
1473
|
const db = await openSqliteDatabase(dbPath, { readonly: true });
|
|
@@ -1332,7 +1479,7 @@ async function runExport(root, args, dialect) {
|
|
|
1332
1479
|
process.exit(1);
|
|
1333
1480
|
}
|
|
1334
1481
|
tables = [args.table];
|
|
1335
|
-
} else tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'
|
|
1482
|
+
} else tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !isInternalTable(name, dialect));
|
|
1336
1483
|
const parts = [];
|
|
1337
1484
|
for (const table of tables) {
|
|
1338
1485
|
if (!args.noSchema) {
|
|
@@ -1367,14 +1514,14 @@ async function runExport(root, args, dialect) {
|
|
|
1367
1514
|
]) for (const object of schemaObjects) {
|
|
1368
1515
|
if (object.type !== type) continue;
|
|
1369
1516
|
if (type === "view") {
|
|
1370
|
-
if (args.table || object.name
|
|
1517
|
+
if (args.table || isInternalTable(object.name, dialect)) continue;
|
|
1371
1518
|
} else if (!tables.includes(object.tbl_name)) continue;
|
|
1372
1519
|
parts.push(object.sql.trim().replace(/;?$/, ";"));
|
|
1373
1520
|
}
|
|
1374
1521
|
}
|
|
1375
1522
|
const output = parts.join("\n");
|
|
1376
1523
|
if (args.output) {
|
|
1377
|
-
writeFileSync(
|
|
1524
|
+
writeFileSync(resolve(root, args.output), output);
|
|
1378
1525
|
printSuccess(`Exported to ${args.output}`);
|
|
1379
1526
|
} else process.stdout.write(output);
|
|
1380
1527
|
} finally {
|
|
@@ -1444,18 +1591,16 @@ function toSeedTarget(root, seedPath, displayPath) {
|
|
|
1444
1591
|
log.error(`db: Unsupported seed file '${normalizedDisplay}'. Use .sql, .ts, .mts, .js, or .mjs.`);
|
|
1445
1592
|
process.exit(1);
|
|
1446
1593
|
}
|
|
1447
|
-
async function runSeedModule(root,
|
|
1448
|
-
const seed = await loadSeedFunction(seedPath);
|
|
1594
|
+
async function runSeedModule(root, seed, dialect) {
|
|
1449
1595
|
const schema = await loadSeedSchema(root);
|
|
1450
1596
|
if (dialect === "postgresql") {
|
|
1451
1597
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
1452
1598
|
await withPgClient(root, async (client) => {
|
|
1453
1599
|
const options = getDrizzleSchemaOptions(schema);
|
|
1454
1600
|
const drizzleClient = client;
|
|
1455
|
-
const db = options ? drizzle(drizzleClient, options) : drizzle(drizzleClient);
|
|
1456
1601
|
await seed({
|
|
1457
1602
|
dialect,
|
|
1458
|
-
db,
|
|
1603
|
+
db: options ? drizzle(drizzleClient, options) : drizzle(drizzleClient),
|
|
1459
1604
|
schema
|
|
1460
1605
|
});
|
|
1461
1606
|
});
|
|
@@ -1481,7 +1626,7 @@ async function runSeedModule(root, seedPath, dialect) {
|
|
|
1481
1626
|
return;
|
|
1482
1627
|
}
|
|
1483
1628
|
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
|
1484
|
-
const { openSqliteDatabase } = await import("./runner-
|
|
1629
|
+
const { openSqliteDatabase } = await import("./runner-WCdfeI0q.mjs");
|
|
1485
1630
|
const { databasePath: dbPath } = getLocalD1Target(root);
|
|
1486
1631
|
const sqlite = await openSqliteDatabase(dbPath);
|
|
1487
1632
|
try {
|
|
@@ -1502,7 +1647,7 @@ async function loadSeedFunction(seedPath) {
|
|
|
1502
1647
|
return seed;
|
|
1503
1648
|
}
|
|
1504
1649
|
async function loadSeedSchema(root) {
|
|
1505
|
-
const { discoverSchema } = await import("./discover-
|
|
1650
|
+
const { discoverSchema } = await import("./discover-D4TPKo57.mjs");
|
|
1506
1651
|
const location = discoverSchema(root, readProjectPaths(root));
|
|
1507
1652
|
if (!location) return {};
|
|
1508
1653
|
if (location.type === "file") {
|