diff --git a/ProjectLighthouse.Tests/DatabaseFact.cs b/ProjectLighthouse.Tests/DatabaseFact.cs index ecb8216f..f1c9341f 100644 --- a/ProjectLighthouse.Tests/DatabaseFact.cs +++ b/ProjectLighthouse.Tests/DatabaseFact.cs @@ -1,3 +1,4 @@ +using Microsoft.EntityFrameworkCore; using ProjectLighthouse.Types; using Xunit; @@ -6,6 +7,10 @@ namespace ProjectLighthouse.Tests { public DatabaseFact() { ServerSettings.DbConnectionString = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse"; if(!ServerSettings.DbConnected) Skip = "Database not available"; + else { + using Database database = new(); + database.Database.Migrate(); + } } } } \ No newline at end of file diff --git a/ProjectLighthouse/Program.cs b/ProjectLighthouse/Program.cs index ae45cb0e..a15a54ac 100644 --- a/ProjectLighthouse/Program.cs +++ b/ProjectLighthouse/Program.cs @@ -13,17 +13,18 @@ namespace ProjectLighthouse { Console.WriteLine("Welcome to Project Lighthouse!"); Console.WriteLine("Determining if the database is available..."); bool dbConnected = ServerSettings.DbConnected; - Console.WriteLine(dbConnected ? "Connected to the database." : "Database unavailable. Exiting."); + Console.WriteLine(dbConnected ? "Connected to the database." : "Database unavailable! Exiting."); if(dbConnected) { Stopwatch migrationStopwatch = new(); migrationStopwatch.Start(); Console.WriteLine("Migrating database..."); - new Database().Database.Migrate(); + using Database database = new(); + database.Database.Migrate(); migrationStopwatch.Stop(); - Console.WriteLine($"Migration took {migrationStopwatch.ElapsedMilliseconds}ms"); + Console.WriteLine($"Migration took {migrationStopwatch.ElapsedMilliseconds}ms."); } else Environment.Exit(1); startupStopwatch.Stop();