I have register a post meta field called project_description with it's explicit 'schema' in register_post_meta function. The following is register_post_meta function -
function register_project_description_post_meta() {
register_block_type( plugin_dir_path( __FILE__) . 'build/project-description' );
register_post_meta('project', 'project_description', array(
'single' => true,
'type' => 'object',
'show_in_rest' => array(
'schema' => array(
'type' =>'object',
'properties' => array(
'excerpt' => array(
'type' => 'object',
'properties' => array(
'title' => array(
'type' => 'string'
),
'description' => array(
'type' => 'string'
)
)
),
'responsive' => array(
'type' => 'object',
'properties' => array(
'title' => array(
'type' => 'string'
),
'description' => array(
'type' => 'string'
),
'image' => array(
'type' => 'string',
'properties' => array(
'id' => array(
'type' => 'integer'
),
'url' => array(
'type' => 'string'
)
)
)
)
)
)
)
)
));
}
Now when I change the image property with type string instead of object I get project_description: null
when calling REST API in Postman.
So I want to know is there a way to change the schema when a post already has that meta field. That is, after the schema change the meta field should look like this -
project_description: {
excerpt: {
title: '',
description: '',
},
responsive: {
title: '',
description: '',
image: ''
}
}
instead of
project_description: {
excerpt: {
title: '',
description: '',
},
responsive: {
title: '',
description: '',
image: {
id: '',
url: ''
}
}
}