Synchronization code

This commit is contained in:
sunkaixuan 2023-12-07 04:19:11 +08:00
parent aba7da92b9
commit e67860e0af
2 changed files with 17 additions and 4 deletions

View File

@ -9,11 +9,13 @@ namespace SqlSugar
public class StaticConfig
{
public static bool EnableAot { get; set; }
public static Func<string,string> Encode { get; set; }
public static Func<string,string> Decode{ get; set; }
public static bool AppContext_ConvertInfinityDateTime { get; set; }
public static Func<string, string> Encode { get; set; }
public static Func<string, string> Decode { get; set; }
public static bool AppContext_ConvertInfinityDateTime { get; set; }
public const string CodeFirst_BigString = "varcharmax,longtext,text,clob";
public static string CodeFirst_MySqlCollate{get;set;}
public static Func<long> CustomSnowFlakeFunc;
public static Func<long> CustomSnowFlakeTimeErrorFunc;
public static Func<Guid> CustomGuidFunc;

View File

@ -372,7 +372,7 @@ WHERE EVENT_OBJECT_TABLE = '"+tableName+"'");
public override bool CreateDatabase(string databaseName, string databaseDirectory = null)
{
if (this.Context.Ado.IsValidConnection())
if (this.Context.Ado.IsValidConnection())
{
return true;
}
@ -415,6 +415,17 @@ WHERE EVENT_OBJECT_TABLE = '"+tableName+"'");
{
createSql = createSql.Replace("utf8 COLLATE utf8_general_ci", "utf8mb4");
}
if (!string.IsNullOrEmpty(StaticConfig.CodeFirst_MySqlCollate))
{
if (createSql.Contains(" COLLATE "))
{
createSql = $" {Regex.Split(createSql, " COLLATE ").First()} COLLATE {StaticConfig.CodeFirst_MySqlCollate} ";
}
else
{
createSql += $" COLLATE {StaticConfig.CodeFirst_MySqlCollate} ";
}
}
newDb.Ado.ExecuteCommand(string.Format(createSql, databaseName, databaseDirectory));
}
return true;