1 | import wmill from "windmill-cli"; |
2 |
|
3 |
|
4 |
|
5 | export async function main(source_workspace_id: string, target_workspace_id: string) { |
6 |
|
7 | console.log(`Starting migration of jobs from ${source_workspace_id} to ${target_workspace_id}`); |
8 |
|
9 | try { |
10 | const cmd = [ |
11 | "workspace", |
12 | "migrate", |
13 | target_workspace_id, |
14 | "--token", |
15 | process.env["WM_TOKEN"] ?? "", |
16 | "--remote", |
17 | process.env["BASE_URL"] ?? "", |
18 | "--source-workspace", |
19 | source_workspace_id |
20 | ]; |
21 |
|
22 | console.log("Running CLI command:", cmd.join(" ")); |
23 | await wmill.parse(cmd); |
24 |
|
25 | console.log(`Successfully migrated jobs from ${source_workspace_id} to ${target_workspace_id}`); |
26 |
|
27 | return { |
28 | success: true, |
29 | message: `Jobs migration completed from ${source_workspace_id} to ${target_workspace_id}`, |
30 | source_workspace_id, |
31 | target_workspace_id, |
32 | }; |
33 | } catch (error) { |
34 | console.error("Migration failed:", error); |
35 | throw new Error(`Migration failed: ${error}`); |
36 | } |
37 | } |