Skip to content

Commit

Permalink
Updates SchemaInitializer to enable SqlServerFhirModel initialization…
Browse files Browse the repository at this point in the history
… changes. (#44)
  • Loading branch information
rotodd authored Jun 8, 2020
1 parent eb73cf1 commit 0800f6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SchemaInitializer : IStartable
private readonly SchemaUpgradeRunner _schemaUpgradeRunner;
private readonly SchemaInformation _schemaInformation;
private readonly ILogger<SchemaInitializer> _logger;
private bool _started;

public SchemaInitializer(SqlServerDataStoreConfiguration sqlServerDataStoreConfiguration, SchemaUpgradeRunner schemaUpgradeRunner, SchemaInformation schemaInformation, ILogger<SchemaInitializer> logger)
{
Expand Down Expand Up @@ -190,13 +191,17 @@ private bool CanInitialize()

public void Start()
{
if (!string.IsNullOrWhiteSpace(_sqlServerDataStoreConfiguration.ConnectionString))
if (!_started)
{
Initialize();
}
else
{
_logger.LogCritical("There was no connection string supplied. Schema initialization can not be completed.");
if (!string.IsNullOrWhiteSpace(_sqlServerDataStoreConfiguration.ConnectionString))
{
Initialize();
_started = true;
}
else
{
_logger.LogCritical("There was no connection string supplied. Schema initialization can not be completed.");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static IServiceCollection AddSqlServerBase<TSchemaVersionEnum>(

services.Add<SchemaInitializer>()
.Singleton()
.AsSelf()
.AsService<IStartable>();

services.Add<ScriptProvider<TSchemaVersionEnum>>()
Expand Down

0 comments on commit 0800f6f

Please sign in to comment.