diff --git a/scripts/dw/commands/reset.ts b/scripts/dw/commands/reset.ts index b00e86d70..dac20ed78 100644 --- a/scripts/dw/commands/reset.ts +++ b/scripts/dw/commands/reset.ts @@ -6,9 +6,6 @@ import { tmuxSessionName, killTmuxSession } from "../helpers/tmux.ts"; import { removeComposeStack } from "../helpers/compose.ts"; import { removeEnvLocalFiles, writeEnvLocalFiles } from "../helpers/env-files.ts"; import { setupAgentWorktree } from "../helpers/setup.ts"; -import { SHARED_DIR, BRANCH_NAME_RE } from "../constants.ts"; -import { existsSync, rmSync } from "node:fs"; -import { join } from "node:path"; import type { RegistryEntry } from "../types.ts"; export async function cmdReset(): Promise { @@ -20,10 +17,7 @@ export async function cmdReset(): Promise { } killTmuxSession(tmuxSessionName(entry.worktreeNum)); if (entry.branchName) deleteBranch(entry.branchName); - if (entry.branchName && BRANCH_NAME_RE.test(entry.branchName)) { - const localDir = join(SHARED_DIR, "drizzle-local", entry.branchName); - if (existsSync(localDir)) rmSync(localDir, { recursive: true, force: true }); - } + // shared/drizzle/ is rewritten on next setupAgentWorktree; no need to clear here. removeComposeStack(entry.worktreeNum); removeEnvLocalFiles(); const cleared: RegistryEntry = { diff --git a/scripts/dw/commands/teardown.ts b/scripts/dw/commands/teardown.ts index 294369a73..05d50724e 100644 --- a/scripts/dw/commands/teardown.ts +++ b/scripts/dw/commands/teardown.ts @@ -11,9 +11,6 @@ import { tmuxSessionName, killTmuxSession } from "../helpers/tmux.ts"; import { removeComposeStack, removeAllAutumnComposeStacks } from "../helpers/compose.ts"; import { removeEnvLocalFiles } from "../helpers/env-files.ts"; import { stopEmulateAndPortless } from "../helpers/emulate.ts"; -import { SHARED_DIR } from "../constants.ts"; -import { existsSync, rmSync } from "node:fs"; -import { join } from "node:path"; import type { Registry } from "../types.ts"; export async function cmdTeardown(opts: { all?: boolean }): Promise { @@ -25,15 +22,6 @@ export async function cmdTeardown(opts: { all?: boolean }): Promise { if (entry.branchName) deleteBranch(entry.branchName); unregisterPortlessAliases(entry.worktreeNum); killTmuxSession(tmuxSessionName(entry.worktreeNum)); - if (entry.branchName) { - const localDir = join( - SHARED_DIR, - "drizzle-local", - entry.branchName, - ); - if (existsSync(localDir)) - rmSync(localDir, { recursive: true, force: true }); - } } removeAllAutumnComposeStacks(); const next: Registry = {}; @@ -62,10 +50,6 @@ export async function cmdTeardown(opts: { all?: boolean }): Promise { unregisterPortlessAliases(entry.worktreeNum); killTmuxSession(tmuxSessionName(entry.worktreeNum)); removeComposeStack(entry.worktreeNum); - if (entry.branchName) { - const localDir = join(SHARED_DIR, "drizzle-local", entry.branchName); - if (existsSync(localDir)) rmSync(localDir, { recursive: true, force: true }); - } delete registry[cwd]; saveRegistry(registry); removeEnvLocalFiles(); diff --git a/scripts/dw/helpers/migration.ts b/scripts/dw/helpers/migration.ts index 2a897bfbe..047eb07ab 100644 --- a/scripts/dw/helpers/migration.ts +++ b/scripts/dw/helpers/migration.ts @@ -19,7 +19,12 @@ export function generateAndApplyMigration( branchName: string, databaseUrl: string, ): void { - const outDir = join(SHARED_DIR, "drizzle-local", branchName); + // Use the worktree's own shared/drizzle/ as the migration dir (matches + // drizzle.config.ts out: "./drizzle"). Empty it first so the baseline + // generated for this fresh Neon branch isn't a diff against the canonical + // repo's migration history — subsequent `bun db:generate` runs then emit + // clean incrementals against this worktree's actual DB state. + const outDir = join(SHARED_DIR, "drizzle"); if (existsSync(outDir)) rmSync(outDir, { recursive: true, force: true }); mkdirSync(outDir, { recursive: true }); diff --git a/scripts/dw/helpers/registry.ts b/scripts/dw/helpers/registry.ts index b37d220a4..ef085a911 100644 --- a/scripts/dw/helpers/registry.ts +++ b/scripts/dw/helpers/registry.ts @@ -1,6 +1,5 @@ import { createHash } from "node:crypto"; -import { existsSync, readFileSync, writeFileSync, rmSync } from "node:fs"; -import { join } from "node:path"; +import { existsSync, readFileSync, writeFileSync } from "node:fs"; import { log, fatal } from "./shell.ts"; import { getWorktreeList, getCurrentWorktree } from "./git.ts"; import { deleteBranch } from "./neon.ts"; @@ -9,7 +8,6 @@ import { MAX_WORKTREE, BRANCH_NAME_RE, INACTIVITY_MS, - SHARED_DIR, } from "../constants.ts"; import type { Registry, RegistryEntry } from "../types.ts"; @@ -83,8 +81,6 @@ export function reconcile(registry: Registry): Registry { for (const o of orphaned) { if (!o.branchName || !BRANCH_NAME_RE.test(o.branchName)) continue; deleteBranch(o.branchName); - const localDir = join(SHARED_DIR, "drizzle-local", o.branchName); - if (existsSync(localDir)) rmSync(localDir, { recursive: true, force: true }); } return next; }