Index Refactoring
Since v17, the backend items index (Cadmus.Index*) was rewritten in plain SQL for PostgreSQL, dropping Entity Framework and the unused SqlKata dependency, fixing several bugs, and optimizing its schema.
Update
Solutions depending on these packages (API and CLI projects) should:
- update all the Cadmus packages to 17.0.0, and remove any reference to
Cadmus.Index.EforCadmus.Index.Sql, which no longer exist. ReplaceCadmus.Index.Ef.PgSqlwithCadmus.Index.PgSqlwhere possible; keeping it still works, as a deprecated shim. -
index factory providers: projects with their own provider (e.g.
StandardItemIndexFactoryProviderin CLI tools) should register both assemblies, so that both the new and the legacy tags are resolved:ItemIndexFactory.ConfigureServices(services, // Cadmus.Index.PgSql typeof(PgSqlItemIndexWriter).Assembly, // Cadmus.Index.Ef.PgSql (legacy tags) #pragma warning disable CS0618 typeof(Cadmus.Index.Ef.PgSql.EfPgSqlItemIndexWriter).Assembly); #pragma warning restore CS0618Providers registering only the legacy assembly keep working with profiles using the legacy tags. API projects using
Cadmus.Api.Servicesneed no change. - profiles (optional, recommended): replace
item-index-writer.ef-pgwithitem-index-writer.pgsql, anditem-index-reader.ef-pgwithitem-index-reader.pgsql. This requires a provider registeringCadmus.Index.PgSql(see above). - code using the index directly (obsolete members produce warnings, but keep working as before):
await writer.WriteItemAsync(item)instead ofwriter.WriteItem(item), and so on for the other members; removeClose()calls. Note that calls to the obsolete members are now blocking until completion, so that non-awaited calls (e.g._indexWriter.WriteItem(item);in importers) still work.await indexer.BuildAsync(repository, filter, progress, cancel)instead ofindexer.Build(repository, filter, cancel, progress)(mind the parameters order);ClearAsyncinstead ofClear.PgSqlIndexSchema.GetSql()instead ofEfPgSqlItemIndexWriter.GetPgSqlSchema().PgSqlQueryBuilder.BuildItemQuery/BuildPinQueryinstead ofBuildForItem/BuildForPin.
- databases: no action required. Existing index databases are upgraded in place at the first API startup: for big indexes this rewrites the
itemandpintables once, which may take some time (the startup waits for it). Alternatively, runcadmus-tool create-db index <name>before deploying, or drop the index database and rebuild it withcadmus-tool index.