fix: refuse objects built on a continuous aggregate, show copy warnings in the cli and import

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-12-02 12:12:01 +01:00
co-authored by Claude Opus 5.5
parent 443fc4a589
commit 4c71c42e49
4 changed files with 53 additions and 10 deletions
+15 -5
View File
@@ -24,7 +24,11 @@ import {
} from "../../core/conf.ts";
/** Wait for a fork creation started in the background, by the id its request answered with. */
async function waitForForkCreation(parentWorkspace: string, creationId: string) {
/** Resolves to what the created fork goes without. */
async function waitForForkCreation(
parentWorkspace: string,
creationId: string,
): Promise<string[]> {
let failingSince: number | undefined;
let lastStep: string | undefined;
while (true) {
@@ -47,7 +51,7 @@ async function waitForForkCreation(parentWorkspace: string, creationId: string)
lastStep = result.step;
log.info(colors.gray(`${lastStep}...`));
}
if (result?.status === "completed") return;
if (result?.status === "completed") return result.warnings ?? [];
if (result?.status === "failed") {
throw new Error(result.error ?? "Unknown error");
}
@@ -355,7 +359,7 @@ async function createWorkspaceFork(
)
);
await wmill.importPgDatabase({
const imported = await wmill.importPgDatabase({
workspace: workspace.workspaceId,
requestBody: {
source: `datatable://${dt.name}`,
@@ -365,6 +369,9 @@ async function createWorkspaceFork(
},
});
for (const warning of imported.split("\n").slice(1)) {
log.warn(colors.yellow(` ${warning}`));
}
log.info(colors.green(` ✓ Datatable "${dt.name}" cloned.`));
forkedDatatables.push({ name: dt.name, new_dbname: newDbName });
} catch (e) {
@@ -420,8 +427,11 @@ async function createWorkspaceFork(
},
});
// A server without background forks ignores the flag and answers once the fork is created.
if (!response.startsWith("Created forked workspace")) {
await waitForForkCreation(workspace.workspaceId, response);
const warnings = response.startsWith("Created forked workspace")
? response.split("\n").slice(1)
: await waitForForkCreation(workspace.workspaceId, response);
for (const warning of warnings) {
log.warn(colors.yellow(warning));
}
log.info(colors.green(`✅ Created forked workspace ${trueWorkspaceId}`));