Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ Duende Storage separates two kinds of schema change:
opening a database connection. Pass `DatabaseSchemaVersion.Zero` for the full script from an empty database.

`app.Services.GetRequiredService<IStorageInstanceSchema>()` resolves the default storage instance only. For a named
instance, use `IStorageInstanceSchemaFactory.GetStorageInstanceSchema(storageInstanceId, cancellationToken)` to resolve its schema,
as shown in [Multiple Storage Instances](/identityserver/data/providers/duende-storage/multiple-storage-instances.md).
instance, resolve `IStorageInstanceSchemaFactory` and call
`GetStorageInstanceSchema(storageInstanceId, cancellationToken)`. The returned schema provides the same migration,
version-checking, verification, and script-generation operations for that named instance. See
[Multiple Storage Instances](/identityserver/data/providers/duende-storage/multiple-storage-instances.md) for a
complete registration and migration example.

### If a Migration Fails

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ Do not hide a missing connection string or continue startup after a migration fa

The example runs migrations from the application only in development. See
[Deploy the Database Schema](#deploy-the-database-schema) for the production approach.
If you register additional storage instances, resolve each one with
`IStorageInstanceSchemaFactory.GetStorageInstanceSchema(storageInstanceId, cancellationToken)` and migrate it
separately. See [Multiple Storage Instances](/identityserver/data/providers/duende-storage/multiple-storage-instances.md).

### Configuration Stores

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ Selecting a second database provider for the same instance, whether in one `AddS
throws an `InvalidOperationException`. This catches accidental double registration instead of silently replacing the
first provider.

## Choose the Schema API

Use `IStorageInstanceSchema` when you need to create, upgrade, or verify the default storage instance. Resolving it
without a key returns the schema for `StorageInstanceId.Default`.

Use `IStorageInstanceSchemaFactory` when you need the schema for a specific instance. Pass the `StorageInstanceId`
created for the named instance to `GetStorageInstanceSchema(...)`, then call the same migration and verification
methods on the returned `IStorageInstanceSchema`. The factory does not fall back to another instance when the
requested instance is not registered, so configuration errors fail at the point where you resolve the schema.

## Register a Second Instance

Give the instance an explicit ID, register a provider for it, then map a category to it:
Expand Down Expand Up @@ -92,8 +102,8 @@ app.UseIdentityServer();
app.Run();
```

Migrate every instance you register. `IStorageInstanceSchema.MigrateAsync` resolves the default instance only;
use `IStorageInstanceSchemaFactory.GetStorageInstanceSchema(storageInstanceId, ct)` to resolve and migrate a named
Migrate every instance you register. `IStorageInstanceSchema.MigrateAsync` resolves the default instance only. Use
`IStorageInstanceSchemaFactory.GetStorageInstanceSchema(storageInstanceId, ct)` to resolve and migrate each named
instance, as shown above.

## Cross-Product Example: IdentityServer, User Management and Spaces
Expand Down
Loading