mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
chore: improve worktree tooling and security docs
This commit is contained in:
parent
548721248e
commit
8bdf4081ee
17 changed files with 1100 additions and 123 deletions
|
|
@ -39,6 +39,8 @@ import {
|
|||
issues,
|
||||
projectWorkspaces,
|
||||
projects,
|
||||
routines,
|
||||
routineTriggers,
|
||||
runDatabaseBackup,
|
||||
runDatabaseRestore,
|
||||
createEmbeddedPostgresLogBuffer,
|
||||
|
|
@ -922,6 +924,36 @@ async function ensureEmbeddedPostgres(dataDir: string, preferredPort: number): P
|
|||
};
|
||||
}
|
||||
|
||||
export async function pauseSeededScheduledRoutines(connectionString: string): Promise<number> {
|
||||
const db = createDb(connectionString);
|
||||
try {
|
||||
const scheduledRoutineIds = await db
|
||||
.selectDistinct({ routineId: routineTriggers.routineId })
|
||||
.from(routineTriggers)
|
||||
.where(and(eq(routineTriggers.kind, "schedule"), eq(routineTriggers.enabled, true)));
|
||||
const idsToPause = scheduledRoutineIds
|
||||
.map((row) => row.routineId)
|
||||
.filter((value): value is string => Boolean(value));
|
||||
|
||||
if (idsToPause.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const paused = await db
|
||||
.update(routines)
|
||||
.set({
|
||||
status: "paused",
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(and(inArray(routines.id, idsToPause), sql`${routines.status} <> 'paused'`, sql`${routines.status} <> 'archived'`))
|
||||
.returning({ id: routines.id });
|
||||
|
||||
return paused.length;
|
||||
} finally {
|
||||
await db.$client?.end?.({ timeout: 5 }).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
async function seedWorktreeDatabase(input: {
|
||||
sourceConfigPath: string;
|
||||
sourceConfig: PaperclipConfig;
|
||||
|
|
@ -979,6 +1011,7 @@ async function seedWorktreeDatabase(input: {
|
|||
backupFile: backup.backupFile,
|
||||
});
|
||||
await applyPendingMigrations(targetConnectionString);
|
||||
await pauseSeededScheduledRoutines(targetConnectionString);
|
||||
const reboundWorkspaces = await rebindSeededProjectWorkspaces({
|
||||
targetConnectionString,
|
||||
currentCwd: input.targetPaths.cwd,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue