TL;DR
- Kafka messages reference schemas by ID, so a registry migration has to preserve the original IDs, not just copy schemas.
- Karapace IMPORT mode keeps original schema IDs and versions, skips compatibility checks, and rejects conflicting registrations.
- A migration is a sequence of Schema Registry API calls: export, check the target, enable IMPORT mode, register, reproduce soft deletes, restore compatibility, verify.
- Hard-deleted schemas and Confluent-specific features such as data contract rules aren't migrated.
Moving your Schema Registry to a new service isn't just about copying schemas. You also need to preserve the schema IDs that existing Kafka messages reference. If those IDs change, consumers might fail to deserialize messages that were written before the migration.
With the new IMPORT mode, Karapace lets you migrate schemas while preserving their original IDs and version numbers. It also rejects conflicting registrations, so existing Kafka messages can continue resolving to the correct schemas after migration.
This post explains why schema IDs make registry migration harder than it looks, how IMPORT mode solves that, and the stages of moving a registry to Aiven.
Why schema IDs are the whole problem
A producer using a registry-aware serializer (Avro, Protobuf, or JSON Schema) doesn't put the schema definition in each message. Instead, it writes a magic byte (0), a four-byte schema ID, and the serialized payload. The consumer reads that ID and asks the registry for the corresponding schema.
So every message on your topics points to a schema by its ID. That creates two challenges when migrating to a new registry:
- Re-registering schemas doesn't preserve their IDs. The new registry assigns fresh IDs. For example, your
orders-valueschema might have ID1042in the source registry but receive ID1in the target. Existing messages still reference ID1042, so consumers might retrieve the wrong schema or fail to find one. - Mirroring the
_schemastopic isn't a reliable alternative. For example, on Confluent Cloud, the Schema Registry is fully managed and its storage topic isn't accessible for replication. Confluent's docs point to the REST API instead. Even on a self-managed registry, another registry's internal topic can hold record types the target doesn't understand, and it bakes in assumptions about the cluster it came from. Copying through the API gives you more control and allows a more agnostic solution.
What you need is a registry that accepts the original ID and version for each schema and rejects conflicting registrations.
That's what IMPORT mode provides.
How Karapace IMPORT mode works
Karapace supports two modes for managing schema registrations:
READWRITE(default): Karapace assigns schema IDs and versions, deduplicates identical schemas, and enforces compatibility checks.IMPORT: You provide the original schema ID and version, and Karapace preserves them during registration.
You can enable IMPORT mode globally using PUT /mode or for individual subjects using PUT /mode/{subject}. A subject-level mode takes precedence over the global mode.
Here's what changes when a subject is in IMPORT mode:
- IDs and versions are preserved. You must provide the original schema ID, and you should always include its version. Versions can have gaps and don't need to start at
1. - Compatibility checks are skipped. Your source history can be copied as is, including breaking changes that were allowed in the past.
- Content deduplication is disabled. Identical schema content doesn't automatically collapse into an existing registration.
For example, suppose a schema has ID 1001 and version 5 in the source registry. With IMPORT mode, you can register it in Karapace using those same values, even if versions 1–4 aren't present in the target.
After registration, the subject contains version 5, not version 1, and requesting schema ID 1001 returns the imported schema. Karapace doesn't automatically renumber the version or assign a new ID.
The ID counter keeps up, too. Importing schema ID N raises the counter to at least N. Once you're back in READWRITE mode, new schemas receive IDs higher than the highest imported ID.
How Karapace prevents conflicting registrations
Incorrect schema ID mappings can cause consumers to retrieve the wrong schema when reading existing Kafka messages. Karapace includes safeguards to prevent these conflicts during migration.
In IMPORT mode, Karapace:
- Rejects attempts to associate an existing schema ID with different schema content.
- Rejects attempts to assign a different ID to an existing subject version.
- Requires an explicit schema ID and rejects registrations that supply an ID outside
IMPORTmode. - Prevents you from entering
IMPORTmode on a registry or subject with live schemas unless you explicitly override the check using?force=true.
Karapace also allows you to register the same schema with the same ID and version more than once. This makes imports idempotent, so you can resume an interrupted migration without changing schemas that were already imported.
For the complete safeguards, validation limits, and error codes, see the Karapace IMPORT mode reference.
Migrate your Schema Registry to Aiven
A migration is a sequence of Schema Registry API calls: read schemas and configuration from the source, then write them to the target with IMPORT mode enabled. The two registries never communicate directly, so you can drive the migration from any tool or machine that can reach both.
Figure: Schemas, IDs, versions, and configuration are read from the source registry and imported into Aiven Karapace through the Schema Registry API.
The most common scenario is moving an entire registry from Confluent Schema Registry or Confluent Cloud to a fresh Aiven for Apache Kafka® service.
Before you start
Before migrating, pause schema registrations, deletions, and compatibility changes on the source. Stop producers that automatically register schemas, or set auto.register.schemas=false. Keep schema changes paused until clients use the target registry, and don't register new schemas on the target subjects during migration.
An export captures the source registry at a particular point in time. If the source changes after the export, export the schemas again before importing.
Rehearse the migration against a non-production Aiven service first. Schema registrations made during import aren't automatically rolled back.
Migration stages
Whether you use your own automation or call the API by hand, a migration follows the same stages:
- Export the source: Read every subject and its versions, including each version's schema ID, schema type, and references. Include soft-deleted versions with
?deleted=true, and capture the global and per-subject compatibility levels fromGET /configandGET /config/{subject}. - Check the target: Confirm that the subjects you're importing have no live schemas on the target, and that none of the exported IDs are already used by different schema content. Resolve any conflicts before you write anything.
- Enable IMPORT mode: Use
PUT /modeto migrate a whole registry into a fresh service, orPUT /mode/{subject}for each subject when the target is already in use. Other subjects keep operating normally in the subject-level case. - Register schemas with their original IDs and versions: Send
POST /subjects/{subject}/versionswith the sourceidandversionin the request body. Register referenced schemas before the schemas that reference them. - Reproduce soft deletes and reserve unused IDs: Soft-delete the versions that were soft-deleted in the source. If the source issued IDs that no longer appear in the export because their schemas were hard-deleted, register a placeholder schema at the highest issued ID and soft-delete it, so that ID is never reused.
- Restore compatibility settings: Apply the exported levels with
PUT /configandPUT /config/{subject}. A subject-scoped migration shouldn't overwrite the target's global level, so compare it with the source instead. - Verify and leave IMPORT mode: Compare the imported IDs and versions with the export. Then return the registry to
READWRITEmode withPUT /mode, or remove the subject-level overrides withDELETE /mode/{subject}.
Reserving the highest issued ID matters more than it might seem. Suppose the source's highest issued ID was 1500, but the highest ID in the export is 1400. Without a reservation, the target could eventually assign ID 1500 to an unrelated schema, and existing messages that reference it would resolve to the wrong schema.
For a whole-registry migration, these stages preserve:
- Subjects, schema versions, and their original IDs.
- Soft-deleted versions, including their deleted status.
- The global compatibility level and per-subject compatibility overrides.
Hard-deleted schemas and unsupported Confluent-specific features aren't included in the migration.
If a target subject already has schemas, ?force=true lets you enter IMPORT mode anyway. It doesn't delete existing schemas or allow conflicting ID and version mappings, so only use it after the target check reports no conflicts.
Want a starting point? The Karapace repository includes an example migration script that implements these stages, with a check and confirmation before each one. Treat it as a reference you can adapt to your own tooling.
For more migration options, including advanced scenarios and troubleshooting, see Migrate schemas with IMPORT mode.
Verify before switching clients
The last migration stage compares the imported schema IDs and versions with the export. Before switching clients, run a few additional checks:
- Check registry mode: Confirm that the target registry is back in
READWRITEmode and that no imported subjects remain inIMPORTmode. - Verify schemas: Spot-check schema IDs, versions, and soft-deleted versions against the source.
- Check compatibility: Confirm that compatibility settings were restored as expected. You can also use the compatibility API to check that compatibility rules are enforced again without registering a new schema.
- Test existing messages: Run a consumer against existing Kafka messages using the Aiven Schema Registry. Include a topic whose schemas use references if your applications rely on them.
If existing messages deserialize successfully, you've confirmed that their IDs resolve to the expected schemas in the target registry.
Once verification is complete, update your producers' and consumers' schema.registry.url and credentials to point to Aiven. Restart the producers you paused and resume schema changes against the target.
Keep the source registry running until you've confirmed that all clients work correctly with Aiven. Switching back becomes more complicated once new schemas are registered on the target.
Remember that this migration moves schemas, not Kafka topics or messages. If you're also moving Kafka data to Aiven, plan both cutovers together.
Migration limitations and recovery
There are a few limitations and recovery considerations worth knowing.
Hard-deleted schemas can't be migrated. They're no longer available through the source registry API. Reserving the source's highest issued ID prevents previously issued IDs from being reused, but it doesn't recover deleted schema content.
Some Confluent-specific features aren't preserved. Karapace accepts schema metadata and ruleSet fields but discards them, so data contract rules don't carry over. Confluent contexts and schema exporters aren't migrated either. Review these differences if your applications depend on them.
Karapace doesn't support READONLY mode. To prevent schema changes during migration, pause schema registrations and producers that automatically register schemas.
Interrupted migrations can be resumed. Imports are idempotent: registering the same schema with the same ID and version again succeeds without changes. If a migration stops, resolve the error and repeat the remaining steps. Before resuming normal operations, check that no subject is still in IMPORT mode.
For complete troubleshooting guidance, see the Aiven migration documentation.
Wrapping up
With Karapace IMPORT mode, you can migrate schemas to Aiven for Apache Kafka while preserving their original IDs, versions, and supported schema history. Each stage is a standard Schema Registry API call, so the migration fits into the tooling and change processes you already use.
Before migrating production schemas, rehearse the process on a non-production service and verify that existing messages deserialize correctly.
For more information:


