Skip to content

How to write a migration

Pere Urbón edited this page Aug 14, 2019 · 1 revision

How to write a migration

The tool currently supports migration changes written in yaml format. You can see a few examples of the required format in this page.

As of current version is required the first line of the migration contains the type:

  • type: schema-registry for changes happening to the Confluent Schema Registry
  • type: broker for changes directly to an Apache Kafka cluster

Current migration types supported

Confluent Schema Registry

Create a new schema

type: schema-registry
action: register
data: "{\"schema\": \"{\\\"type\\\": \\\"string\\\"}\"}"
subject: "Kafka-key2"

Delete an schema version

type: schema-registry
action: delete
id: latest
subject: "Kafka-key2"

or

type: schema-registry
action: delete
id: 3
subject: "Kafka-key2"

Set global compatibility level

type: schema-registry
action: set_top_level_compatibility
data: "{\"compatibility\":\"NONE\"}"

Apache Kafka

Topic creation

type: broker
action: create-topic
topic: foo
config:
  numPartitions: 1
  replicationFactor: 1

Topic delete

type: broker
action: delete-topic
topic: foo

Were should you save your migrations

In the feature, this will change, but as of the current version the migrations are stored in the local file system. You will need to place them in a shared directory that the tool will use to read and apply them in order.

The recommend way to name the file is: [timestamp]_migration-name.yml

The tool will read the files in chronological order, from this the need of having the timestamp first to keep the changes in order.