refactor: type DataTable.forked_from as DataTableForkedFrom struct

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Diego Imbert
2026-03-27 10:53:06 +01:00
parent bef700b5cf
commit 8321cccf19
2 changed files with 15 additions and 2 deletions

View File

@@ -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::<PgDatabase>(original_resource.clone()) {
Ok(pg) => pg,

View File

@@ -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<serde_json::Value>,
pub forked_from: Option<DataTableForkedFrom>,
}
#[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<String>,
/// Original resource value before fork (resource datatables only)
#[serde(default, skip_serializing_if = "Option::is_none")]
pub original_resource: Option<serde_json::Value>,
/// Schema snapshot at fork time
#[serde(default, skip_serializing_if = "Option::is_none")]
pub schema: Option<serde_json::Value>,
}
#[derive(Deserialize, Serialize, Debug)]