diff --git a/backend/windmill-api/src/workspaces_extra.rs b/backend/windmill-api/src/workspaces_extra.rs index 8dfbc5c0b2..3c66723834 100644 --- a/backend/windmill-api/src/workspaces_extra.rs +++ b/backend/windmill-api/src/workspaces_extra.rs @@ -47,15 +47,6 @@ fn default_batch_size() -> i64 { DEFAULT_BATCH_SIZE } -#[derive(Default, Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] -#[serde(rename_all(serialize = "lowercase", deserialize = "lowercase"))] -pub enum MigrationType { - #[default] - All, - Metadata, - Jobs, -} - #[derive(Deserialize)] pub(crate) struct DeleteWorkspaceQuery { pub(crate) only_delete_forks: Option, diff --git a/frontend/src/lib/components/settings/ChangeWorkspaceId.svelte b/frontend/src/lib/components/settings/ChangeWorkspaceId.svelte index 1e0156a497..6bd61ce5f5 100644 --- a/frontend/src/lib/components/settings/ChangeWorkspaceId.svelte +++ b/frontend/src/lib/components/settings/ChangeWorkspaceId.svelte @@ -7,7 +7,7 @@ import Modal from '../common/modal/Modal.svelte' import { Pen, Loader2 } from 'lucide-svelte' import { isCloudHosted } from '$lib/cloud' - import { onDestroy, onMount } from 'svelte' + import { onDestroy } from 'svelte' import { hubPaths } from '$lib/hub' let { open = $bindable(false) } = $props() @@ -44,7 +44,6 @@ let metadataMigrated = $state(false) let oldWorkspaceId = $state('') - let jobMigrationStarted = $state(false) let jobMigrationJobId = $state(undefined) let migratingJobs = $state(false) let jobMigrationComplete = $state(false) @@ -84,10 +83,6 @@ } } - onMount(() => { - checkForIncompleteMigration() - }) - async function migrateMetadata() { try { loading = true @@ -102,7 +97,6 @@ }) metadataMigrated = true - // Keep modal open to show step 2 sendUserToast(`Workspace metadata migrated to ${newId}`) } catch (err: any) { @@ -116,18 +110,20 @@ if (!jobMigrationJobId) return try { - const result = await JobService.getCompletedJob({ + const jobResult = await JobService.getCompletedJobResultMaybe({ workspace: newId, id: jobMigrationJobId }) - const jobSuccess = !!result.success - if (!jobSuccess) { - throw Error('err') + if (jobResult.completed) { + migratingJobs = false + stopPolling() + if (jobResult.success) { + jobMigrationComplete = true + sendUserToast('Job migration completed!') + } else { + throw Error(JSON.stringify(jobResult.result)) + } } - jobMigrationComplete = true - migratingJobs = false - stopPolling() - sendUserToast('Job migration completed!') } catch (err: any) { stopPolling() migratingJobs = false @@ -150,8 +146,6 @@ } }) - jobMigrationStarted = true - startPolling() } catch (err: any) { sendUserToast(`Migration failed: ${err.body || err.message}`, true) @@ -217,31 +211,7 @@ } } - async function completeMigration() { - if (!incompleteMigration) return - - try { - loading = true - - await WorkspaceService.completeWorkspaceMigration({ - requestBody: { - source_workspace_id: incompleteMigration.sourceWorkspaceId, - target_workspace_id: incompleteMigration.targetWorkspaceId - } - }) - - sendUserToast('Migration completed successfully!') - - window.location.href = `/workspace_settings?tab=general&workspace=${incompleteMigration.targetWorkspaceId}` - } catch (err: any) { - sendUserToast(`Failed to complete migration: ${err.body || err.message}`, true) - } finally { - loading = false - } - } - async function revertMigration() { - // Handle both incomplete migration and post-step-1 revert cases const sourceWorkspaceId = incompleteMigration?.sourceWorkspaceId || oldWorkspaceId const targetWorkspaceId = incompleteMigration?.targetWorkspaceId || newId @@ -259,10 +229,9 @@ sendUserToast('Migration reverted successfully!') - // Reset all state and form values incompleteMigration = null metadataMigrated = false - jobMigrationStarted = false + migratingJobs = false jobMigrationComplete = false newName = '' newId = '' @@ -287,6 +256,7 @@ {#if !isCloudHosted() || $superadmin} + {:else if migratingJobs} + + {:else if incompleteMigration}
{:else if !metadataMigrated} @@ -449,9 +506,7 @@ > Step 1: Migrate Metadata - + {:else if metadataMigrated && !jobMigrationComplete}
@@ -481,157 +536,6 @@ Revert
- {:else} -
- - -
{/if} - -{#if migratingJobs} - -
-
-
- -
-

Migration in Progress

-

This process may take several minutes depending on job history size

-
-
-
-
-
-
- -
-
-
- Metadata migration completed -
-
-
- Migrating job history and results... -
-
-
- Authentication tables transfer (pending) -
-
- -
-

Migration Details

-
-

From: {oldWorkspaceId}

-

To: {newId}

-
-
- - -

- Please do not close this window or navigate away during the migration process. This - ensures data integrity and allows proper completion tracking. -

-
-
- - - -
-{/if} - -{#if jobMigrationComplete} - -
-
-
- ✓ -
-

- Migration Successful! -

-

- All data has been successfully migrated to your new workspace -

-
- -
-

Migration Summary

-
-
-
- Workspace metadata migrated -
-
-
- Job history and results migrated -
-
-
- Ready for final workspace switch -
-
-
- -
-
-

Old Workspace

-

{oldWorkspaceId}

-

Will be deleted

-
-
-

New Workspace

-

{newId}

-

Ready to use

-
-
- - -

- Click the button below to complete the migration process. This will transfer - authentication tables, delete the old workspace, and redirect you to the new workspace. -

-
-
- - - -
-{/if}