Fixes unable to create new DB when it doesnt exists.

This commit is contained in:
hondacrx
2023-01-23 04:10:54 -05:00
parent 6a11bac8ea
commit edcdfa95c4
3 changed files with 35 additions and 34 deletions
+5 -2
View File
@@ -101,8 +101,8 @@ namespace Framework.Database
// Create temporary query to use external MySQL CLi
try
{
using BinaryWriter binaryWriter = new(File.Open(temp, FileMode.Create, FileAccess.Write));
binaryWriter.Write($"CREATE DATABASE `{connectionObject.Database}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
using StreamWriter streamWriter = new(File.Open(temp, FileMode.Create, FileAccess.Write));
streamWriter.Write($"CREATE DATABASE `{connectionObject.Database}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
}
catch (Exception)
{
@@ -131,6 +131,9 @@ namespace Framework.Database
if (_updateFlags == 0)
Log.outInfo(LogFilter.SqlUpdates, "Automatic database updates are disabled for all databases!");
if (_updateFlags != 0 && !DBExecutableUtil.CheckExecutable())
return false;
if (!OpenDatabases())
return false;