File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 1919{
2020 if ( args is not [ "--init-db" , var path ] )
2121 {
22- Console . WriteLine ( "Usage: dotnet run --init-db <path>" ) ;
22+ Console . WriteLine ( "Usage: dotnet run -- -- init-db <path/to/db.sqlite >" ) ;
2323 return 1 ;
2424 }
2525
2626 var initLoggerFactory = LoggerFactory . Create ( builder => builder . AddConsole ( ) . SetMinimumLevel ( logLevel ) ) ;
27- if ( ! Migrator . InitializeDatabase ( initLoggerFactory , path ) )
28- {
29- return 1 ;
30- }
31-
32- return Migrator . ApplyMigrations ( initLoggerFactory , ConnectionString . Create ( path ) ) ? 0 : 1 ;
27+ var initSuccess =
28+ Migrator . InitializeDatabase ( initLoggerFactory , path )
29+ && Migrator . ApplyMigrations ( initLoggerFactory , ConnectionString . Create ( path ) ) ;
30+ return initSuccess ? 0 : 1 ;
3331}
3432
3533var databaseName = Environment . GetEnvironmentVariable ( "DATABASE_NAME" ) ?? "knowledgebase.sqlite" ;
5351var appLoggerFactory = app . Services . GetRequiredService < ILoggerFactory > ( ) ;
5452appLoggerFactory . CreateLogger ( nameof ( Program ) ) . LogInformation ( "Using database at {Path}" , databasePath ) ;
5553
56- if (
57- ! Migrator . InitializeDatabase ( appLoggerFactory , databasePath )
58- || ! Migrator . ApplyMigrations ( appLoggerFactory , connectionString )
59- )
54+ var dbSetupSuccess =
55+ Migrator . InitializeDatabase ( appLoggerFactory , databasePath )
56+ && Migrator . ApplyMigrations ( appLoggerFactory , connectionString ) ;
57+ if ( ! dbSetupSuccess )
6058{
6159 return 1 ;
6260}
You can’t perform that action at this time.
0 commit comments