/avro-schema-evolution

some very basic avro schemas and evolving them with the confluent schema registry

Primary LanguageShell

avro schema evolution examples

A very basic example of how to evolve an avro schema (assumes backwards compatibility)

setup

The confluent avro schema registry should be installed and running. The confluent cli tool make this painless.

$ confluent start schema-registry
Starting zookeeper
zookeeper is [UP]
Starting kafka
kafka is [UP]
Starting schema-registry
schema-registry is [UP]

$ confluent status schema-registry
schema-registry is [UP]
kafka is [UP]
zookeeper is [UP]

Ensure jq is installed and available within your PATH

example setting schema subject compatibility

bin/compatibility-set FULL_TRANSITIVE test http://localhost:8081
# {"compatibility":"FULL_TRANSITIVE"}

example getting schema subject compatibility

bin/compatibility-get test http://localhost:8081
# {"compatibilityLevel":"FULL_TRANSITIVE"}

example registration

bin/register schemas/test/s001.avsc test http://localhost:8081
# {"id":1}

evolve all schemas

SUBJECT=test
for VERSION in $(seq -f "%03g" 1 10); do
    bin/register "schemas/test/s${VERSION}.avsc" "$SUBJECT" "http://localhost:8081"
done