Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Query Agent

Run agentic search over your Weaviate Cloud collections

Weaviate Cloud

Manage and scale Weaviate in the cloud

Engram

Persistent memory for LLM agents and applications

Additional resources

Integrations
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Support
Community Forum
Contributor guide

Zero-downtime collection migration with aliases

In this tutorial, we will explore how to use collection aliases in Weaviate to perform zero-downtime migrations. Collection aliases are alternative names for Weaviate collections that allow you to reference a collection by multiple names. This powerful feature enables you to migrate to new collection schemas, update configurations, or reorganize your data without any service interruption.

Prerequisites​

Before starting this tutorial, ensure you have the following:

  • An instance of Weaviate (e.g. on Weaviate Cloud, or locally), version v1.32 or newer.
  • Your preferred Weaviate client library installed.
  • Basic familiarity with Weaviate collections and data import.
See the Quickstart guide

For information on how to set up Weaviate and install the client library, see the cloud or local Quickstart guide.

Introduction​

Traditional collection migrations require significant downtime. The typical workflow involves:

  1. Creating a new collection
  2. Stopping your application
  3. Migrating data
  4. Updating all collection references in your code
  5. Restarting your application

This process causes service interruption and requires code changes. With aliases, you can eliminate both issues.

What are collection aliases?​

A collection alias is a pointer to an underlying collection. When you query using an alias, Weaviate automatically routes the request to the target collection. Think of it like a symbolic link in a file system or a DNS alias for a website.

Collection alias concept visualization

Collection aliases are ideal for schema migrations (updating properties or vectorization settings), A/B testing, and disaster recovery. They add minimal routing overhead and enable instant switching between collection versions without code changes.

Collection alias usage

Weaviate automatically routes alias requests to the target collection for object-related operations. You can use aliases wherever collection names are required for:

How aliases enable zero-downtime migration​

Aliases allow you to keep your application code unchanged as it references the stable alias name. You can switch between collections instantly and roll back quickly if needed.

The migration process becomes:

  1. Create a new collection with updated schema
  2. Migrate data (while the old collection serves traffic)
  3. Update the alias to point to the new collection (instant switch)
  4. Delete the old collection after verification

Tutorial: Migrating a products collection​

Let's walk through a complete migration scenario where we need to add a new field to an existing collection of products.

Step 1: Connect to Weaviate​

First, connect to your Weaviate instance using your preferred client library.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Connect to local Weaviate instance
client = weaviate.connect_to_local()
// Connect to local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal()
// Connect to local Weaviate instance
config := weaviate.Config{
Scheme: "http",
Host: "localhost:8080",
}
client, err := weaviate.NewClient(config)
require.NoError(t, err)
ctx := context.Background()
client, err := weaviate.NewLocal(ctx)
if err != nil {
// handle error
panic(err)
}
defer client.Close()
// Connect to local Weaviate instance
client = WeaviateClient.connectToLocal();
// Connect to local Weaviate instance
client = await Connect.Local();

Step 2: Create the original collection​

Let's create our initial products collection and populate it with data.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Create original collection with data
client.collections.create(
name="Products_v1", vector_config=wvc.config.Configure.Vectors.self_provided()
)

products_v1 = client.collections.use("Products_v1")
products_v1.data.insert_many(
[{"name": "Product A", "price": 100}, {"name": "Product B", "price": 200}]
)
// Create original collection with data
await client.collections.create({
name: "Products_v1",
vectorizers: weaviate.configure.vectors.selfProvided()
})

const products_v1 = client.collections.use("Products_v1")

await products_v1.data.insertMany([
{ "name": "Product A", "price": 100 },
{ "name": "Product B", "price": 200 }
])
// Create original collection with data
err := client.Schema().ClassCreator().WithClass(&models.Class{
Class: "Products_v1",
Vectorizer: "none",
}).Do(ctx)

require.NoError(t, err)

// Insert data into Products_v1
objects := []*models.Object{
{
Class: "Products_v1",
Properties: map[string]interface{}{
"name": "Product A",
"price": 100,
},
},
{
Class: "Products_v1",
Properties: map[string]interface{}{
"name": "Product B",
"price": 200,
},
},
}

_, err = client.Batch().ObjectsBatcher().
WithObjects(objects...).
Do(ctx)

require.NoError(t, err)
// Create the original collection and add some products.
if _, err := client.Collections.Create(ctx, collections.Collection{
Name: "Products_v1",
Properties: []collections.Property{
{Name: "name", DataType: collections.DataTypeText},
{Name: "price", DataType: collections.DataTypeNumber},
},
}); err != nil {
// handle error
panic(err)
}

productsV1 := client.Collections.Use("Products_v1")
productA := uuid.MustParse("a1a2a3a4-b1b2-4c00-8d00-e1e2e3e4e5e6")
productB := uuid.MustParse("b1b2b3b4-c1c2-4d00-8e00-f1f2f3f4f5f6")
if _, err := productsV1.Data.Insert(ctx,
&data.Object{UUID: &productA, Properties: map[string]any{"name": "Product A", "price": 100}},
&data.Object{UUID: &productB, Properties: map[string]any{"name": "Product B", "price": 200}},
); err != nil {
// handle error
panic(err)
}
// Create original collection with data
client.collections.create("Products_v1", col -> col.vectorConfig(VectorConfig.selfProvided())
.properties(Property.text("name"), Property.number("price")));

var productsV1 = client.collections.use("Products_v1");
productsV1.data.insertMany(Map.of("name", "Product A", "price", 100.0),
Map.of("name", "Product B", "price", 200.0));
// Create original collection with data
await client.Collections.Create(
new CollectionCreateParams
{
Name = ProductsV1,
VectorConfig = Configure.Vector("default", v => v.Text2VecTransformers()),
}
);

var productsV1 = client.Collections.Use(ProductsV1);

// Batch insert works best with anonymous objects here
await productsV1.Data.InsertMany(
new[]
{
new { name = "Product A", price = 100 },
new { name = "Product B", price = 200 },
}
);

Step 3: Create an alias for production access​

Now create an alias that your application will use. This decouples your application code from the specific collection version.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Create alias pointing to current collection
client.alias.create(alias_name="ProductsAlias", target_collection="Products_v1")
// Create alias pointing to current collection
await client.alias.create({
alias: "ProductsAlias",
collection: "Products_v1"
})
// Create alias pointing to current collection
err = client.Alias().AliasCreator().WithAlias(&alias.Alias{
Alias: "Products",
Class: "Products_v1",
}).Do(ctx)

require.NoError(t, err)
// Point an alias at the current collection. Your application uses this alias.
if err := client.Alias.Create(ctx, collections.Alias{
Alias: "ProductsAlias",
Collection: "Products_v1",
}); err != nil {
// handle error
panic(err)
}
// Create alias pointing to current collection
client.alias.create("Products_v1", "ProductsAlias");
// Create alias pointing to current collection
await client.Alias.Create(ProductsAlias, ProductsV1);

Step 4: Use the alias in your application​

Your application code should reference the alias, not the underlying collection. This ensures it continues working regardless of which collection version is active.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Your application always uses the alias name "Products"
products = client.collections.use("ProductsAlias")

# Insert data through the alias
products.data.insert({"name": "Product C", "price": 300})

# Query through the alias
results = products.query.fetch_objects(limit=5)
for obj in results.objects:
print(f"Product: {obj.properties['name']}, Price: ${obj.properties['price']}")
// Your application always uses the alias name "Products"
const prods = client.collections.use("ProductsAlias");

// Insert data through the alias
await prods.data.insert({ name: "Product C", price: 300 });

// Query through the alias
const res = await prods.query.fetchObjects({ limit: 5 });
for (const obj of res.objects) {
console.log(`Product: ${obj.properties.name}, Price: $${obj.properties.price}`);
}
// Your application always uses the alias name "Products"
// Insert data through the alias
_, err = client.Data().Creator().WithClassName("Products").WithProperties(map[string]interface{}{
"name": "Product C",
"price": 300,
}).Do(ctx)
require.NoError(t, err)

// Query through the alias
resp, err := client.Data().ObjectsGetter().WithClassName("Products").WithLimit(5).Do(ctx)
require.NoError(t, err)
for _, obj := range resp {
props := obj.Properties.(map[string]interface{})
t.Logf("Product: %v, Price: $%v", props["name"], props["price"])
}
// Application code refers only to the alias, never the underlying collection.
products := client.Collections.Use("ProductsAlias")

// Insert data through the alias.
productC := uuid.MustParse("c1c2c3c4-d1d2-4e00-8f00-a1a2a3a4a5a6")
if _, err := products.Data.Insert(ctx,
&data.Object{UUID: &productC, Properties: map[string]any{"name": "Product C", "price": 300}},
); err != nil {
// handle error
panic(err)
}

// Query through the alias.
response, err := products.Query.OverAll(ctx, query.OverAll{Limit: 5})
if err != nil {
// handle error
panic(err)
}
for _, obj := range response.Objects {
fmt.Printf("Product: %v, Price: %v\n", obj.Properties["name"], obj.Properties["price"])
}
// Your application always uses the alias name
CollectionHandle<Map<String, Object>> products = client.collections.use("ProductsAlias");

// Insert data through the alias
products.data.insert(Map.of("name", "Product C", "price", 300.0));

// Query through the alias
var results = products.query.fetchObjects(q -> q.limit(5));
for (var obj : results.objects()) {
System.out.printf("Product: %s, Price: $%.2f\n", obj.properties().get("name"),
obj.properties().get("price"));
}
// Your application always uses the alias name "Products"
var products = client.Collections.Use(ProductsAlias);

// Insert data through the alias
await products.Data.Insert(new { name = "Product C", price = 300 });

// Query through the alias
var results = await products.Query.FetchObjects(limit: 5);
foreach (var obj in results.Objects)
{
Console.WriteLine(
$"Product: {obj.Properties["name"]}, Price: ${obj.Properties["price"]}"
);
}

The key point is that your application code doesn't need to know whether it's accessing Products_v1 or Products_v2 - it just uses the stable alias name.

Step 5: Create the new collection with updated schema​

Now let's create a new version of the collection with an additional field (e.g., adding a category property).

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Create new collection with updated schema
client.collections.create(
name="Products_v2",
vector_config=wvc.config.Configure.Vectors.self_provided(),
properties=[
wvc.config.Property(name="name", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(name="price", data_type=wvc.config.DataType.NUMBER),
wvc.config.Property(
name="category", data_type=wvc.config.DataType.TEXT
), # New field
],
)
// Create new collection with updated schema
await client.collections.create({
name: "Products_v2",
vectorizers: weaviate.configure.vectors.selfProvided(),
properties: [
{ name: "name", dataType: weaviate.configure.dataType.TEXT },
{ name: "price", dataType: weaviate.configure.dataType.NUMBER },
{ name: "category", dataType: weaviate.configure.dataType.TEXT }, // New field
],
})
// Create new collection with updated schema
err = client.Schema().ClassCreator().WithClass(&models.Class{
Class: "Products_v2",
Vectorizer: "none",
Properties: []*models.Property{
{Name: "name", DataType: schema.DataTypeText.PropString()},
{Name: "price", DataType: schema.DataTypeNumber.PropString()},
{Name: "category", DataType: schema.DataTypeText.PropString()}, // New field
},
}).Do(ctx)

require.NoError(t, err)
// Create the new collection version, adding a "category" property.
if _, err := client.Collections.Create(ctx, collections.Collection{
Name: "Products_v2",
Properties: []collections.Property{
{Name: "name", DataType: collections.DataTypeText},
{Name: "price", DataType: collections.DataTypeNumber},
{Name: "category", DataType: collections.DataTypeText}, // New field
},
}); err != nil {
// handle error
panic(err)
}
// Create new collection with updated schema
client.collections.create("Products_v2", col -> col.vectorConfig(VectorConfig.selfProvided())
.properties(Property.text("name"), Property.number("price"), Property.text("category") // New field
));
// Create new collection with updated schema
await client.Collections.Create(
new CollectionCreateParams
{
Name = ProductsV2,
VectorConfig = Configure.Vector("default", v => v.SelfProvided()),
Properties =
[
Property.Text("name"),
Property.Number("price"),
Property.Text("category"), // New field
],
}
);

Step 6: Migrate data to the new collection​

Copy data from the old collection to the new one, adding default values for new fields or transforming data as needed.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Migrate data to new collection
products_v2 = client.collections.use("Products_v2")
old_data = products_v1.query.fetch_objects().objects

for obj in old_data:
products_v2.data.insert(
{
"name": obj.properties["name"],
"price": obj.properties["price"],
"category": "General", # Default value for new field
}
)
// Migrate data to new collection
const products_v2 = client.collections.use("Products_v2")
const oldData = (await products_v1.query.fetchObjects()).objects

for (const obj of oldData) {
await products_v2.data.insert({
"name": obj.properties["name"],
"price": obj.properties["price"],
"category": "General", // Default value for new field
})
}
// Migrate data to new collection
oldData, err := client.Data().ObjectsGetter().
WithClassName("Products_v1").
Do(ctx)

require.NoError(t, err)

for _, obj := range oldData {
props := obj.Properties.(map[string]interface{})
_, err = client.Data().Creator().
WithClassName("Products_v2").
WithProperties(map[string]interface{}{
"name": props["name"],
"price": props["price"],
"category": "General", // Default value for new field
}).Do(ctx)

require.NoError(t, err)
}
// Copy every object into the new collection, adding a default value for the
// new "category" field and preserving each object's id.
productsV2 := client.Collections.Use("Products_v2")
oldData, err := productsV1.Query.OverAll(ctx, query.OverAll{Limit: 100})
if err != nil {
// handle error
panic(err)
}
for _, obj := range oldData.Objects {
uid := obj.UUID
if _, err := productsV2.Data.Insert(ctx, &data.Object{
UUID: &uid,
Properties: map[string]any{
"name": obj.Properties["name"],
"price": obj.Properties["price"],
"category": "General", // Default value for the new field
},
}); err != nil {
// handle error
panic(err)
}
}
// Migrate data to new collection
var productsV2 = client.collections.use("Products_v2");
var oldData = productsV1.query.fetchObjects(c -> c.limit(10)).objects();

List<Map<String, Object>> migratedObjects = new ArrayList<>();
for (var obj : oldData) {
migratedObjects.add(Map.of("name", obj.properties().get("name"), "price",
obj.properties().get("price"), "category", "General" // Default value for new field
));
}
productsV2.data.insertMany(migratedObjects.toArray(new Map[0]));
// Migrate data to new collection
var productsV2 = client.Collections.Use(ProductsV2);
var oldData = (await productsV1.Query.FetchObjects()).Objects;

foreach (var obj in oldData)
{
// Convert property values to primitives (string, double, etc.) explicitly.
await productsV2.Data.Insert(
new
{
name = obj.Properties["name"].ToString(),
price = Convert.ToDouble(obj.Properties["price"].ToString()),
category = "General",
}
);
}

Step 7: Update the alias (instant switch)​

This is the magic moment - update the alias to point to the new collection. This switch is instantaneous, and all queries using the ProductsAlias alias now access the new collection.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Switch alias to new collection (instant switch!)
client.alias.update(alias_name="ProductsAlias", new_target_collection="Products_v2")

# All queries using "Products" alias now use the new collection
products = client.collections.use("ProductsAlias")
result = products.query.fetch_objects(limit=1)
print(result.objects[0].properties) # Will include the new "category" field
// Switch alias to new collection (instant switch!)
await client.alias.update({
alias: "ProductsAlias",
newTargetCollection: "Products_v2"
})

// All queries using "ProductsAlias" alias now use the new collection
const products = client.collections.use("ProductsAlias")
const result = await products.query.fetchObjects({ limit: 1 })
console.log(result.objects[0].properties) // Will include the new "category" field
// Switch alias to new collection (instant switch!)
err = client.Alias().AliasUpdater().WithAlias(&alias.Alias{
Alias: "Products",
Class: "Products_v2",
}).Do(ctx)

require.NoError(t, err)

// All queries using "Products" alias now use the new collection
result, err := client.Data().ObjectsGetter().
WithClassName("Products").
WithLimit(1).
Do(ctx)

require.NoError(t, err)

if len(result) > 0 {
fmt.Printf("%v\n", result[0].Properties) // Will include the new "category" field
}
// Switch the alias to the new collection. The change is instantaneous.
if err := client.Alias.Update(ctx, collections.Alias{
Alias: "ProductsAlias",
Collection: "Products_v2",
}); err != nil {
// handle error
panic(err)
}

// Every query through the alias now reaches the new collection.
products = client.Collections.Use("ProductsAlias")
result, err := products.Query.OverAll(ctx, query.OverAll{Limit: 1})
if err != nil {
// handle error
panic(err)
}
for _, obj := range result.Objects {
fmt.Printf("%v\n", obj.Properties) // Includes the new "category" field
}
// Switch alias to new collection (instant switch!)
client.alias.update("ProductsAlias", "Products_v2");

// All queries using "Products" alias now use the new collection
products = client.collections.use("ProductsAlias");
var result = products.query.fetchObjects(q -> q.limit(1));
System.out.println(result.objects().get(0).properties()); // Will include the new "category" field
// Switch alias to new collection (instant switch!)
await client.Alias.Update(aliasName: ProductsAlias, targetCollection: ProductsV2);

// All queries using "Products" alias now use the new collection
products = client.Collections.Use(ProductsAlias);
var result = await products.Query.FetchObjects(limit: 1);

// Will include the new "category" field
Console.WriteLine(JsonSerializer.Serialize(result.Objects.First().Properties));

Step 8: Verify and clean up​

After verifying that everything works correctly with the new collection, you can safely delete the old one.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Clean up old collection after verification
client.collections.delete("Products_v1")
// Clean up old collection after verification
await client.collections.delete("Products_v1")
// Clean up old collection after verification
err = client.Schema().ClassDeleter().WithClassName("Products_v1").Do(ctx)
// After verifying the migration, delete the old collection.
if err := client.Collections.Delete(ctx, "Products_v1"); err != nil {
// handle error
panic(err)
}
// Clean up old collection after verification
client.collections.delete("Products_v1");
// Clean up old collection after verification
await client.Collections.Delete(ProductsV1);

Summary​

This tutorial demonstrated how to use collection aliases in Weaviate for zero-downtime migrations. Key takeaways:

  • Aliases are pointers to collections that enable instant switching between versions
  • Zero downtime is achieved by preparing the new collection while the old one serves traffic
  • Application code remains unchanged when using aliases instead of direct collection names
  • Rollback is simple - just point the alias back to the previous collection

Collection aliases are essential for production Weaviate deployments where uptime is critical. They enable confident migrations, A/B testing, and flexible deployment strategies without service interruption.

Further resources​

Questions and feedback​