feat: tag forked datatables with nonDiffable and forkedFrom
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1608,6 +1608,8 @@ async fn fork_datatable(
|
||||
resource_type: DataTableCatalogResourceType::Instance,
|
||||
resource_path: new_dbname.clone(),
|
||||
},
|
||||
non_diffable: true,
|
||||
forked_from: Some(original_dbname.clone()),
|
||||
};
|
||||
let datatable_value: serde_json::Value =
|
||||
serde_json::to_value(&new_datatable).map_err(|err| Error::internal_err(err.to_string()))?;
|
||||
@@ -1710,6 +1712,27 @@ async fn fork_resource_datatable(
|
||||
.execute(db)
|
||||
.await?;
|
||||
|
||||
// Tag the datatable config as non_diffable with forked_from info
|
||||
let forked_from_value = format!("$res:{}", resource_path);
|
||||
let tag_json = serde_json::json!({
|
||||
"nonDiffable": true,
|
||||
"forkedFrom": forked_from_value
|
||||
});
|
||||
sqlx::query!(
|
||||
r#"UPDATE workspace_settings
|
||||
SET datatable = jsonb_set(
|
||||
COALESCE(datatable, '{"datatables":{}}'::jsonb),
|
||||
ARRAY['datatables', $1],
|
||||
COALESCE(datatable->'datatables'->$1, '{}'::jsonb) || $2
|
||||
)
|
||||
WHERE workspace_id = $3"#,
|
||||
datatable_name,
|
||||
tag_json,
|
||||
target_workspace_id
|
||||
)
|
||||
.execute(db)
|
||||
.await?;
|
||||
|
||||
tracing::info!(
|
||||
"Forked resource datatable '{}': created database '{}' from '{}'",
|
||||
datatable_name,
|
||||
|
||||
@@ -404,8 +404,13 @@ impl Default for DataTableForkBehavior {
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DataTable {
|
||||
pub database: DataTableDatabase,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub non_diffable: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub forked_from: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user