Class RootStructureKey

Namespace: redb.Core.Data
Assembly: redb.Core.dll

The unique key of the root structures of a scheme: one field name once per scheme. The key of
_structures (_id_scheme, _name, _id_parent) lets a root field in twice on PostgreSQL and SQLite, where two
NULL parents are distinct, and nodes syncing one scheme at once used to do exactly that (SQL Server counts NULLs
as equal and refused it). The SQL is the dialect's (the "root structure key" group of );
this class decides.

A database written before the schema lock may hold such duplicates already, and the key cannot be built over
them. A duplicate nothing points to (no value, no child with a value, no structure overriding it, no migration
record) is removed with its subtree; one with values is left alone, and the key waits until the duplicates are
resolved by hand (UPGRADING.md, "Duplicate root structures"). Run under the schema lock, in one transaction.

public static class RootStructureKey

Inheritance

Object→RootStructureKey

Methods

DuplicateProblem(long, string, string, IReadOnlyList<long>)

The problem, and its logged text, for one root field found more than once.

public static RedbSchemaProblem DuplicateProblem(long schemeId, string schemeName, string field, IReadOnlyList<long> ids)

EnsureAsync(IRedbContext, ISqlDialect, bool, ILogger?, CancellationToken)

Removes the empty root duplicates and builds the key when none with values remain. Called only for a dialect

public static Task<bool> EnsureAsync(IRedbContext context, ISqlDialect sql, bool hasMigrationsTable, ILogger? logger, CancellationToken cancellationToken = default)

FindDuplicatesAsync(IRedbContext, ISqlDialect, CancellationToken)

The root duplicates in the database, one problem per field (read only). Asked only while the key is missing:

public static Task<IReadOnlyList<RedbSchemaProblem>> FindDuplicatesAsync(IRedbContext context, ISqlDialect sql, CancellationToken cancellationToken = default)