Description
Replicator provides a Schema Migration feature which supports replicating an entire Schema Registry environment to another (empty) Schema Registry cluster, preserving all schema ID and version information. In some cases, however, you might have a need to manually migrate individual subject(s) between Schema Registry clusters, instead of an entire environment. This article describes how to perform a subject-level migration.
This can also be used to manually register a schema at a specified ID on a Schema Registry. This assumes that the schema ID is not already taken, and is useful in recovery operations when a schema was deleted but is backed up on another cluster.
Applies To
Confluent Platform 5.5.1+
Confluent Cloud
Cause
When you only want to replicate individual subjects/schemas between Schema Registry environments, preserving IDs and version information, instead of migrating the entire environment from scratch.
Resolution
Note: These steps only work for subjects that are empty or non-existent, you cannot use the Schema Registry API to provide a schema ID for a schema that already exists in the Schema registry. If required, you can delete an existing subject to allow importing new schemas by ID and version. For example:
#Soft delete
curl -X DELETE "http://localhost:8081/mode/test-value"
#Hard delete
curl -X DELETE "http://localhost:8081/mode/test-value?permanent=true"
1. Ensure that mode.mutability=true
in SR properties (only applicable for self-managed Schema Registry)
2. Put the subject into IMPORT
mode (the subject must be empty or non-existent to do this):
curl -X PUT -H "Content-Type: application/json" "http://localhost:8081/mode/test-value" --data '{"mode": "IMPORT"}'
3. Register schema(s) for that subject, providing schema ID and version:
curl -X POST -H "Content-Type: application/json" \
--data '{"schemaType": "AVRO", "version":1, "id":24, "schema":"{\"type\":\"record\",\"name\":\"value_a1\",\"namespace\":\"com.mycorp.mynamespace\",\"fields\":[{\"name\":\"field1\",\"type\":\"string\"}]}" }' \
http://localhost:8081/subjects/test-value/versions
READWRITE
mode:curl -X PUT -H "Content-Type: application/json" "http://localhost:8081/mode/test-value" --data '{"mode": "READWRITE"}'