From 8321cccf192c74cf11a7a5cc36f0a70d3d04bf41 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Fri, 27 Mar 2026 10:53:06 +0100 Subject: [PATCH] refactor: type DataTable.forked_from as DataTableForkedFrom struct Co-Authored-By: Claude Opus 4.5 --- .../src/workspaces_extra.rs | 2 +- backend/windmill-common/src/workspaces.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backend/windmill-api-workspaces/src/workspaces_extra.rs b/backend/windmill-api-workspaces/src/workspaces_extra.rs index c4b99c1f60..f350bdd730 100644 --- a/backend/windmill-api-workspaces/src/workspaces_extra.rs +++ b/backend/windmill-api-workspaces/src/workspaces_extra.rs @@ -902,7 +902,7 @@ async fn drop_forked_datatable_databases( if let Err(e) = windmill_common::drop_custom_instance_database(db, db_to_drop).await { tracing::error!("Failed to drop instance database '{}': {}", db_to_drop, e); } - } else if let Some(original_resource) = forked_from.get("original_resource") { + } else if let Some(original_resource) = &forked_from.original_resource { // Connect to the original resource's database to run DROP on the forked db let pg = match serde_json::from_value::(original_resource.clone()) { Ok(pg) => pg, diff --git a/backend/windmill-common/src/workspaces.rs b/backend/windmill-common/src/workspaces.rs index 06fb4e4820..947664b50a 100644 --- a/backend/windmill-common/src/workspaces.rs +++ b/backend/windmill-common/src/workspaces.rs @@ -407,7 +407,20 @@ impl Default for DataTableForkBehavior { pub struct DataTable { pub database: DataTableDatabase, #[serde(default, skip_serializing_if = "Option::is_none")] - pub forked_from: Option, + pub forked_from: Option, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct DataTableForkedFrom { + /// Original instance database name (instance datatables only) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub original_dbname: Option, + /// Original resource value before fork (resource datatables only) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub original_resource: Option, + /// Schema snapshot at fork time + #[serde(default, skip_serializing_if = "Option::is_none")] + pub schema: Option, } #[derive(Deserialize, Serialize, Debug)]