mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-25 19:38:37 +08:00
* Uses MySQL Connector/NET from nuget * Adds SQL Server type to configuration. * Hostname for MySQL connections can include port - Format: <hostname>[:<port>] * Abstracted a bundle of stuff to be generic for both MSSQL and MySQL, including a number of variable and method names. (Mostly went from "sql..." -> "db..." * Changed MiscTools.DBDate() string building for MSSQL, uses DateTime.ToString() with a format which seemed simpler. * Unsure about which lines in .csproj are actually required, and which are auto-munged by Visual Studio. * ... This is my first C# (and VS!) work, be gentle! Signed-off-by: Mike Beattie <mike@ethernal.org>
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using mRemoteNG.App;
|
|
using mRemoteNG.Config.DatabaseConnectors;
|
|
using mRemoteNG.Messages;
|
|
using System;
|
|
|
|
namespace mRemoteNG.Config.Serializers.Versioning
|
|
{
|
|
public class SqlVersion22To23Upgrader : IVersionUpgrader
|
|
{
|
|
private readonly IDatabaseConnector _databaseConnector;
|
|
|
|
public SqlVersion22To23Upgrader(IDatabaseConnector databaseConnector)
|
|
{
|
|
if (databaseConnector == null)
|
|
throw new ArgumentNullException(nameof(databaseConnector));
|
|
|
|
_databaseConnector = databaseConnector;
|
|
}
|
|
|
|
public bool CanUpgrade(Version currentVersion)
|
|
{
|
|
return currentVersion.CompareTo(new Version(2, 2)) == 0;
|
|
}
|
|
|
|
public Version Upgrade()
|
|
{
|
|
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
|
"Upgrading database from version 2.2 to version 2.3.");
|
|
const string sqlText = @"
|
|
ALTER TABLE tblCons
|
|
ADD EnableFontSmoothing bit NOT NULL DEFAULT 0,
|
|
EnableDesktopComposition bit NOT NULL DEFAULT 0,
|
|
InheritEnableFontSmoothing bit NOT NULL DEFAULT 0,
|
|
InheritEnableDesktopComposition bit NOT NULL DEFAULT 0;";
|
|
var dbCommand = _databaseConnector.DbCommand(sqlText);
|
|
dbCommand.ExecuteNonQuery();
|
|
|
|
return new Version(2, 3);
|
|
}
|
|
}
|
|
} |