Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Migrating from V2 Schema to V3 Example #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 27 additions & 1 deletion docs/sqlserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,30 @@ TODO

# Migrating from V2 Schema to V3

TODO
// simplified code example

var settings = new MsSqlStreamStoreV3Settings(); // you can set some not default values
var v3Store = new MsSqlStreamStoreV3(settings);
await v3Store.CreateSchemaIfNotExists();
var checkSchemaResult = await v3Store.CheckSchema();
_logger.LogInformation($"checkSchemaResult before Migrate CurrentVersion {checkSchemaResult.CurrentVersion } ");
if (checkSchemaResult.CurrentVersion == 2)
{
// you can consider to run migration as fire and forget to not block the main thread
//Task.Factory.StartNew(() => MigrateToV3());

_logger.LogInformation($"Before Migrate IsMatch {checkSchemaResult.IsMatch()} CurrentVersion {checkSchemaResult.CurrentVersion} ExpectedVersion {checkSchemaResult.ExpectedVersion} ");
var progress = new Progress<MigrateProgress>();
progress.ProgressChanged += (_, migrateProgress) =>
_logger.LogInformation($"Migration stage complete: {migrateProgress.Stage}");
await v3Store.Migrate(progress, CancellationToken.None)

checkSchemaResult = await v3Store.CheckSchema();
_logger.LogInformation($"After Migrate IsMatch {checkSchemaResult.IsMatch()} CurrentVersion {checkSchemaResult.CurrentVersion} ExpectedVersion {checkSchemaResult.ExpectedVersion} ");
}
return v3Store;


See more details in [Wiki Example-of-Migration-to-MsSqlStreamStoreV3](https://github.com/SQLStreamStore/SQLStreamStore/wiki/Example-of-Migration-to-MsSqlStreamStoreV3)