Created on 11-09-201804:11 AM - edited 08-17-201905:50 AM
In this article, let us take a look at how to delete a schema from the Hortonworks Schema Registry.
Let me start with a word of caution that the approach is not recommended for Production systems and use these steps at your own risk. Also, would like to thank Brian Goerlitz for his ideas towards this post.
Currently it is not possible to delete a schema from the UI. So the steps below shows how to delete the schema from its backend datastore. I am using MySQL as my backend datastore for the schema registry and the queries will be related to MySQL. You should change them according to your database type.
Step 1 Verify that the two tables schema_version_info and schema_field_info have CASCADE ON UPDATE and CASCADE ON DELETE enabled.
This can be done by the below queries on information_schema database
select UPDATE_RULE,DELETE_RULE,REFERENCED_TABLE_NAME from REFERENTIAL_CONSTRAINTS where table_name='schema_version_info';
select UPDATE_RULE,DELETE_RULE,REFERENCED_TABLE_NAME from REFERENTIAL_CONSTRAINTS where table_name='schema_field_info';
Step 2 Stop Schema Registry Service from Ambari
Step 3 Backup the database
Below is the content of my schema registry before the delete operation and I am interested in deleting the person.demographic.details schema
Step 4 Identify the id of the schema to be deleted.
For this, you need to switch to the database provisioned to store the schema registry information. In my case it is 'registry' and issue the select query.
select id from schema_metadata_info where name ='person.demographic.details';
Step 5 Delete the schema from schema_serdes_mapping based on the id we queried in step 4 above
delete from schema_serdes_mapping where schemaMetadataId=1;
Step 6 Delete the schema from schema_metadata_info based on the id we queried in step 4 above
delete from schema_metadata_info where id =1;
We observe that the schema has been deleted from the tables.
Step 7 Start the schema registry service via Ambari, and verify that the schema is deleted.
Optionally we can recreate the schema with the same name on the UI and explore the front-end and back-end to ensure the schema can be re-created with no issues.
We observe that the new schema was created with the same name and a different id.