feat: 🎸 empty drizzle for dw
This commit is contained in:
@@ -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<void> {
|
||||
@@ -20,10 +17,7 @@ export async function cmdReset(): Promise<void> {
|
||||
}
|
||||
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 = {
|
||||
|
||||
@@ -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<void> {
|
||||
@@ -25,15 +22,6 @@ export async function cmdTeardown(opts: { all?: boolean }): Promise<void> {
|
||||
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<void> {
|
||||
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();
|
||||
|
||||
@@ -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 });
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user