-
Notifications
You must be signed in to change notification settings - Fork 0
Schema Migration
When you change your type registrations (add a new [Queryable] property, register a new type, etc.), LottaDB detects the schema change on startup and automatically rebuilds the Lucene index from table storage.
// v1: only Actor registered
var db = await catalog.GetDatabaseAsync("main", c => c.Store<Actor>());
// v2: added Note -- schema changed, index auto-rebuilt
var db = await catalog.GetDatabaseAsync("main", c =>
{
c.Store<Actor>();
c.Store<Note>(); // new! triggers rebuild
});The schema hash includes an IndexFormatVersion constant so Lucene document format changes (e.g., adding new stored fields) also trigger a rebuild on upgrade.
JsonSchema entities are loaded from Table Storage at startup and included in the schema hash. When you update a JsonSchema at runtime, the built-in On<JsonSchema> handler detects the change and triggers a selective reindex -- only that document type's Lucene entries are rebuilt, not the entire index.
// Add a new queryable property -- triggers reindex of Person documents only
await db.SaveAsync(new JsonSchema
{
Name = "Person",
Properties = new()
{
new() { Name = "Name", Type = "string" },
new() { Name = "Age", Type = "integer" },
new() { Name = "Email", Type = "string" }, // new!
}
});Deleting a JsonSchema removes its mapper and Lucene index entries.
You can force a full rebuild at any time:
await db.RebuildSearchIndex();This deletes the entire Lucene index and re-indexes all entities (typed and dynamic) from Table Storage in a single pass. Does not run On<T> handlers.